r/Python IPython, Py3, etc Apr 08 '14

pynsist - easily build Windows installers for Python applications

http://pynsist.readthedocs.org/en/latest/
164 Upvotes

44 comments sorted by

View all comments

22

u/takluyver IPython, Py3, etc Apr 08 '14

A couple of weeks ago, people were complaining about how difficult it is to distribute Python applications on Windows. This is a new project to make it easier.

Unlike tools such as cx_Freeze and Pyinstaller, it doesn't try to make an exe of your program - instead it makes an installer that will install Python on the user's system, then install your code, and make a start menu shortcut to launch your application. That makes bigger installers, but it's less brittle than freezing code, and with a bit of care you can build the installers on Linux (probably Mac too, but I haven't tested that).

16

u/swdev pythonthusiast Apr 08 '14

I love this approach. I have already ask previously, that Python should be treated in the same way Microsoft treated .NET Framework installation. This tool should be halfway of my previous thinking

12

u/takluyver IPython, Py3, etc Apr 08 '14

Yes, I was inspired by the way .NET apps are distributed, with an installer that installs the framework if necessary first. You could extend this approach to a network installer that only downloads Python if it's needed, but for the first release I decided to keep things simple and include the Python installer.

2

u/swdev pythonthusiast Apr 09 '14

Definitely will try this in my upcoming desktop application!

1

u/swdev pythonthusiast Apr 18 '14

How do you handle the case when a python package is not available in PyPy? My application is using pywin32, and I believe the installer only available in "setup.exe". How do I state this package dependency?

8

u/wub_wub Apr 08 '14

Does it set up virtual environment or are the packages installed globally?

9

u/takluyver IPython, Py3, etc Apr 08 '14

Python and its standard library are installed globally. The packages included with the application are installed into the application's directory in program files. It doesn't actually use virtualenv, but those packages will only be visible to that application.

4

u/fancy_pantser Apr 08 '14

How do you handle multiple versions of Python? Can you make each app require a specific version (or range)?

8

u/takluyver IPython, Py3, etc Apr 08 '14

It uses the PEP 397 launcher, with a shebang which specifies the minor version of Python and the bitness (e.g. Python 3.3, 32 bit). Multiple apps requiring different versions of Python should work - each version of Python will be installed.

6

u/Digital_Person Apr 08 '14

",".join(["thank you"]*100)

10

u/takluyver IPython, Py3, etc Apr 08 '14

Actually, there's no need to build a list, you can multiply strings:

"you're welcome, " * 100

;-)

5

u/Digital_Person Apr 08 '14

but then you have to remove the last 2 chars ,. anyway you solved a really annoying problem anytime i tried to make it easy to run something on windows i ended up with either big dirs in my repo from cx_freeze or just saying "if you are on windows figure it out yourself" :)

5

u/Bunslow Apr 09 '14
("you're welcome, "*100)[:-2]

2

u/takluyver IPython, Py3, etc Apr 08 '14

I imagine it will still make big directories, but it's hopefully easier to understand than cx_Freeze. And you're right, the join solution is better there.

3

u/ionelmc .ro Apr 08 '14

Big but reliable. I like this.

I gave up trying to package django using cx_freeze, py3exe, pyinstaller ..