-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
62 lines (46 loc) · 1.75 KB
/
setup.py
File metadata and controls
62 lines (46 loc) · 1.75 KB
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
import setuptools
import re
with open("docs/requirements.txt", "r") as stream:
extras_require_docs = stream.read().splitlines()
# with open("test/requirements.txt", "r") as stream:
# extras_require_test = stream.read().splitlines()
extras_require = {
"docs": extras_require_docs,
# "test": extras_require_test, # TODO: graphql[test]
}
with open("requirements.txt", "r") as stream:
install_requires = stream.read().splitlines()
packages = setuptools.find_packages()
_version_regex = r"^version(?:\s*:\s*str)?\s*=\s*('|\")((?:[0-9]+\.)*[0-9]+(?:\.?([a-z]+)(?:\.?[0-9])?)?)\1$"
with open("graphql/__init__.py") as stream:
match = re.search(_version_regex, stream.read(), re.MULTILINE)
if not match:
raise RuntimeError("could not find version")
version = match.group(2)
if match.group(3) is not None:
try:
import subprocess
process = subprocess.Popen(["git", "rev-list", "--count", "HEAD"], stdout=subprocess.PIPE)
out, _ = process.communicate()
if out:
version += out.decode("utf-8").strip()
process = subprocess.Popen(["git", "rev-parse", "--short", "HEAD"], stdout=subprocess.PIPE)
out, _ = process.communicate()
if out:
version += "+g" + out.decode("utf-8").strip()
except (Exception) as e:
pass
setuptools.setup(
author="ShineyDev",
author_email="contact@shiney.dev",
description="An asynchronous Python library for interaction with GraphQL APIs.",
extras_require=extras_require,
include_package_data=True,
install_requires=install_requires,
license="Apache Software License",
name="graphql",
packages=packages,
python_requires=">=3.8.0",
url="https://github.com/ShineyDev/graphql",
version=version,
)