Skip to content
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

print-deps-only: Document we don't handle recursive deps (from files, e.g. -rrequirements.txt) #22

Open
hroncok opened this issue Feb 28, 2020 · 8 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@hroncok
Copy link
Member

hroncok commented Feb 28, 2020

Fedora report: https://bugzilla.redhat.com/show_bug.cgi?id=1808601

tox docs: https://tox.readthedocs.io/en/latest/example/basic.html#depending-on-requirements-txt-or-defining-constraints

When the dependencies are defined as:

[testenv]
deps = -rrequirements.txt

We need to read the files (recursively) and output their content.

The code that handles this now is

@tox.hookimpl
def tox_runtest(venv, redirect):
"""If --print-deps-only, prints deps instead of running tests"""
config = venv.envconfig.config
unsupported_raise(config, venv)
if config.option.print_deps_path is not None:
with open(config.option.print_deps_path, "a", encoding="utf-8") as f:
print(*venv.get_resolved_dependencies(), sep="\n", file=f)
return True
if config.option.print_deps_only:
print(*venv.get_resolved_dependencies(), sep="\n")
return True

The *venv.get_resolved_dependencies() call needs to be replaced with a custom function call. That function needs to call venv.get_resolved_dependencies() and handle "packages" that start with -r/-c specially.

@hroncok hroncok added bug Something isn't working good first issue Good for newcomers labels Feb 28, 2020
@AdamWill
Copy link

Note that -c is also possible, to specify a 'constraints file' - see upstream docs for more.

@hroncok
Copy link
Member Author

hroncok commented Feb 28, 2020

Not sure how to handle constrains files here. On RPM level, we could wrap them in something like (foo > 5 if foo). But on the output of "one package per line" we don't really have a choice other than documenting it in the caveat section.

And that is also a valid solution of the -r files: we can just document that the output can contain them (and handle the recursion in Fedora macros).

@encukou
Copy link
Member

encukou commented Feb 29, 2020

It seems to me that to support requirements.txt properly, we'd basically need to reimplement pip's argument parsing :(

@hroncok
Copy link
Member Author

hroncok commented Feb 29, 2020

The more I think about this the more I think tox-current-env should just document this and %pyproject_buildrequires could do "best effort" with -r (and even possibly -c).

Parsing any possible pip command line arguments is not needed: those 2 options are explicitly documented in tox docs and I'd only consider more -r/-c switches inside.

@hroncok
Copy link
Member Author

hroncok commented Feb 29, 2020

What about this (new part in bold):

tox --print-deps-only / --print-deps-to-file:

Instead of running any commands, simply prints the declared dependencies in deps to the standard output or specified file. This is useful for preparing the current environment for the above. Any recursive dependencies or constraints (-r or -c) are printed as is. --print-deps-to-file will overwrite the file if it already exists.

Alternatively a new section in Other limitations and known bugs:

When the tox environment is depending on requirements.txt or defining constraints (via -r or -c), tox --print-deps-only / --print-deps-to-file does not attempt to read and parse the files but simply outputs the options as received.

@AdamWill
Copy link

It may be a naive idea, but - if what tox does here is just pass this through to pip for parsing, can we not do the same? Just ask pip to parse it for us and tell us the result? Does pip have a 'print out the deps' mode?

@hroncok
Copy link
Member Author

hroncok commented Mar 2, 2020

It's not a bad idea, but I don't think it does. And extending pip's API is quite hard.

@hroncok
Copy link
Member Author

hroncok commented Mar 2, 2020

@hroncok hroncok changed the title print-deps-only: handle recursive deps (from files, e.g. -rrequirements.txt) print-deps-only: Document we don't handle recursive deps (from files, e.g. -rrequirements.txt) Aug 27, 2020
@hroncok hroncok added documentation Improvements or additions to documentation and removed bug Something isn't working labels Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants