Skip to content

Instantly share code, notes, and snippets.

@brettcannon
Created November 26, 2021 22:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettcannon/5d954881bf4b0a396180c38f3a3ff85e to your computer and use it in GitHub Desktop.
Save brettcannon/5d954881bf4b0a396180c38f3a3ff85e to your computer and use it in GitHub Desktop.
Make Jeff feel better about Python packaging
"""Back in my day, we only needed **one** command. 🧓"""
import runpy
import sys
def run(command):
sys.argv[0] = command
runpy.run_module(command, run_name="__main__")
command = sys.argv[1]
args = sys.argv[2:]
match command:
case "sdist" | "bdist_wheel":
del sys.argv[1]
run("build")
case "install":
run("pip")
case "develop":
sys.argv[1] = "install"
sys.argv.insert(2, "-e")
run("pip)")
case "upload":
run("twine")
case "check":
run("twine")
case _:
raise ValueError(f"{command!r} is not a recognized command")
build
twine
pip
@merwok
Copy link

merwok commented Jan 15, 2022

Python packaging now focuses on building, distributing, downloading and installing code.
Running commands for other parts of development workflow like test, lint, etc is not in scope.

(And really, what is the need to add a passthrough test command when tox/nox are the mostly universal test runners nowadays?)

@jefftriplett
Copy link

The comment was an inside joke like the point of the gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment