|
1 | | -from setuptools import setup, find_packages |
| 1 | +import sys |
| 2 | +from pathlib import Path |
| 3 | + |
| 4 | +from setuptools import find_packages, setup |
| 5 | + |
| 6 | +CURRENT_DIRECTORY = Path(__file__).parent.absolute() |
| 7 | +CURRENT_PYTHON = sys.version_info[:2] |
| 8 | +REQUIRED_PYTHON = (3, 8) |
| 9 | +VER_ERR_MSG = """ |
| 10 | +========================== |
| 11 | +Unsupported Python version |
| 12 | +========================== |
| 13 | +This version of ibllib requires Python {}.{}, but you're trying to install it on Python {}.{}. |
| 14 | +""" |
| 15 | +if CURRENT_PYTHON < REQUIRED_PYTHON: |
| 16 | + sys.stderr.write(VER_ERR_MSG.format(*REQUIRED_PYTHON + CURRENT_PYTHON)) |
| 17 | + sys.exit(1) |
| 18 | + |
| 19 | +with open("README.md", "r") as f: |
| 20 | + long_description = f.read() |
| 21 | + |
| 22 | +with open("requirements.txt") as f: |
| 23 | + require = [x.strip() for x in f.readlines() if not x.startswith("git+")] |
| 24 | + |
| 25 | + |
| 26 | +def read(rel_path): |
| 27 | + here = Path(__file__).parent.absolute() |
| 28 | + with open(here.joinpath(rel_path), "r") as fp: |
| 29 | + return fp.read() |
| 30 | + |
| 31 | + |
| 32 | +def get_version(rel_path): |
| 33 | + for line in read(rel_path).splitlines(): |
| 34 | + if line.startswith("__version__"): |
| 35 | + delim = '"' if '"' in line else "'" |
| 36 | + return line.split(delim)[1] |
| 37 | + else: |
| 38 | + raise RuntimeError("Unable to find version string.") |
2 | 39 |
|
3 | | -with open('requirements.txt') as f: |
4 | | - require = [x.strip() for x in f.readlines() if not x.startswith('git+')] |
5 | 40 |
|
6 | 41 | setup( |
7 | | - name='iblapps', |
8 | | - version='0.1', |
9 | | - packages=find_packages(), |
| 42 | + name="iblapps", |
| 43 | + version=get_version("__init__.py"), |
| 44 | + python_requires=">={}.{}".format(*REQUIRED_PYTHON), |
| 45 | + description="IBL Applications", |
| 46 | + license="MIT", |
| 47 | + long_description=long_description, |
| 48 | + long_description_content_type="text/markdown", |
| 49 | + author="IBL Staff", |
| 50 | + url="https://www.internationalbrainlab.com/", |
| 51 | + packages=find_packages(exclude=["scratch"]), # same as name |
10 | 52 | include_package_data=True, |
11 | | - install_requires=require |
| 53 | + # external packages as dependencies |
| 54 | + install_requires=require, |
| 55 | + scripts=[], |
12 | 56 | ) |
0 commit comments