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'
],
)
In this case, you have two options: Use the pipdeptree utility to gather a list of all dependencies, create a requirements. txt file listing all the dependencies, and then download them with the pip download command. Get the list of dependencies for a package from the setup.py file.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With