pypa / pipfile

Other
3.24k stars 145 forks source link

Allow usage of Environment Variables inside TOML values #105

Closed dvf closed 6 years ago

dvf commented 6 years ago

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

Some thoughts:

jtratner commented 6 years ago
  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:$PASSWORD@mypypi.whatever.org"

[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 commented 6 years ago

I suggest doing something like pypa/pip#3782.

Also these tests will fail on Windows.

pradyunsg commented 6 years ago

I meant to link to pypa/pip#3728.

dvf commented 6 years ago

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 commented 6 years ago

README.rst seems to have all the docs, so good to put a note there :) On Mon, Mar 19, 2018 at 3:46 PM Daniel van Flymen notifications@github.com wrote:

Thanks for the feedback folks!

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

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/pypa/pipfile/pull/105#issuecomment-374410325, or mute the thread https://github.com/notifications/unsubscribe-auth/ABhjqw-fqw3RMnhfyxjcXrhRvLf_jN5Kks5tgDUtgaJpZM4SvAL7 .

kennethreitz commented 6 years ago

Merging — please add another PR with docs updates ASAP.

gnagel commented 6 years ago

Nice! 👍 @dvf

pradyunsg commented 6 years ago

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 commented 6 years ago

I see your point but I think this is ok—it’s a Python feature and not application-specific. We shouldn’t deviate from the std lib implementation without good reason.

On Apr 10, 2018, at 6:22 AM, Pradyun Gedam notifications@github.com wrote:

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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.