Search code examples
pythonpippython-packagingpyproject.tomlpip-tools

Automate the update of packages in pyproject.toml from virtualenv or pip-tools


I am trying to update my Python CI environment and am working on package management right now. I have several reasons that I do not want to use Poetry; however, one nice feature of poetry is the fact that it automatically updates the pyproject.toml file. I know that pip-tools can create a requirements.txt file from the pyproject.toml file; however, is there any feature within virtualenv or pip-tools that will enable an automatic update of the pyproject.toml file when you install a package with pip to your virtual environment?


Solution

  • A standard tool-agnostic add command does not exist.

    It is being discussed here: https://discuss.python.org/t/poetry-add-but-for-pep-621/22957

    I do not know if there is such a feature in pip-tools. I am pretty sure it does not exist in virtualenv, that would be quite out of scope.

    Your can always adopt a "dev workflow tool" (PDM, Hatch, Poetry*) if you want it.


    *: Poetry uses a non-standard notation for the project metadata, but you seem to be currently using the standard notation (aka PEP621) so this could be a step backward if you were to migrate to Poetry.