4

I have some small Python programs which depend on several big libraries, such as:

  • NumPy & SciPy
  • matplotlib
  • PyQt
  • OpenCV
  • PIL

I'd like to make it easier to install these programs for Windows users. Currently I have two options:

  • either create huge executable bundles with PyInstaller, py2exe or similar tool,
  • or write step-by-step manual installation instructions.

Executable bundles are way too big. I always feel like there is some magic happening, which may or may not work the next time I use a different library or a new library version. I dislike wasted space too. Manual installation is too easy to do wrong, there are too many steps: download this particular interpreter version, download numpy, scipy, pyqt, pil binaries, make sure they all are built for the same python version and the same platform, install one after another, download and unpack OpenCV, copy its .pyd file deep inside Python installation, setup environment variables and file asssociations... You see, few users will have the patience and self-confidence to do all this.

What I'd like to do: distribute only a small Python source and, probably, an installation script, which fetches and installs all the missing dependencies (correct versions, correct platform, installs them in the right order). That's a trivial task with any Linux package manager, but I just don't know which tools can accomplish it on Windows. Are there simple tools which can generate Windows installers from a list of URLs of dependencies1?

1 As you may have noticed, most of the libraries I listed are not installable with pip/easy_install, but require to run their own installers and modify some files and environment variables.

sastanin
  • 40,473
  • 13
  • 103
  • 130
  • +1- Many people have this problem. It would be great if you could share how you accomplished this, in a separate answer of your own. – Abid Rahman K Jul 28 '12 at 05:54

3 Answers3

2

npackd exists http://code.google.com/p/windows-package-manager/ It could be done through here or use distribute (python 3.x) or setuptools (python 2.x) with easy_install, possibly pip (don't know it's windows compatibility). But I would choose npackd because PyQt and it's unusual setup for pip/easy_install (doesn't play with them nicely, using a configure.py instead of setup.py). Though you would have to create your own repo for npackd to use for some of them. I forget what is contributed in total for python libs with it.

Mike Ramirez
  • 10,750
  • 3
  • 26
  • 20
  • The problem with the libraries above that they require to run their own installers. OpenCV for Python requires to download and unpack a zip file, and then copy *.pyd files into the Python installation. It's nice to know there are maintained package managers for windows. – sastanin Jul 27 '12 at 19:47
  • @sastanin npackd runs external installers, check it out. – Mike Ramirez Jul 28 '12 at 01:00
  • 1
    if you choose Npackd, I would help you with inclusion of prerequisites in the default repository: http://code.google.com/p/windows-package-manager/issues/entry – kaboom Jul 28 '12 at 19:16
1

AFAIK there is no tool (and I'd assume you googled), so you must make one yourself.

Fetching the proper library versions seems simple enough -- using python's ftplib you can fetch the proper installers for every library. How would you know which version is compatible with the user's python? You can store different lists of download URLs, each for a different python version (this method came off the top of my head and there is probably a better way; not that it matters much if it's simple and it works).

After you figure out how to make each installer run, you can py2exe your installer script, and even use it to fetch the program itself.


EDIT

Some Considerations

There are a couple of things that popped into my mind just as I posted: First, some pseudocode (how I would approach it, anyway)

#first, we check modules
try:
    import numpy
except ImportError:
    #flag numpy for installation
#lather, rinse repeat for all dependencies

#next we check version compatibility -- note that if a library version you need 
#is not backwards-compatible, you're in DLL hell, and there is little we can do.
<insert version-checking code here>

#once you have your unavailable dependencies, you install them
import ftplib
<all your file-downloading here>

#now you install. sorry I can't help you here.

There are a few things you can do to make your utility reusable --

  • put all URL lists, minimum version numbers, required library names etc in config files
  • Write a script which helps you set up an installer
  • Py2exe the installer-maker-script
  • Sell it
  • Even better, release it under GPL so we can all feast upon fruits of your labours.
Community
  • 1
  • 1
Moop
  • 456
  • 4
  • 9
  • It seems to be a doable approach. I just hope someone already did it, so I don't have to write, debug and maintain it. So far I've found [py2nsis, installer script generator](http://code.google.com/p/py2nsis/). – sastanin Jul 27 '12 at 19:45
0

I have a similar need as you, but in addition I need the packaged application to work on several platforms. I'm currently exploring the currently available solutions, here are a few interesting ones:

I will update here if I find something that fills my bill.

Community
  • 1
  • 1
gaborous
  • 15,832
  • 10
  • 83
  • 102