From cc5533b17a8f040df3049c0fbd2149025f23d802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Sep 2012 18:49:21 +0200 Subject: [PATCH 1/3] Add dependencies to setup process --- setup.py | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index efa5f8db..40ad846f 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ try: except ImportError: from distutils.command.build_py import build_py + def configuration(parent_package='', top_path=None): if os.path.exists('MANIFEST'): os.remove('MANIFEST') @@ -44,6 +45,7 @@ def configuration(parent_package='', top_path=None): return config + def write_version_py(filename='skimage/version.py'): template = """# THIS FILE IS GENERATED FROM THE SKIMAGE SETUP.PY version='%s' @@ -57,6 +59,7 @@ version='%s' finally: vfile.close() + if __name__ == "__main__": write_version_py() @@ -72,23 +75,32 @@ if __name__ == "__main__": version=VERSION, classifiers = - [ 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: C', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Operating System :: Unix', - 'Operating System :: MacOS', - ], + ['Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: C', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Scientific/Engineering', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Operating System :: Unix', + 'Operating System :: MacOS', + ], configuration=configuration, - install_requires=[], + install_requires= + ['Python >= 2.5', + 'Numpy >= 1.6', + 'Cython >= 0.15', + 'SciPy >= 0.10', + ], + extras_require= + {'Viewer': ['PyQt', 'matplotlib'], + 'Tests': ['nose'], + }, packages=setuptools.find_packages(), include_package_data=True, zip_safe=False, # the package can run out of an .egg file From ab58ed0ce1e5dd3b2a3b60fb199362d566e40591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 8 Sep 2012 20:02:53 +0200 Subject: [PATCH 2/3] Improve code layout --- setup.py | 60 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/setup.py b/setup.py index 40ad846f..48ea48a8 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -descr = """Image Processing SciKit +descr = """Image Processing SciKit Image processing algorithms for SciPy, including IO, morphology, filtering, warping, color manipulation, object detection, etc. @@ -74,41 +74,43 @@ if __name__ == "__main__": download_url=DOWNLOAD_URL, version=VERSION, - classifiers = - ['Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: C', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Operating System :: Unix', - 'Operating System :: MacOS', - ], + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: C', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Scientific/Engineering', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Operating System :: Unix', + 'Operating System :: MacOS', + ], configuration=configuration, - install_requires= - ['Python >= 2.5', - 'Numpy >= 1.6', - 'Cython >= 0.15', - 'SciPy >= 0.10', - ], - extras_require= - {'Viewer': ['PyQt', 'matplotlib'], - 'Tests': ['nose'], - }, + + install_requires=[ + 'Python >= 2.5', + 'Numpy >= 1.6', + 'Cython >= 0.15', + 'SciPy >= 0.10', + ], + + extras_require={ + 'Viewer': ['PyQt', 'matplotlib'], + 'Tests': ['nose'], + }, + packages=setuptools.find_packages(), include_package_data=True, zip_safe=False, # the package can run out of an .egg file entry_points={ - 'console_scripts': [ - 'skivi = skimage.scripts.skivi:main'] - }, + 'console_scripts': ['skivi = skimage.scripts.skivi:main'], + }, cmdclass={'build_py': build_py}, ) From f2a256ec9b983218b8eefc682b87db99bb977cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 9 Sep 2012 19:35:39 +0200 Subject: [PATCH 3/3] Implement own dependency checking before installation --- setup.py | 60 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index 48ea48a8..396d8429 100644 --- a/setup.py +++ b/setup.py @@ -18,8 +18,16 @@ URL = 'http://scikits-image.org' LICENSE = 'Modified BSD' DOWNLOAD_URL = 'http://github.com/scikits-image/scikits-image' VERSION = '0.7dev' +PYTHON_VERSION = (2, 5) +DEPENDENCIES = { + 'numpy': (1, 6), + 'scipy': (0, 10), + 'Cython': (0, 15), + } + import os +import sys import setuptools from numpy.distutils.core import setup try: @@ -60,7 +68,45 @@ version='%s' vfile.close() +def get_package_version(package): + version = [] + for version_attr in ('version', 'VERSION', '__version__'): + if hasattr(package, version_attr) \ + and isinstance(getattr(package, version_attr), str): + version_info = getattr(package, version_attr) + for part in version_info.split('.'): + try: + version.append(int(part)) + except ValueError: + pass + return tuple(version) + + +def check_requirements(): + if sys.version_info < PYTHON_VERSION: + raise SystemExit('You need Python version %d.%d or later.' \ + % PYTHON_VERSION) + + for package_name, min_version in DEPENDENCIES.items(): + dep_error = False + try: + package = __import__(package_name) + except ImportError: + dep_error = True + else: + package_version = get_package_version(package) + if min_version > package_version: + dep_error = True + + if dep_error: + raise ImportError('You need `%s` version %d.%d or later.' \ + % ((package_name, ) + min_version)) + + if __name__ == "__main__": + + check_requirements() + write_version_py() setup( @@ -92,18 +138,6 @@ if __name__ == "__main__": configuration=configuration, - install_requires=[ - 'Python >= 2.5', - 'Numpy >= 1.6', - 'Cython >= 0.15', - 'SciPy >= 0.10', - ], - - extras_require={ - 'Viewer': ['PyQt', 'matplotlib'], - 'Tests': ['nose'], - }, - packages=setuptools.find_packages(), include_package_data=True, zip_safe=False, # the package can run out of an .egg file @@ -113,4 +147,4 @@ if __name__ == "__main__": }, cmdclass={'build_py': build_py}, - ) + )