2

I am packaging a Python 2.7 program with the lastest version of Pynsist.
I've created an installer.cfg file following this example.
But when I try to package my application running

pynsist installer.cgf

into the application folder it comes up with

Copying Python installer to build directory
PyLauncher MSI already in build directory.
Copying packages into build directory...
Traceback (most recent call last):
  File "/usr/local/bin/pynsist", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/nsist/__init__.py", line 540, in main
    InstallerBuilder(**args).run(makensis=(not options.no_makensis))
  File "/usr/local/lib/python2.7/dist-packages/nsist/__init__.py", line 495, in run
    self.prepare_packages()
  File "/usr/local/lib/python2.7/dist-packages/nsist/__init__.py", line 381, in prepare_packages
    py_version=self.py_version, exclude=self.exclude)
  File "/usr/local/lib/python2.7/dist-packages/nsist/copymodules.py", line 224, in copy_modules
    mc.copy(modname, target, exclude)
  File "/usr/local/lib/python2.7/dist-packages/nsist/copymodules.py", line 195, in copy
    check_package_for_ext_mods(path, self.py_version)
  File "/usr/local/lib/python2.7/dist-packages/nsist/copymodules.py", line 41, in check_package_for_ext_mods
    check_ext_mod(os.path.join(path, dirpath, filename), target_python)
  File "/usr/local/lib/python2.7/dist-packages/nsist/copymodules.py", line 30, in check_ext_mod
    raise ExtensionModuleMismatch(extensionmod_errmsg % ('Windows', path))
nsist.copymodules.ExtensionModuleMismatch: Found an extension module that will not be usable on Windows:
/usr/lib/python2.7/dist-packages/pygame/rwobject.so
Put Windows packages in pynsist_pkgs/ to avoid this.

So the problem I think is with Pygame.

On Google there in nothing about this, but i cannot use others programs for packaging(eg. py2exe, pyinstaller ecc...).
Thanks and sorry for the bad english

Richard Wave
  • 89
  • 2
  • 10
  • 1
    If you put pygame in `packages=`, it tries to copy it from your computer. But that's pygame for Linux, which won't work on Windows. You can get round this by using a wheel for pygame - Pynsist will automatically pick a Windows wheel. Have a look at the pygame example here: https://github.com/takluyver/pynsist/tree/master/examples/pygame – Thomas K Sep 05 '17 at 07:44
  • @ThomasK I had a look at the example but I didn't understand very well... i have to download the windows-version of pygame and....? And why with the others modules i have not this problem? – Richard Wave Sep 06 '17 at 09:39
  • If you put pygame in the `pypi_wheels=` bit of the config file (instead of `packages=`), Pynsist will take care of downloading it for you. You shouldn't need to do anything yourself. Most packages don't have this problem because they only contain Python code, which is the same files on all platforms. Pygame has compiled modules, which have to be compiled for the right platform. – Thomas K Sep 07 '17 at 10:35
  • @ThomasK, thanks!!! Now the .exe generated (Under Linux) should work under windows? – Richard Wave Sep 07 '17 at 14:38
  • Yup, that's the idea! – Thomas K Sep 08 '17 at 15:44
  • @ThomasK It works! thanks! – Richard Wave Sep 12 '17 at 14:15

1 Answers1

2

Reposting as an answer, since it worked:

If you put pygame in packages=, it tries to copy it from your computer. But on your computer that's pygame for Linux, which won't work on Windows. If you instead put pygame in the pypi_wheels= bit of the config file, Pynsist will take care of downloading a Windows version for you.

Have a look at the pygame example in the Pynsist repository.

Most packages don't have this problem because they only contain Python code, which is the same files on all platforms. Pygame has compiled modules, which have to be compiled for the right platform.

Thomas K
  • 39,200
  • 7
  • 84
  • 86