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

Environment collector plugin: environment variables cannot be used as context variables in pyproject.toml #1929

Open
sumpfralle opened this issue Mar 10, 2025 · 0 comments

Comments

@sumpfralle
Copy link

I am using an environment collector plugin in order to populate an environment variable (here: GDAL_VERSION_SPECIFICATION):

env_dict = env_entry.setdefault("env-vars", {})
env_dict.setdefault("GDAL_VERSION_SPECIFICATION", some_value)

This environment variable is referenced in pyproject.toml:

dependencies = [
    "gdal{env:GDAL_VERSION_SPECIFICATION}",
]

But currently only real environment variables are used for context substitution:

if env_var in os.environ:

(source)

Thus, I am currently setting a real environment in my environment collector plugin as a workaround:

os.environ.setdefault("GDAL_VERSION_SPECIFICATION", some_value)

But this approach is certainly not the intended way of using environment collector plugins.
And it is fragile, since it relies on the collector plugin and the context substitution being executed within the same process.

The obvious solution seems to be, to let the context substitution peek into the env-vars dictionary of the current environment.
But these information are not handed over to the context substitution at the moment (source).

Do you have an idea, how this could be solved? Or maybe the os.environ hack above is sufficient?

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

No branches or pull requests

1 participant