-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
Add pre_install
configuration option
#2886
Comments
I'm not sure I follow how this work. What kind of modification would happen, and how would this trickle back to the installation command for tox? |
@Czaki If you're looking for something "simple" to get off the ground, consider an inline plugin, The plugin api exposes Here's a possible example: import os
from typing import Any
from tox.config.cli.parser import DEFAULT_VERBOSITY
from tox.execute.request import StdinSource
from tox.plugin import impl
from tox.tox_env.api import ToxEnv
HERE = os.path.dirname(__file__)
@impl
def tox_on_install(tox_env: ToxEnv, arguments: Any, section: str, of_type: str):
if of_type == "deps":
cmd = ["python", os.path.join(HERE, "build_utils", "create_minimal_reqs.py")]
result = tox_env.execute(
cmd=cmd,
stdin=StdinSource.user_only(),
run_id="create_minimal_requirements",
show=tox_env.options.verbosity > DEFAULT_VERBOSITY,
) I've been developing a plugin recently, tox-pin-deps, which creates pip-compile lock files from the While I don't think |
in the second example napari/napari@20319df/.github/workflows/test_pull_requests.yml#L129 the called scripts modifies
Wow, it looks promising.
It looks interesting, but |
This sounds destructive, and probably there are better ways to go. Using constraint files is a better solution. https://tox.wiki/en/latest/faq.html#using-constraint-files |
Oh yikes. I guess I was only looking at the example that built a requirements file with pip-compile... Munging the I think using a pip-compile lock file is okay, but installing any requirements file via Ultimately I think constraint files are the answer here, so the question remains as to where those constraint files come from and how tox can know about them and apply them at the correct time. Again, even specifying |
I agree, but it provides a single source of truth. MAybe it could be better to use a constraints file, but it still is nice to have the option to generate it from |
I'd say I won't do part of the core. You can create a plugin for it, though. Core only intends to support constraints files. |
What's the problem this feature will solve?
Next to the normal test, I would have the oldest-supported test. I test my code on the oldest supported version of packages based on requirements constrains from
setup.cfg
.Currently, it requires me to run separate commands before calling tox (or make tox calling tox) to extract minimal requirements from package metadata. So time to time, I have false negative runs when executing it manually. I also need to have a more complex CI configuration.
Describe the solution you'd like
Add
pre_install
command that will be executed before the installation of package. To allow modify metadata/requirements file.Manual curated list of minimal requirements to be passed to deps:
https://github.com/4DNucleome/PartSeg/blob/develop/build_utils/minimal-req.txt
https://github.com/4DNucleome/PartSeg/blob/develop/tox.ini#L91
Special call of script that modifies setup.cfg for testing minimal requirements:
https://github.com/napari/napari/blob/20319df0b397f85054e1c7e728d393eb7a7a7b38/.github/workflows/test_pull_requests.yml#L129
Alternative Solutions
commadn_pre
- additional maintenance need to keep consistency with other envsinstall_command
to execute pinning before callpip install
- additional maintenance need to keep consistency with other envsAll works but all looks like a dirty solutions.
Additional context
The text was updated successfully, but these errors were encountered: