Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@jefftriplett
Copy link

jefftriplett commented Nov 26, 2021

Feature request: Please add test => pytest and tox or nox please. Gotta be feature/requirements-level complete. 😄

@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

jefftriplett commented Jan 16, 2022

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