-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
66 lines (58 loc) · 2.7 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from setuptools import setup
from os import path
# how to upload to PyPI:
# https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56
# briefly, first
# 1. install twice (pip install twine),
# 2. pip install importlib-metadata==4.13.0 (to avoid error
# "AttributeError: 'EntryPoints' object has no attribute 'get'" with versions after 5.0)
#
# Then to upload to PyPI:
# 1. [bump version number in file gpac/__version__.py]
# 2. python setup.py sdist
# 3. twine upload dist/*
# this is ugly, but appears to be standard practice:
# https://stackoverflow.com/questions/17583443/what-is-the-correct-way-to-share-package-version-with-setup-py-and-the-package/17626524#17626524
def extract_version(filename: str):
with open(filename) as f:
lines = f.readlines()
version_comment = '# version line; WARNING: do not remove or change this line or comment'
for line in lines:
if version_comment in line:
idx = line.index(version_comment)
line_prefix = line[:idx]
parts = line_prefix.split('=')
parts = [part.strip() for part in parts]
version_str = parts[-1]
version_str = version_str.replace('"', '')
version_str = version_str.replace("'", '')
version_str = version_str.strip()
return version_str
raise AssertionError(f'could not find version in {filename}')
package_name = 'gpac'
version = extract_version(f'{package_name}/__version__.py')
print(f'{package_name} version = {version}')
with open("requirements.txt") as fp:
install_requires = fp.read().strip().split("\n")
# read the contents of your README file
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(name=package_name,
packages=[package_name],
version=version,
license='MIT',
description=f"{package_name} stands for \"General-Purpose Analog Computer\". "
f"This package makes it easy to specify ordinary differential equations (ODEs) "
f"and plot their solutions. "
f"It also contains functions for specifying chemical reaction networks (CRNs) "
f"and simulating their behavior.",
author="David Doty",
author_email="[email protected]",
url=f"https://github.com/UC-Davis-molecular-computing/{package_name}",
long_description=long_description,
long_description_content_type='text/markdown; variant=GFM',
python_requires='>=3.7',
install_requires=install_requires,
include_package_data=True,
)