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

How to share Environment Variables (eg: python venv) between recipes? #1216

Closed
mokeyish opened this issue Jun 7, 2022 · 6 comments · Fixed by #1229
Closed

How to share Environment Variables (eg: python venv) between recipes? #1216

mokeyish opened this issue Jun 7, 2022 · 6 comments · Fixed by #1229

Comments

@mokeyish
Copy link

mokeyish commented Jun 7, 2022

How to share Environment Variables (eg: python venv) between recipes?

# create venv 
venv:
  #!/usr/bin/env bash
  [ ! -f 'venv' ]&& python -m venv venv
  source venv/bin/activate


# install dependencies.
dev: venv
  #!/usr/bin/env bash
  which python 
  pip install -r requirements.txt
@casey
Copy link
Owner

casey commented Jun 7, 2022

There is no good way to share environment variables between recipes.

Instead of sourcing the venv, can you run the venv binaries directly?

venv:
  [ ! -f 'venv' ]&& python -m venv venv

dev: venv
  venv/bin/pip install -r requirements.txt

Or can you add venv/bin to your path?

export PATH = "venv/bin:" + env_var("PATH") 

venv:
  [ ! -f 'venv' ]&& python -m venv venv

dev: venv
  pip install -r requirements.txt

I haven't used python virtual environments much, so I'm not sure if either of these approaches work.

@mokeyish
Copy link
Author

mokeyish commented Jun 8, 2022

Thanks, it should work.

@casey
Copy link
Owner

casey commented Jun 8, 2022

@mokeyish Which solution do you think is best, adding venv/bin to PATH, or executing the binaries in it directly? This specific question comes up a lot, so I'd like to add the best solution to the readme.

@mokeyish
Copy link
Author

mokeyish commented Jun 8, 2022

I think the second solution is better, It's simple than the first one.

Will you add feature share Environment Variables to just?

@casey
Copy link
Owner

casey commented Jun 8, 2022

I think the second solution is better, It's simple than the first one.

Thanks, I'll note it in the readme.

Will you add feature share Environment Variables to just?

Unfortunately I don't think there's a reasonable way to implement it. If someone comes up with a good strategy for implementing it, I'd definitely consider it.

@mokeyish
Copy link
Author

mokeyish commented Jun 8, 2022

Unfortunately I don't think there's a reasonable way to implement it. If someone comes up with a good strategy for implementing it, I'd definitely consider it.

  • Generate all command in recipes into a bash srcipt dynamiclly?
  • subprocess?

Do you think?

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

Successfully merging a pull request may close this issue.

2 participants