In-built Python Version Manager (PVM) and Package Manager

Description:

Please consider adding an in-built Python Version Manager (PVM) similar to existing tools like fnm (Fast Node Manager. The PVM should offer the following subcommands:

  • pvm list or pvm ls: Lists all locally installed Python versions.
  • pvm list-remote or pvm ls-remote: Lists all available Python versions for download, including alpha and beta versions.
  • pvm install <version>: Installs the specified Python version.
  • pvm use <version>: Sets a specific Python version for the current session.
  • pvm default <version>: Sets a default Python version globally.
  • pvm current: Displays the currently active Python version.
  • pvm uninstall <version>: Uninstalls the specified Python version.
  • pvm help: Displays help information for PVM commands.

Additionally, consider adding a Python package manager similar to Node’s package.json system. Python could have a command like pip init or pip init -y to initialize a new project with package dependencies.

Additional Features:

  • Hot Reloading & Watch Mode:
    • Add support for py --hot main.py to provide hot-reloading of the Python script.
    • Add py --watch main.py to watch for file changes and automatically restart the script.

These enhancements would greatly improve Python’s usability and developer experience.

Expected Benefits:

  • Simplified Python version management with comprehensive subcommands.
  • Streamlined package initialization and management.
  • Enhanced development workflow with hot-reloading and file-watching capabilities.
3 Likes

This is a really cool feature, but it requires a huge amount of infrastructure and planning within the script. You won’t be able to just bolt it on from the outside. In general, the best way to achieve this is to have some sort of kernel that sets things up, and then a number of hot-reloadable modules; and those modules need to maintain state in a way that can be transferred to a new version of that module. I have done this before, but not often in Python, and almost always it’s something that has to get designed in from the ground up.

The other features you’ve requested are all very doable, and there’s no reason for them to be built-in; they can exist around the outside of Python quite happily.

3 Likes

pdm, hatch, rye, and pyenv each exist already with various tradeoffs and each do the “install and manage python versions in use” portion.

2 Likes

There has been a lot of discussion about this possibility and a bunch of related issues connected with packaging. Without going too much into that, I will say that if you want this kind of integrated management you might want to take a look at conda and/or mamba. Although they don’t let you set a “global default” Python version, they allow you to create multiple separate environments, each of which can have its own version of Python, and they can also manage the packages within these environments. (Pyenv is another tool that lets you manage Python versions, but doesn’t provide such a comprehensive integration of Python management and package management within the environments.)

Hmm, wouldn’t it make more sense to install Python with this tool rather than this tool coming with the Python installation? Then you’re also not limited by the restriction of needing to have at least 1 Python version installed.

1 Like

Ideas like this have been discussed multiple times in Packaging (looking for the keyword platypus might put you on the right track to finding the relevant discussion threads).

You can install some of the tools mentioned above (hatch, uv, maybe others) as standalone apps without needing a Python interpreter.

You should definitely check out uv.

uv python install 3.12
uv init --package
1 Like