Skip to content

Commit

Permalink
Sandbox: Bring back python setup.py publish subcommand
Browse files Browse the repository at this point in the history
It has been removed too early.
  • Loading branch information
amotl authored and kennethreitz committed Oct 26, 2024
1 parent 68bbea0 commit 4ff73e9
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
with open(os.path.join(here, "responder", "__version__.py")) as f:
exec(f.read(), about)

if sys.argv[-1] == "publish":
os.system("python setup.py sdist bdist_wheel upload")
sys.exit()

required = [
"aiofiles",
"apispec>=1.0.0b1",
Expand Down Expand Up @@ -64,6 +68,39 @@ def run(self):
os.system("dpkg-buildpackage -rfakeroot -uc -us")


class UploadCommand(Command):
"""Support setup.py publish."""

description = "Build and publish the package."
user_options = []

@staticmethod
def status(s):
"""Prints things in bold."""
print("\033[1m{0}\033[0m".format(s))

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
try:
self.status("Removing previous builds…")
rmtree(os.path.join(here, "dist"))
except FileNotFoundError:
pass
self.status("Building Source distribution…")
os.system("{0} setup.py sdist bdist_wheel".format(sys.executable))
self.status("Uploading the package to PyPI via Twine…")
os.system("twine upload dist/*")
self.status("Pushing git tags…")
os.system("git tag v{0}".format(about["__version__"]))
os.system("git push --tags")
sys.exit()


setup(
name="responder",
version=about["__version__"],
Expand Down Expand Up @@ -111,5 +148,5 @@ def run(self):
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet :: WWW/HTTP",
],
cmdclass={"deb": DebCommand},
cmdclass={"upload": UploadCommand, "deb": DebCommand},
)

0 comments on commit 4ff73e9

Please sign in to comment.