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?
Asked
Active
Viewed 561 times
3
-
What is the build back-end? Is it `setuptools`? – sinoroc Feb 01 '23 at 17:04
-
@sinoroc yes setup tools is my backend. – Jon Feb 01 '23 at 20:03
1 Answers
1
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.

sinoroc
- 18,409
- 2
- 39
- 70
-
Your answer is what I expected. I was hoping against all hope that pip-tools offered the desired functionality, but I do not think it does. I'm considering the possibility of just writing a bash script as a wrapper around pip that will automate the update of the toml file, but wanted to avoid this extra work. – Jon Feb 01 '23 at 20:08
-
Please correct me if I am wrong. I know that post python 3.8 is driving a lot of changes in the necessary configuration files. However, ultimately if I can capture all of my package requirements in the toml file, there is no longer a need for the requirements.txt file or a lock file. Am I incorrect in my understanding? – Jon Feb 01 '23 at 20:12
-
`pyproject.toml` is used for many things. If you mean the `[project]` section, then it is about specifying the metadata for a redistributable package that you want to build (sdists and wheels), and in this metadata is a list of dependencies, yes. But that is not the same purpose as `requirements.txt`, which is also not the same as a lock file. You can read [this](https://caremad.io/posts/2013/07/setup-vs-requirement/), although it is a bit outdated but if you substitute `setup.py` with `pyproject.toml`, it should still make sense. – sinoroc Feb 01 '23 at 21:16
-
I guess you can "*mis-use*" the `pyproject.toml` and in particular the `dependencies` field of its `[project]` section to replace a `requirements.txt` (or a lockfile), maybe that fits your expectations well enough after all, also I do not know how you used `requirements.txt` before so I really can just guess here. -- I do not know what you mean regarding Python 3.8. – sinoroc Feb 01 '23 at 21:34