0

I'm a scientific python programmer and don't have much experience making packages for distribution.

What I'm trying to do is create a complete package (Windows 7) that will install (or check and install):

1) correct python version 2) third party packages necessary for my package, i.e. numpy, pandas, matplotlib 3) my python package

on a user's local machine.

I will then put this complete package on a shared network drive. Basically I want to make it as easy as possible to port the python functionality I created to others. The end user will not be developing the python code. I read on the Hitchiker's Guide and some of the Python docs but am having a bit of trouble piecing it all together.

Would it be easier to compile an executable? Is this possible?

  • Looks like duplicate : http://stackoverflow.com/questions/5458048/how-to-make-a-python-script-standalone-executable-to-run-without-any-dependency – Ciasto piekarz Jun 23 '14 at 15:40

3 Answers3

0

I haven't done this in a while, but I used to use innosetup to create an installer that would install all necessary packages. You can glob all the packages into the installer.

monkut
  • 42,176
  • 24
  • 124
  • 155
0

This is probably not the best route (I was unable to figure out py2exe), but you could create a batch file that runs through binary installer packages, for install of python, pip and other, then run pip install -r requirements.txt

This method requires an internet connection if using pip.

You could also zip the python directory. Install python, unzip the folder, and copy it over?

Or include all the windows installer binaries?

pip example: How to pip install packages according to requirements.txt from a local directory?

pip installer: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip

python installer: https://www.python.org/downloads/

Example Batch script:

@ ECHO off
@ REM off
# msi examples
msiexec /i dependencies\python-2.7.6.msi
msiexec /i dependencies\pycurl-7.19.0.2.win32-py2.7.msi
# exe examples
start dependencies\paramiko-1.7.7.1.win32-py2.7.exe
start dependencies\pycrypto-2.3.win32-py2.7.exe
start dependencies\pip-1.5.4.win32-py2.7.exe
start dependencies\wxPython3.0-win32-3.0.0.0-py27.exe
pip install image
pip install -r requirements.txt
pause

example requirements.txt:

image==1.2
BeautifulSoup==3.2.1
PyYAML==3.10
beautifulsoup4==4.3.2
distribute==0.6.49
idna==0.3
pyparsing==2.0.1
python-dateutil==2.2
pywin==0.3.1
selenium==2.40.0
six==1.6.1

A useful pip function is to use pip freeze (docs) to snag the dependencies/requirements.

example of setting python path in batch:

set path=%path%;C:\python27;C:\python27\scripts
reg ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d %path% /f
Community
  • 1
  • 1
jmunsch
  • 22,771
  • 11
  • 93
  • 114
0

This is a little bit off course, but what I've done at work is copy the installer of Anaconda to a shared directory.

It includes almost all the scientific libraries and that way each of my coworkers is working from the same install and libraries. It will install without admin privileges for the user which is important where I work. It also adds python.exe to their path so they can execute scripts wherever they download them.

It's not exactly an answer to what you are asking but it might be worth looking into. It also includes a couple IDEs that made editing scripts easier for non-programmers.

chaps
  • 158
  • 1
  • 6