forked from taverntesting/tavern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
79 lines (57 loc) · 1.83 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
#!/usr/bin/env python
import os
from subprocess import check_call
from distutils.core import Command
from setuptools import setup
class BuildDocs(Command):
description = "Build documentation html"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.execute(check_call,
[["sphinx-apidoc", "tavern", "-o", "docs"]],
msg="Generating rst for tavern")
self.execute(check_call,
[["make", "-C", "docs", "html"]],
msg="Making html docs")
class DeployPypi(Command):
description = "Deploy to pypi using twine"
user_options = [
("repository=", "r", "Repository to upload to"),
]
def initialize_options(self):
self.repository = None # pylint: disable=attribute-defined-outside-init
def finalize_options(self):
if not self.repository:
raise RuntimeError("Need a repository to upload to! Run 'python setup.py upload_twine' for options.")
def run(self):
self.run_command("clean")
self.run_command("sdist")
if len(os.listdir("dist")) > 1:
raise RuntimeError("More than one package in dist/ - only one can be present to upload! Delete the dist/ folder before running this command.")
to_upload = os.path.join("dist", os.listdir("dist")[0])
args = ["twine", "upload", "-r", self.repository, to_upload]
self.execute(check_call,
[args],
msg="Uploading package to pypi")
TESTS_REQUIRE = [
"pytest-cov",
"colorlog",
"mock",
"faker"
]
setup(
name="tavern",
cmdclass={
"docs": BuildDocs,
"upload_twine": DeployPypi,
},
tests_require=TESTS_REQUIRE,
extras_require={
"tests": TESTS_REQUIRE
},
zip_safe=True
)