-
Notifications
You must be signed in to change notification settings - Fork 77
/
setup.py
134 lines (115 loc) · 4.16 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import os
import shutil
import sys
import re
import subprocess
from setuptools import setup, find_packages, Command
VERSION = ""
with open("nylas/_client_sdk_version.py", "r") as fd:
VERSION = re.search(
r'^__VERSION__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE
).group(1)
with open("README.md", "r", encoding="utf-8") as f:
README = f.read()
RUN_DEPENDENCIES = [
"requests[security]>=2.31.0",
"requests-toolbelt>=1.0.0",
"dataclasses-json>=0.5.9",
"typing_extensions>=4.7.1",
]
TEST_DEPENDENCIES = ["pytest>=7.4.0", "pytest-cov>=4.1.0", "setuptools>=69.0.3"]
DOCS_DEPENDENCIES = [
"mkdocs>=1.5.2",
"mkdocstrings[python]>=0.22.0",
"mkdocs-material>=9.2.6",
"mkdocs-gen-files>=0.5.0",
"mkdocs-literate-nav>=0.6.0",
]
RELEASE_DEPENDENCIES = ["bumpversion>=0.6.0", "twine>=4.0.2"]
class PyTest(Command):
user_options = [("pytest-args=", "a", "Arguments to pass to pytest")]
def initialize_options(self):
# pylint: disable=attribute-defined-outside-init
self.pytest_args = [
"--cov",
"--cov-report=xml",
"--junitxml",
"./tests/output",
"tests/",
]
self.lint = False
def finalize_options(self):
# pylint: disable=attribute-defined-outside-init
self.test_args = []
self.test_suite = True
def run(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
def main():
# A few handy release helpers.
# For publishing you should install the extra 'release' dependencies
# by running: pip install nylas['release']
if len(sys.argv) > 1:
if sys.argv[1] == "publish":
try:
subprocess.check_output(["git", "push", "--follow-tags"])
subprocess.check_output(["python", "setup.py", "sdist"])
subprocess.check_output(["twine", "upload", "-r", "testpypi", "dist/*"])
subprocess.check_output(["twine", "upload", "dist/*"])
except FileNotFoundError as e:
print("Error encountered: {}.\n\n".format(e))
sys.exit()
elif sys.argv[1] == "build-docs":
if not os.path.exists("docs"):
os.makedirs("docs")
try:
# Copy the README and other markdowns to the docs folder
shutil.copy("README.md", "docs/index.md")
shutil.copy("Contributing.md", "docs/contributing.md")
shutil.copy("LICENSE", "docs/license.md")
subprocess.check_output(["mkdocs", "build"])
except FileNotFoundError as e:
print("Error encountered: {}.\n\n".format(e))
sys.exit()
elif sys.argv[1] == "release":
if len(sys.argv) < 3:
type_ = "patch"
else:
type_ = sys.argv[2]
try:
subprocess.check_output(
["bumpversion", "--current-version", VERSION, type_]
)
except FileNotFoundError as e:
print(
"Error encountered: {}.\n\n".format(e),
"Did you install the extra 'release' dependencies? (pip install nylas['release'])",
)
sys.exit()
setup(
name="nylas",
version=VERSION,
python_requires=">=3.8",
packages=find_packages(),
install_requires=RUN_DEPENDENCIES,
dependency_links=[],
tests_require=TEST_DEPENDENCIES,
extras_require={
"test": TEST_DEPENDENCIES,
"docs": DOCS_DEPENDENCIES,
"release": RELEASE_DEPENDENCIES,
},
cmdclass={"test": PyTest},
author="Nylas Team",
author_email="[email protected]",
description="Python bindings for the Nylas API platform.",
license="MIT",
keywords="inbox app appserver email nylas contacts calendar",
url="https://github.com/nylas/nylas-python",
long_description_content_type="text/markdown",
long_description=README,
)
if __name__ == "__main__":
main()