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 usage of Environment Variables inside TOML values #105

Merged
merged 3 commits into from
Mar 20, 2018

Conversation

dvf
Copy link
Contributor

@dvf dvf commented Mar 17, 2018

We're relying on os.path.expandvars() to inject environment variables in values.

Some thoughts:

  • The Pipfile hash should be determined after values have attempted to be inserted.
  • Pipfile shouldn't be intelligent by trying to differentiate env vars from regular characters—if an env var can't be inserted, the string should remain intact.
  • As it stands, Pipenv's vendor folder contains some version of this repository. I don't fully understand the reasons behind this, couldn't we pin it as a requirement instead? We could then separate tests.

@jtratner
Copy link

  1. Can you add notes to the docs about the environment variable parsing that explain how they should be interpreted?
  2. I guess there aren't other tests for pipfile right now, but might be nicer / clearer to just write out full example pipfiles. I get the desire to DRY up the tests cases, but it'd be easier to understand what you mean if you just saw in code:
"""
[[source]]
url = "https://$FOO:[email protected]"

[packages]

requests = "*"
# presumably some git egg style thing where you're putting env vars in git URL
"""

and then (because you have two env vars) you can check what happens when env vars can and cannot be expanded. + that gives you easy route to check hashing behavior :)

@pradyunsg
Copy link
Member

I suggest doing something like pypa/pip#3782.

Also these tests will fail on Windows.

@pradyunsg
Copy link
Member

I meant to link to pypa/pip#3728.

@dvf
Copy link
Contributor Author

dvf commented Mar 19, 2018

Thanks for the feedback folks!

@pradyunsg: Can you give some context about why you think these tests will fail on windows?
@jtratner: Where would you like these notes to go?

@jtratner
Copy link

jtratner commented Mar 20, 2018 via email

@kennethreitz
Copy link
Contributor

Merging — please add another PR with docs updates ASAP.

@kennethreitz kennethreitz merged commit 04c2616 into pypa:master Mar 20, 2018
@gnagel
Copy link

gnagel commented Mar 20, 2018

Nice! 👍 @dvf

@pradyunsg
Copy link
Member

Can you give some context about why you think these tests will fail on windows?

My bad. Not fail.

The point I wanted to make was os.path.expandvars expands %VAR% format variables along with ${var} and $var format ones on Windows, not other OSes. This is an inconsistency across OSes. The approach in the PR I linked above is consistent across OSes -- only expanding ${var} on all OSes.

@dvf
Copy link
Contributor Author

dvf commented Apr 10, 2018 via email

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 this pull request may close these issues.

5 participants