-
Notifications
You must be signed in to change notification settings - Fork 26
/
setup.py
52 lines (41 loc) · 1.28 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
# -*- coding:utf-8 -*-
from setuptools import setup
import subprocess
def parse_requirements(filename):
with open(filename) as f:
lines = f.read().splitlines()
requires = []
for line in lines:
if "http" in line:
pkg_name_with_version = line.split("/")[-1].split("-")[0]
requires.append(pkg_name_with_version)
else:
requires.append(line)
return requires
def get_version():
command = ["git", "describe", "--tags"]
try:
version = subprocess.check_output(command).decode().strip()
version_parts = version.split("-")
if len(version_parts) > 1 and version_parts[0].startswith(
"magic_html"
):
return version_parts[1]
else:
raise ValueError(
f"Invalid version tag {version}. Expected format is magic_html-<version>-released."
)
except Exception as e:
print(e)
return "0.0.0"
requires = parse_requirements("requirements.txt")
setup(
name="magic_html",
version=get_version(),
packages=["magic_html", "magic_html.extractors"],
package_data={"magic_html": ["mmltex/*.xsl"]},
install_requires=requires,
python_requires=">=3.8",
zip_safe=False,
)
# python setup.py bdist_wheel