forked from terrier-org/pyterrier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
75 lines (66 loc) · 2.64 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
67
68
69
70
71
72
73
74
75
import sys
assert sys.version_info[0] > 2, "PyTerrier requires Python 3.7 minimum"
import os
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
def find_packages(where='.'):
# os.walk -> list[(dirname, list[subdirs], list[files])]
return [folder.replace("/", ".").lstrip(".")
for (folder, _, fils) in os.walk(where)
if "__init__.py" in fils]
with open("README.md", "r") as fh:
long_description = fh.read()
# see https://packaging.python.org/guides/single-sourcing-package-version/
import codecs
import os.path
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()
def get_version(rel_path):
import os
suffix = os.environ["PYTERRIER_VERSION_SUFFIX" ] if "PYTERRIER_VERSION_SUFFIX" in os.environ else ""
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1] + suffix
else:
raise RuntimeError("Unable to find version string.")
requirements = []
with open('requirements.txt', 'rt') as f:
for req in f.read().splitlines():
if req.startswith('git+'):
pkg_name = req.split('/')[-1].replace('.git', '')
if "#egg=" in pkg_name:
pkg_name = pkg_name.split("#egg=")[1]
requirements.append("%s @ %s" % (pkg_name, req))
else:
requirements.append(req)
setup(
name="python-terrier",
version=get_version("pyterrier/__init__.py"),
author="Craig Macdonald",
author_email='[email protected]',
description="Terrier IR platform Python API",
project_urls={
'Documentation': 'https://pyterrier.readthedocs.io',
'Changelog': 'https://github.com/terrier-org/pyterrier/releases',
'Issue Tracker': 'https://github.com/terrier-org/pyterrier/issues',
'CI': 'https://github.com/terrier-org/pyterrier/actions',
},
long_description=long_description,
long_description_content_type="text/markdown",
package_data={'': ['LICENSE.txt', 'requirements.txt', 'requirements-test.txt']},
include_package_data=True,
url="https://github.com/terrier-org/pyterrier",
packages=['pyterrier'] + ['pyterrier.' + i for i in find_packages('pyterrier')],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Operating System :: OS Independent",
],
install_requires=requirements,
python_requires='>=3.7',
)