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

feature: set environment variables as options #31

Open
15r10nk opened this issue Dec 30, 2024 · 1 comment
Open

feature: set environment variables as options #31

15r10nk opened this issue Dec 30, 2024 · 1 comment
Assignees
Labels
feature New feature or request fund Issue priority can be boosted

Comments

@15r10nk
Copy link

15r10nk commented Dec 30, 2024

Is your feature request related to a problem? Please describe.

I use coverage.py and coverage-enable-subprocess to run my tests with coverage.
This requires a environment variable TOP to be set to the project root directory

Describe the solution you'd like

I would like to use a option like extra_env={...} to add environment variables

with ctx.options(extra_env={"TOP": str(Path.cwd())}):
    ctx.run(...) # TOP is used
# TOP is not used

I searched for something like this in your docs, because it is possible to set the cwd via an option and I expected that there would also be an option for environment variables.

Describe alternatives you've considered

My current solution is this

os.environ["TOP"]=str(Path.cwd())

This works, but I think the other solution would be cleaner.

Additional context


This issue was labeled with the fund label. The following section is automatically added by Polar.

Boost priority in our backlog through Polar's "issue funding". Issues linked to monthly sponsorships of $50 or more (author, upvoters) are already prioritized, see how we manage our backlog.

Fund with Polar
@15r10nk 15r10nk added the feature New feature or request label Dec 30, 2024
@pawamoy
Copy link
Owner

pawamoy commented Dec 30, 2024

Sure, that's a good idea! I wonder if we should accept partial environments that are used to update the current one (temporarily), or complete envs that replace it, as the former would not allow removing environment variables. That's what subprocess does for example, and we usually do env={**os.environ.copy(), "MY_ENV": "VALUE"} to pass complete environments. A bit less ergonomic, for sure.

@pawamoy pawamoy added the fund Issue priority can be boosted label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request fund Issue priority can be boosted
Projects
None yet
Development

No branches or pull requests

2 participants