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

Allow requirement.Marker.evaluate() with arbitrary environment #431

Open
pombredanne opened this issue May 25, 2021 · 1 comment
Open

Allow requirement.Marker.evaluate() with arbitrary environment #431

pombredanne opened this issue May 25, 2021 · 1 comment

Comments

@pombredanne
Copy link

One of the use case of the packaging library is to support tooling that may run in a different environment than the processed packages are intended for. For instance, I may want to process a Requirement.marker and evaluate() it on a different platform environment that is not the environment of the current Python interpreter. However, the evaluate() method environment arg can only update the environment and can never override/replace it entirely.

current_environment.update(environment)

It would be useful for tools to be able to entirely override the environment rather than just updating it.

@uranusjr
Copy link
Member

But for replacing to work, don’t you need to pass the whole environment anyway? In which case the dict.update would simply replace everything from the original environment. Or am I missing something?

With that said, the fact that packaging currently implicitly depending a lot on the current environment is problematic (not just packaging.markers, but packaging.tags as well). It would be much easier to work with it if instead of providing a point for partial override, the user is always required to pass in a complete environment to replace the current one (and we can provide some helper functions to generate a complete environment dict).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants