|
2 | 2 | import codecs |
3 | 3 | import os |
4 | 4 |
|
5 | | -setup( |
6 | | - # Application name: |
7 | | - name="singularity", |
| 5 | +########################################################################################## |
| 6 | +# HELPER FUNCTIONS ####################################################################### |
| 7 | +########################################################################################## |
8 | 8 |
|
9 | | - # Version number: |
10 | | - version="0.91", |
| 9 | +def get_lookup(): |
| 10 | + '''get version by way of singularity.version, returns a |
| 11 | + lookup dictionary with several global variables without |
| 12 | + needing to import singularity |
| 13 | + ''' |
| 14 | + lookup = dict() |
| 15 | + version_file = os.path.join('singularity', 'version.py') |
| 16 | + with open(version_file) as filey: |
| 17 | + exec(filey.read(), lookup) |
| 18 | + return lookup |
11 | 19 |
|
12 | | - # Application author details: |
13 | | - author="Vanessa Sochat", |
14 | | - |
| 20 | +# Read in requirements |
| 21 | +def get_requirements(lookup=None): |
| 22 | + '''get_requirements reads in requirements and versions from |
| 23 | + the lookup obtained with get_lookup''' |
15 | 24 |
|
16 | | - # Packages |
17 | | - packages=find_packages(), |
18 | | - |
19 | | - # Data files |
20 | | - include_package_data=True, |
21 | | - zip_safe=False, |
| 25 | + if lookup == None: |
| 26 | + lookup = get_lookup() |
22 | 27 |
|
23 | | - # Details |
24 | | - url="http://www.github.com/singularityware/singularity-python", |
| 28 | + install_requires = [] |
| 29 | + for module in lookup['INSTALL_REQUIRES']: |
| 30 | + module_name = module[0] |
| 31 | + module_meta = module[1] |
| 32 | + if "exact_version" in module_meta: |
| 33 | + dependency = "%s==%s" %(module_name,module_meta['exact_version']) |
| 34 | + elif "min_version" in module_meta: |
| 35 | + if module_meta['min_version'] == None: |
| 36 | + dependency = module_name |
| 37 | + else: |
| 38 | + dependency = "%s>=%s" %(module_name,module_meta['min_version']) |
| 39 | + install_requires.append(dependency) |
| 40 | + return install_requires |
25 | 41 |
|
26 | | - license="LICENSE", |
27 | | - description="Command line tool for working with singularity-hub and packaging singularity containers.", |
28 | | - keywords='singularity containers hub reproducibility package science', |
29 | 42 |
|
30 | | - install_requires = ['Flask','flask-restful','selenium','simplejson','scikit-learn','pygments', |
31 | | - 'requests','oauth2client','google-api-python-client','pandas'], |
32 | 43 |
|
33 | | - entry_points = { |
34 | | - 'console_scripts': [ |
35 | | - 'shub=singularity.scripts:main', |
36 | | - ], |
37 | | - }, |
| 44 | +# Make sure everything is relative to setup.py |
| 45 | +install_path = os.path.dirname(os.path.abspath(__file__)) |
| 46 | +os.chdir(install_path) |
38 | 47 |
|
39 | | -) |
| 48 | +# Get version information from the lookup |
| 49 | +lookup = get_lookup() |
| 50 | +VERSION = lookup['__version__'] |
| 51 | +NAME = lookup['NAME'] |
| 52 | +AUTHOR = lookup['AUTHOR'] |
| 53 | +AUTHOR_EMAIL = lookup['AUTHOR_EMAIL'] |
| 54 | +PACKAGE_URL = lookup['PACKAGE_URL'] |
| 55 | +KEYWORDS = lookup['KEYWORDS'] |
| 56 | +DESCRIPTION = lookup['DESCRIPTION'] |
| 57 | +LICENSE = lookup['LICENSE'] |
| 58 | +with open('README.md') as filey: |
| 59 | + LONG_DESCRIPTION = filey.read() |
| 60 | + |
| 61 | +########################################################################################## |
| 62 | +# MAIN ################################################################################### |
| 63 | +########################################################################################## |
| 64 | + |
| 65 | + |
| 66 | +if __name__ == "__main__": |
| 67 | + |
| 68 | + INSTALL_REQUIRES = get_requirements(lookup) |
| 69 | + |
| 70 | + setup(name=NAME, |
| 71 | + version=VERSION, |
| 72 | + author=AUTHOR, |
| 73 | + author_email=AUTHOR_EMAIL, |
| 74 | + maintainer=AUTHOR, |
| 75 | + maintainer_email=AUTHOR_EMAIL, |
| 76 | + packages=find_packages(), |
| 77 | + include_package_data=True, |
| 78 | + zip_safe=False, |
| 79 | + url=PACKAGE_URL, |
| 80 | + license=LICENSE, |
| 81 | + description=DESCRIPTION, |
| 82 | + long_description=LONG_DESCRIPTION, |
| 83 | + keywords=KEYWORDS, |
| 84 | + install_requires = INSTALL_REQUIRES, |
| 85 | + classifiers=[ |
| 86 | + 'Intended Audience :: Science/Research', |
| 87 | + 'Intended Audience :: Developers', |
| 88 | + 'License :: OSI Approved :: MIT License', |
| 89 | + 'Programming Language :: C', |
| 90 | + 'Programming Language :: Python', |
| 91 | + 'Topic :: Software Development', |
| 92 | + 'Topic :: Scientific/Engineering', |
| 93 | + 'Operating System :: Unix', |
| 94 | + 'Programming Language :: Python :: 2.7', |
| 95 | + 'Programming Language :: Python :: 3', |
| 96 | + ], |
| 97 | + entry_points = {'console_scripts': [ 'shub=singularity.scripts:main' ] }) |
0 commit comments