-
-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support multiple requirements in / txt #532
Comments
Also as it happens, I've got a bunch of these directories nested. I'd like to update all the |
+1! I find it’s very easy to have requirements split into runtime / test / deployment / CI files, and (sometimes) cpython vs pypy. I’ve been using a makefile to generate files but it’s not terribly user-friendly. |
How about using GNU make with the following Makefile:
Then you run |
Well makefiles are somewhat awful to write and don’t work on all OSes. I used to have them then switched to small shell scripts. |
@merwok I guess my point was that your workflow may be better supported by existing build tools, rather than expecting each tool to be a swiss army knife supporting all possible use cases. I'm -1 on this since you could indeed write a shell script to handle your use case. @vphilippon - what are your thoughts? |
Just my two cents, but I'm -1 on this in its current form. This issue assumes that the Instead I'd rather see a
Basically, we don't need to assume what the desired output is, this information is already present in the output requirements files. |
I'd also add some support for multiple sections in setup.py/setup.cfg ( I originally posted a longer comment in #492 but that was before I read this discussion. I would like to somehow achieve both better setup.py parsing and multiple-in-files compilation as parts of the same generalized workflow. UPD: I'm against using a makefile, I think this shouldn't depend on anything other than python and pip-tools. It could be a separate package, of course, but I think dependency layering is a common-enough practice that could benefit many pip-tools users if not most of them. UPD2: We probably don't even need to add any custom header. If we have explicit |
FTR I have found https://pypi.org/project/pip-compile-multi/ |
Thank you @merwok seems like exactly the tool I need. Except like many others it isn't aware about constraint files. But maybe I can modify it at least instead of implementing my own from scratch. |
@IvanAnishchuk Have you found a solution? Please see also peterdemin/pip-compile-multi#128 (comment) |
@chaoflow My current approach is to use two files: requirements.in and requirements-dev.in with You can read more about constraint files in pip documentation. |
FWIW my helper Zsh scripts for pip-tools work on all # compile requirements.txt files from all found or specified requirements.in files (compile)
pipc () { # [reqs-in...]
for reqsin in ${@:-*requirements.in(N)}; do
print -rP "%F{cyan}> compiling $reqsin -> ${reqsin:r}.txt . . .%f"
pip-compile --no-header $reqsin 2>&1
done
}
# install packages according to all found or specified requirements.txt files (sync)
pips () { # [reqs-txt...]
local reqstxts=(${@:-*requirements.txt(N)})
if [[ $reqstxts ]]; then
print -rP "%F{cyan}> syncing env <- $reqstxts . . .%f"
pip-sync $reqstxts
for reqstxt in $reqstxts; do # can remove if https://github.com/jazzband/pip-tools/issues/896 is resolved (by merging https://github.com/jazzband/pip-tools/pull/907)
pip install -qr $reqstxt # AND
done # https://github.com/jazzband/pip-tools/issues/925 is resolved (by merging https://github.com/jazzband/pip-tools/pull/927)
fi
} |
I little addition to @IvanAnishchuk 's solution, atomic compilation is still needed. Here is why:
When we compile the first file (which is the runtime dependencies), we get:
Then we compile the 2nd file (dev/CI dependencies):
Here comes a problem: So, the latest idna suitable for moto is 2.8. However, we have 2.9 in the runtime compiled list, which was unaware about the dev-dependencies. Now, when we do
We fail:
The 1st file should have been compiled with the 2nd file in mind somehow. But adding |
@nolar I think you want |
@AndydeCleyre That will be some kind of a circular dependency which is hard to compile. Effectively, |
My Zsh frontend functions for pip-tools (linked above) have come a way, and the interface seems pretty stable now. Three relevant functions from the project: # Compile, then sync.
# Use -h to include hashes, -u dep1,dep2... to upgrade specific dependencies, and -U to upgrade all.
pipcs [-h] [-U|-u <pkgspec>[,<pkgspec>...]] [--only-sync-if-changed] [<reqs-in>...] [-- <pip-compile-arg>...]
# 'pipcs -U' (upgrade-compile, sync) in a venv-activated subshell for the current or specified folders.
# Use --all to instead act on all known projects, or -i to interactively choose.
pipup [--py 2|pypy|current] [--only-sync-if-changed] [--all|-i|<proj-dir>...]
# Compile requirements.txt files from all found or specified requirements.in files (compile).
# Use -h to include hashes, -u dep1,dep2... to upgrade specific dependencies, and -U to upgrade all.
pipc [-h] [-U|-u <pkgspec>[,<pkgspec>...]] [<reqs-in>...] [-- <pip-compile-arg>...]
|
Just realized we've been discussing something similar @ #826 (comment). Though, I feel like it's hard to come up with a good UX for multiple source-to-output mappings. Maybe with the config (#604, #1863), it could be bearable. |
I've got a directory of various
requirements(?P<category>-[^.]*)?.in
files. And I want to generate the appropriatef'requirements{category}.txt'
files in one command.The text was updated successfully, but these errors were encountered: