-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
executable file
·109 lines (89 loc) · 3.49 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python3
import sys
import re
import time
from setuptools import setup, find_packages
import distutils.cmd
from distutils.command.clean import clean as clean_orig
import urllib.request
import shutil
import os
import os.path
# Package meta-data
VERSION = '3.1.1'
CORE_VERSION = '3.1.1' # graphANNIS core library version
CORE_FILES = {
'linux-x86-64/libgraphannis.so': '/~https://github.com/korpling/graphANNIS/releases/download/v' +
CORE_VERSION + '/libgraphannis.so',
'win32-x86-64/graphannis.dll': '/~https://github.com/korpling/graphANNIS/releases/download/v' +
CORE_VERSION + '/graphannis.dll',
'darwin-x86-64/libgraphannis.dylib': '/~https://github.com/korpling/graphANNIS/releases/download/v' +
CORE_VERSION + '/libgraphannis.dylib'
}
def replace_in_file(file, replacements):
if len(replacements) == 0:
return
content = None
with open(file, "r") as f_in:
content = f_in.read()
if content:
for pattern, repl in replacements.items():
content = re.sub(pattern, repl, content)
with open(file, "w") as f_out:
f_out.write(content)
# Update version information in README.md
replace_in_file("README.md", {
'graphANNIS core library version ([0-9]+\.[0-9]+\.[0-9]+)': 'graphANNIS core library version ' + CORE_VERSION})
replace_in_file("README_pypi.md", {
'graphANNIS core library version ([0-9]+\.[0-9]+\.[0-9]+)': 'graphANNIS core library version ' + CORE_VERSION})
with open('README_pypi.md') as f:
long_description = f.read()
if not "clean" in sys.argv:
for file, url in CORE_FILES.items():
file = os.path.join('graphannis', file)
if not os.path.isfile(file):
print("Downloading " + url)
with urllib.request.urlopen(url) as response, open(file, 'wb') as out_file:
shutil.copyfileobj(response, out_file)
class clean(clean_orig):
def run(self):
for file, _ in CORE_FILES.items():
file = os.path.join("graphannis", file)
if os.path.isfile(file):
print(file)
os.remove(file)
super().run()
class update_changelog(distutils.cmd.Command):
description = 'Update changelog to release the current version number'
user_options = []
def run(self):
version_header = '## [{}] - {} '.format(
VERSION, time.strftime("%Y-%m-%d"))
replace_in_file('CHANGELOG.md', {
'## \[Unreleased\]': '## [Unreleased]\n\n' + version_header})
def initialize_options(self):
pass
def finalize_options(self):
pass
setup(name='graphannis',
version=VERSION,
description='graphANNIS Python API',
author='Thomas Krause',
author_email='thomaskrause@posteo.de',
url='/~https://github.com/korpling/graphANNIS-python/',
long_description=long_description,
long_description_content_type='text/markdown',
packages=['graphannis'],
include_package_data=True,
setup_requires=["cffi>=1.0.0"],
cffi_modules=["package/graphannis_build.py:ffibuilder"],
install_requires=["cffi>=1.0.0", "networkx"],
classifiers=[
"Programming Language :: Python :: 3.6",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows"
],
cmdclass={"clean": clean, "update_changelog": update_changelog}
)