|
1 | | -#!/usr/bin/env python3 |
2 | | -from setuptools import setup |
3 | | -import os |
4 | | - |
5 | | - |
6 | | -# We store our version number in a simple text file: |
7 | | -version_path = os.path.join(os.path.dirname(__file__), "uparma", "version.txt") |
8 | | - |
9 | | -with open(version_path, "r") as version_file: |
10 | | - uparma_py_version = version_file.read().strip() |
11 | | - |
12 | | -with open("requirements.txt") as req_file: |
13 | | - reqs = req_file.readlines() |
14 | | - |
15 | | - |
16 | | -setup( |
17 | | - name="uparma", |
18 | | - version=uparma_py_version, |
19 | | - packages=["uparma"], |
20 | | - package_dir={"uparma": "uparma"}, |
21 | | - description="uparma", |
22 | | - package_data={ |
23 | | - "uparma": [ |
24 | | - "version.txt", |
25 | | - "lib_version.txt", |
26 | | - ] |
27 | | - }, |
28 | | - install_requires=reqs, |
29 | | - long_description="Universal Parameter Mapper for Proteomics tools", |
30 | | - author="... and Christian Fufezan", |
31 | | - author_email="christian@fufezan.net", |
32 | | - url="http://github.com/uparma/uparma-py", |
33 | | - license="Lesser GNU General Public License (LGPL)", |
34 | | - platforms="any that supports python 3.4", |
35 | | - classifiers=[ |
36 | | - "Development Status :: 4 - Beta", |
37 | | - "Environment :: Console", |
38 | | - "Intended Audience :: Science/Research", |
39 | | - "Intended Audience :: Developers", |
40 | | - "Operating System :: MacOS :: MacOS X", |
41 | | - "Operating System :: Microsoft :: Windows", |
42 | | - "Operating System :: POSIX", |
43 | | - "Operating System :: POSIX :: SunOS/Solaris", |
44 | | - "Operating System :: Unix", |
45 | | - "Programming Language :: Python :: 3", |
46 | | - "Programming Language :: Python :: 3.4", |
47 | | - "Topic :: Scientific/Engineering :: Bio-Informatics", |
48 | | - "Topic :: Scientific/Engineering :: Chemistry", |
49 | | - "Topic :: Scientific/Engineering :: Medical Science Apps.", |
50 | | - "Topic :: Software Development :: Libraries :: Python Modules", |
51 | | - ], |
| 1 | +import setuptools |
| 2 | + |
| 3 | + |
| 4 | +def branch_dependent_version(): |
| 5 | + import setuptools_scm |
| 6 | + |
| 7 | + def void(version): |
| 8 | + return "" |
| 9 | + |
| 10 | + def version_scheme(version): |
| 11 | + if version.branch not in ["main", "master"]: |
| 12 | + _v = setuptools_scm.get_version(local_scheme=void) |
| 13 | + else: |
| 14 | + _v = str(version.tag) |
| 15 | + return _v |
| 16 | + |
| 17 | + def local_scheme(version): |
| 18 | + if version.branch not in ["main", "master"]: |
| 19 | + _v = setuptools_scm.get_version(version_scheme=void) |
| 20 | + else: |
| 21 | + _v = "" |
| 22 | + return _v |
| 23 | + |
| 24 | + scm_version = { |
| 25 | + "root": ".", |
| 26 | + "relative_to": __file__, |
| 27 | + "version_scheme": version_scheme, |
| 28 | + "local_scheme": local_scheme |
| 29 | + # >> "no-local-version" not quit good enough |
| 30 | + # >> on dev "node-and-timestamp", # version_scheme, |
| 31 | + } |
| 32 | + return scm_version |
| 33 | + |
| 34 | + |
| 35 | +setuptools.setup( |
| 36 | + use_scm_version=branch_dependent_version, |
| 37 | + setup_requires=["setuptools_scm"], |
52 | 38 | ) |
0 commit comments