Most of you are probably aware that there’s a lot of packaging discussions going on around tooling and interfaces. A very common expectation/assumption/hope from users is to merge all the functionality into a single tool.
I’m not proposing that (yet), so keep reading before you react
Most importantly to this topic, such a tool would likely have some kind of run
command to launch Python. For example conda
recently added a conda run <command>
command that allows them to set up various state before launching the real command (typically, though not exclusively, Python).
If such a tool became wildly popular, or even integrated into our standard distributions, it would likely replace the direct use of python
/python3[.Y]
by users, and we’d be getting into a vastly more confusing state of commands than we already have. I’d like to avoid that.[1]
Top candidates for tools right now seem to be hatch
(which already has the functionality) and py
(which already has the reach, and is under core-ish control). But I foresee one big compatibility risk that I think we can start dealing with now to make a potential future smoother.
Extensionless script files “look” like subcommands. Which means someone can today create a run
file and then python run <args>
. I have no idea how widespread this is, but I think the possibility would prevent us from ever adding subcommands to the main entry point. py run <args>
would behave exactly the same, which would also prevent us from adding subcommands.
I know we can bikeshed endless alternatives (“hey first time terminal user, just type py --command=RUN <args>
instead” ), but the reality is virtually every other tool like this and virtually every mock up that people create for us uses plain subcommands. I’ve already had to explain to people that we couldn’t possibly have
python install <package>
because someone somewhere might have called their script install
on purpose. That doesn’t land well, because it seems intuitively wrong to the listener, and it’s only going to get harder.
So, the idea/proposal: deprecate and warn when the script file argument provided on the command line does not contain any slashes or dots. Slashes and dots either indicate a file extension, so anything.py
doesn’t get a warning, or a relative/absolute path, so ./script
is also okay. I don’t want to predict which specific subcommands would be important to preserve, because there’s a 100% chance of being wrong, but I think it’s safer and easier to explain that the script file needs to have an extension or a path, rather than just a name.
There’s no need to set an end date, and it can remain deprecated but still working forever if we never come up with a use for actual subcommands, but if we deprecate now then by the time we want to use them we’ll be able to do it.
Again, the premise here is that eventually users will demand subcommands, and that we want them to be able to keep running python
or py
[2] rather than some completely different tool, for the sake of the existing knowledge and material.
What do people think?
Aside: PEP 582 was my proposal to let us get the most important part of this functionality without needing a new command or necessarily breaking existing commands. ↩︎
I think it’s fairly obvious that
py
shouldn’t be radically more restrictive thanpython
here, but happy to spell out why in more detail if that’s contested. ↩︎