Windows installer for cellprofiler Python package?

Dear CellProfiler developers,

is there a way to create a Windows installer that installs the cellprofiler/bioformats/contrib packages into the site-packages directory of an existing Python installation? Here is a simple script that produces such an installer when running ‘python setup_wininst.py bdist_wininst’:

"""setup_wininst.py

Distutils script for creating CellProfiler installer for Windows.

Usage: python setup_wininst.py bdist_wininst --user-access-control=auto

Assumes that Java SDK headers and libraries are found in the
INCLUDE and LIB environment variables, e.g.:
set INCLUDE=C:\Java\include\win32;C:\Java\include;%INCLUDE%
set LIB=C:\Java\lib;%LIB%

The installer places the CellProfiler packages into Python\Lib\site-packages, 
and CellProfiler.py in the Python\Scripts directory.

CellProfiler depends the Decorator, MySQLdb, NumPy, SciPy, Matplotlib, Wx,
and PIL extension packages, which need to be installed separately.
http://cellprofiler.org/wiki/index.php/Main_Page#For_Windows

"""

import sys
import os
import glob

from distutils.core import setup, Extension

import numpy
from numpy import get_include

from Cython.Distutils import build_ext


version = '2.0'
try:
    version += '.dev' + open('.svn\\entries').readlines()[3].strip()
except:
    pass


setup(
    name="CellProfiler",
    version=version,
    url ="http://www.cellprofiler.org",
    description="""
        CellProfiler is free open-source software designed to enable
        biologists without training in computer vision or programming
        to quantitatively measure phenotypes from thousands of images
        automatically.""",
    license='GPLv2',
    author="Broad Institute",
    scripts='CellProfiler.py'],
    packages=
        'cellprofiler',
        'cellprofiler.cpmath',
        'cellprofiler.cpmath.tests',
        'cellprofiler.gui',
        'cellprofiler.gui.html',
        'cellprofiler.gui.tests',
        'cellprofiler.icons',
        'cellprofiler.matlab',
        'cellprofiler.matlab.tests',
        'cellprofiler.modules',
        'cellprofiler.modules.plugins',
        'cellprofiler.modules.tests',
        'cellprofiler.utilities',
        'cellprofiler.utilities.tests',
        'cellprofiler.tests',
        'bioformats',
        'bioformats.tests',
        'imagej',
        'imagej.tests',
        'contrib'
        ],
    cmdclass={'build_ext': build_ext},
    ext_modules=
        Extension(
            name="cellprofiler.cpmath._cpmorphology",
            sources="cellprofiler/cpmath/src/cpmorphology.c"],
            include_dirs='cellprofiler/cpmath/src']+[get_include()]
            ),
        Extension(
            name="cellprofiler.cpmath._cpmorphology2",
            sources="cellprofiler/cpmath/_cpmorphology2.pyx"],
            include_dirs=[get_include()]
            ),
        Extension(
            name="cellprofiler.cpmath._watershed",
            sources="cellprofiler/cpmath/_watershed.pyx",
                     "cellprofiler/cpmath/heap_watershed.pxi"],
            include_dirs='cellprofiler/cpmath/src']+[get_include()]
            ),
        Extension(
            name="cellprofiler.cpmath._propagate",
            sources="cellprofiler/cpmath/_propagate.pyx",
                     "cellprofiler/cpmath/heap.pxi"],
            include_dirs='cellprofiler/cpmath/src']+[get_include()]
            ),
        Extension(
            name="cellprofiler.cpmath._filter",
            sources="cellprofiler/cpmath/_filter.pyx"],
            include_dirs='cellprofiler/cpmath/src']+[get_include()]
            ),
        Extension(
            name="cellprofiler.utilities._get_proper_case_filename",
            sources="cellprofiler/utilities/get_proper_case_filename.c"],
            libraries="shlwapi", "shell32", "ole32"]
            ),
        Extension(
            name="cellprofiler.utilities.javabridge",
            sources="cellprofiler/utilities/javabridge.pyx",
                     "cellprofiler/utilities/strtoull.c"],
            libraries="jvm"]
            ),
        Extension(
            name="contrib.LAP",
            sources="contrib/mexLap.c", "contrib/LAP.pyx"],
            include_dirs=[get_include()]
            )
        ],
    data_files=
        ('Lib/site-packages/cellprofiler/icons', glob.glob(os.path.join(
            '.', 'cellprofiler', 'icons', '*.png'))),
        ('Lib/site-packages/bioformats', 'bioformats/loci_tools.jar']),
        ('Lib/site-packages/imagej', glob.glob(os.path.join(
            '.', 'imagej', '*.jar'))),
        ]
    )

Would it be possible to include the decorator.py module in the cellprofiler or the contrib directory? It seems to be the only external dependency that is not widely used and it is only a single file (BSD license).

The following patch allows CellProfiler.py to be run from the Python\Scripts directory.

Index: CellProfiler.py
===================================================================
--- CellProfiler.py     (revision 9908)
+++ CellProfiler.py     (working copy)
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 """
 CellProfiler is distributed under the GNU General Public License.
 See the accompanying file LICENSE for details.
@@ -87,7 +88,7 @@
 if not hasattr(sys, 'frozen'):
     parser.add_option("-b", "--do-not_build",
                       dest="build_extensions",
-                      default=True,
+                      default=not root.endswith('cripts'),
                       action="store_false",
                       help="Do not build C and Cython extensions")
 parser.add_option("-d", "--done-file",

Best,

Christoph Gohlke
Laboratory for Fluorescence Dynamics
University of California, Irvine

Hi Christoph,
First of all, I’d like to thank you for the 64-bit packages on your website; we use them extensively for our Windows distribution (we have a license for the Intel MKS library).

There is a binary distribution for Windows 32 & 64 which is intended for users who haven’t installed Python or who might want to avoid conflicts with our Python. It would be nice to make CellProfiler available as a package; we’d love to have others use our image processing routines, our bridge to Java and the BioFormats library. Our directory structure should probably change somewhat if we were to use your script. “cellprofiler”, “bioformats”, and “imagej” aren’t bad names for packages, but “contrib” probably needs to be below “cellprofiler”; “contrib” is too generic. I’ll bring up the issues to the group and see about adding the install script to the build.

–Lee Kamentsky

Hi Lee,

thanks for considering to make cellprofiler available as a package. Relocating the contrib folder is a good idea. You should also include license files for cellprofiler and the modules in contrib.

Christoph