takluyver / pynsist

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

Error when including local python packages #185

Closed eliabieri closed 5 years ago

eliabieri commented 5 years ago

Hi there, I get the following error when executing nsist.InstallerBuilder(...).run()

  File "/home/bieri/git/pythonappskeleton/venv/lib/python3.5/site-packages/nsist/__init__.py", line 474, in run
    self.prepare_packages()
  File "/home/bieri/git/pythonappskeleton/venv/lib/python3.5/site-packages/nsist/__init__.py", line 351, in prepare_packages
    py_version=self.py_version, exclude=self.exclude)
  File "/home/bieri/git/pythonappskeleton/venv/lib/python3.5/site-packages/nsist/copymodules.py", line 165, in copy_modules
    mc.copy(modname, target, exclude)
  File "/home/bieri/git/pythonappskeleton/venv/lib/python3.5/site-packages/nsist/copymodules.py", line 115, in copy
    raise ImportError('Could not find %r' % modname)
ImportError: Could not find 'lib'

I run the installer builder the following way:

shortcuts = {appName: {
                "entry_point": "main:main",
                "console": True,
                "icon": os.path.join(args.sourceDir, "windows_installer", "icon.ico")}
            }
factory = nsist.InstallerBuilder(
    appname = appName,
    version = version,
    shortcuts = shortcuts,
    packages = ["lib"],
    pypi_wheel_reqs = pipRequirements,
    py_version = "3.7.4",
    py_bitness = 64,
    build_dir = os.path.join(args.outputDir, "windows_installer"),
    installer_name = "{}_{}_installer.exe".format(appName, version)
)

factory.run()

My lib folder is empty but contains the necessary __init__.py pynsist (v 2.4) runs in a virtual env wih python 3.5.3

I had no problems using this setup under python 2.7

takluyver commented 5 years ago

Using pynsist from Python code, this will probably depend on your files layout and how you run the build scripts. It will look for lib as an importable module in the CWD, then in the list of directories on sys.path.

eliabieri commented 5 years ago

Adding lib to sys.path helped. Thanks