takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
896 stars 119 forks source link

I'm having some trouble including the requests lib on an installer. #59

Closed ghost closed 8 years ago

ghost commented 8 years ago

I tried running one of the examples on the documentation, the guessnumber, and adding the requests lib, I got this error message:

[xor@localhost guessnumber]$ pynsist installer.cfg 
Downloading Python installer...
Getting https://www.python.org/ftp/python/3.4.3/python-3.4.3.amd64.msi
Copying Python installer to build directory
Copying packages into build directory...
Traceback (most recent call last):
  File "/usr/bin/pynsist", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.4/site-packages/nsist/__init__.py", line 490, in main
    ).run(makensis=(not options.no_makensis))
  File "/usr/lib/python3.4/site-packages/nsist/__init__.py", line 431, in run
    self.prepare_packages()
  File "/usr/lib/python3.4/site-packages/nsist/__init__.py", line 329, in prepare_packages
    py_version=self.py_version, exclude=self.exclude)
  File "/usr/lib/python3.4/site-packages/nsist/copymodules.py", line 224, in copy_modules
    mc.copy(modname, target, exclude)
  File "/usr/lib/python3.4/site-packages/nsist/copymodules.py", line 139, in copy
    ignore=shutil.ignore_patterns('*.pyc')
  File "/usr/lib64/python3.4/shutil.py", line 343, in copytree
    raise Error(errors)
shutil.Error: [('/usr/lib/python3.4/site-packages/requests/packages/chardet', 'build/nsis/pkgs/requests/packages/chardet', "[Errno 21] Is a directory: '/usr/lib/python3.4/site-packages/requests/packages/chardet'"), ('/usr/lib/python3.4/site-packages/requests/packages/urllib3', 'build/nsis/pkgs/requests/packages/urllib3', "[Errno 21] Is a directory: '/usr/lib/python3.4/site-packages/requests/packages/urllib3'")]
takluyver commented 8 years ago

I think you're running into a bug in the standard library shutil module. It got fixed in Python 3.4.4, but I guess your system Python version is slightly older (as is mine).

If I'm right, the problem arises because your Linux distro has unbundled chardet and urllib3 from requests by making symlinks that point to the location of those packages installed separately. So, short of upgrading Python, you can probably avoid the problem by installing a copy of requests using pip (e.g. pip install --user requests). So long as your sys.path order is correct, Pynsist should find that before the system-installed copy.

ghost commented 8 years ago

Thanks for the help.