Skip to content

Commit 4ff73e9

Browse files
amotlkennethreitz
authored andcommitted
Sandbox: Bring back python setup.py publish subcommand
It has been removed too early.
1 parent 68bbea0 commit 4ff73e9

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

setup.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
with open(os.path.join(here, "responder", "__version__.py")) as f:
1818
exec(f.read(), about)
1919

20+
if sys.argv[-1] == "publish":
21+
os.system("python setup.py sdist bdist_wheel upload")
22+
sys.exit()
23+
2024
required = [
2125
"aiofiles",
2226
"apispec>=1.0.0b1",
@@ -64,6 +68,39 @@ def run(self):
6468
os.system("dpkg-buildpackage -rfakeroot -uc -us")
6569

6670

71+
class UploadCommand(Command):
72+
"""Support setup.py publish."""
73+
74+
description = "Build and publish the package."
75+
user_options = []
76+
77+
@staticmethod
78+
def status(s):
79+
"""Prints things in bold."""
80+
print("\033[1m{0}\033[0m".format(s))
81+
82+
def initialize_options(self):
83+
pass
84+
85+
def finalize_options(self):
86+
pass
87+
88+
def run(self):
89+
try:
90+
self.status("Removing previous builds…")
91+
rmtree(os.path.join(here, "dist"))
92+
except FileNotFoundError:
93+
pass
94+
self.status("Building Source distribution…")
95+
os.system("{0} setup.py sdist bdist_wheel".format(sys.executable))
96+
self.status("Uploading the package to PyPI via Twine…")
97+
os.system("twine upload dist/*")
98+
self.status("Pushing git tags…")
99+
os.system("git tag v{0}".format(about["__version__"]))
100+
os.system("git push --tags")
101+
sys.exit()
102+
103+
67104
setup(
68105
name="responder",
69106
version=about["__version__"],
@@ -111,5 +148,5 @@ def run(self):
111148
"Programming Language :: Python :: Implementation :: PyPy",
112149
"Topic :: Internet :: WWW/HTTP",
113150
],
114-
cmdclass={"deb": DebCommand},
151+
cmdclass={"upload": UploadCommand, "deb": DebCommand},
115152
)

0 commit comments

Comments
 (0)