gaganpreet/udemy-dl — pull request #21 by InsomniacSoftware (2014-12-05 22:59:37+00:00)
Title: setup.py fixes

First, let me say a huge thanks to you for this script. Being able to download the videos for offline viewing is a great benefit to me. In fact, while looking at different video tutorial sites, I went with Udemy's courses just because I knew it would be possible to download the videos by using your script.

However, I just installed udemy-dl per your README instructions and was unable to run it. Using sudo to install udemy-dl caused the udemy_dl and beautifulsoup package directories to be owned and accessible only to the root user.

```console
$ sudo pip install udemy-dl
Password:
Downloading/unpacking udemy-dl
Downloading udemy-dl-0.1.tar.gz
Running setup.py (path:/private/tmp/pip_build_root/udemy-dl/setup.py) egg_info for package udemy-dl
Pandoc not installed

Downloading/unpacking beautifulsoup4 (from udemy-dl)
Downloading beautifulsoup4-4.3.2.tar.gz (143kB): 143kB downloaded
Running setup.py (path:/private/tmp/pip_build_root/beautifulsoup4/setup.py) egg_info for package beautifulsoup4

Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.7/site-packages (from udemy-dl)
Installing collected packages: udemy-dl, beautifulsoup4
Running setup.py install for udemy-dl
Pandoc not installed
changing mode of build/scripts-2.7/udemy-dl from 600 to 755

changing mode of /usr/local/bin/udemy-dl to 755
Running setup.py install for beautifulsoup4

Successfully installed udemy-dl beautifulsoup4
Cleaning up...

$ udemy-dl --help
Traceback (most recent call last):
File "/usr/local/bin/udemy-dl", line 4, in
from udemy_dl.udemy_dl import main
ImportError: No module named udemy_dl.udemy_dl
```

During install, `pip` sets the necessary permissions (755) for any user to use the script file
```console
$ ls -l /usr/local/bin/udemy-dl
-rwxr-xr-x 1 root wheel 116 Dec 5 08:48 udemy-dl
```

but it does not change the permissions on the package directories, thus they are not accessible to anyone except root
```console
$ ls -l /usr/local/lib/python2.7/site-packages/
drwx------ 7 root wheel 238 Dec 5 08:48 beautifulsoup4-4.3.2-py2.7.egg-info/
drwx------ 14 root wheel 476 Dec 5 08:48 bs4/
drwx------ 6 root wheel 204 Dec 5 08:48 udemy_dl/
drwx------ 8 root wheel 272 Dec 5 08:48 udemy_dl-0.1-py2.7.egg-info/
```

**Summary**
* The first commit in this patch modifies the setup.py file so that when installing as root or using sudo, it will set the umask so all users have read/exec permissions of the installed files.
* The second commit adds a check for the setuptools package and uses it over distutils. The 'install_requires' argument to the setup call is not valid with distutils so it throws an 'unknown option' warning during install.