14
votes

I have a package in the PyPI repository. I include a Windows installer by running the following command to upload a new version, specifically the 'bdist_wininst':

python3 setup.py register sdist bdist_wininst upload

However, when a user runs the associated .exe file, it does not install Python 3 itself. Furthermore, even if Python 3 is installed, it will not install any associated dependencies.

What is the best way to create a windows installer that will install Python 3 if it is not installed, along with my package and its dependencies?

If that is not possible, what is the best way to create a windows installer that will install my package and its dependencies, assuming Python 3 is installed?

I'm on Ubuntu 12.04. If it's of any assistance, here is my setup.py:

from distutils.core import setup

import codecs 
try: 
    codecs.lookup('mbcs') 
except LookupError: 
    ascii = codecs.lookup('ascii') 
    func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs') 
    codecs.register(func) 

setup(
    name='SIGACTor',
    version='0.1.14dev',
    description=open('README.txt').read(),
    url='http://bitbucket.org/davidystephenson/sigactor',
    author='David Y. Stephenson',
    author_email='[email protected]',
    packages=['sigactor'],
    license='Proprietary',
    long_description=open('README.txt').read(),
    install_requires=[
        'beautifulsoup4',
        'feedparser',
        'python-dateutil',
        'pyyaml'
    ],
)
1
people should answer this only once: askubuntu.com/questions/315428/… --- as askubuntu points people back to stackoverflow, maybe this question should becom the place where the question is answered :) - mnagel
My apologies - I didn't understand the question would be migrated. - David Y. Stephenson
Are you wanting to make a Windows executable? Have you tried using py2exe or PyInstaller ? These packages would you to create an exe that allows a computer without Python already installed to run your program. - sytech
@Gator_Python I'm trying to create an installer for a python module. - Daniel
@Daniel -- Isn't that the purpose of pip and PyPI? I just successfully downloaded and installed this package (and its dependencies) from PyPI on my Windows machine using pip install sigactor on Python3. pip ships with Python on Windows. - sytech

1 Answers

5
votes

You should definetely try out pynsist which can bundle Python with your packages and is based on well-established NSIS open-source installer:

https://pypi.python.org/pypi/pynsist

Anaconda team provides Constructor which is based on conda and NSIS again:

https://github.com/conda/constructor

Finally this approach using WinPython and most stable installer called InnoSetup:

http://cyrille.rossant.net/create-a-standalone-windows-installer-for-your-python-application/

But if your package is not a library but an application then you can bundle it (freeze) with Python and all dependencies, even compress it using pyinstaller:

http://www.pyinstaller.org

This is what I use for all of my apps even with crazy interop dependencies!

Bonus - auto update tool for pyinstaller:

https://github.com/JMSwag/PyUpdater