You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I would like to be able to define local variables for my rye scripts (to avoid copy-pasting over, e.g. if I need to repeat the same filepaths). Also, such variable defined in a chain scope should ideally be usable from sub-commands.
I tried to workaround using the env vars in the scripts' commands, but this doesn't work:
Both output "$TEST" and not "OK". Indeed, the output of rye run -l shows that rye handles this by localizing the variable for the command to be called:
This is OK, but the env vars can't be used directly [a].
More concerning, I see that the cmd words after the first one are encapsulated in single quotes, thus even a defined variable would not be evaluated.
I am suggesting to either:
Change the way env var are handled, so that they can be used immediately, in addition to being passed to the sub-process [b].
Add a local variable feature e.g. to make test_env = { cmd = "echo $TEST", var = { TEST = "OK" } } print "OK" and not "$TEST",
As far as I am concerned, both options (local variables, or re-using the env ones) would be OK (I see pros and cons in both).
[a] For the chain usecase, the outputs doesn't tell if the env vars will be passed to sub-processes... I assume it does, but this is not relevant for my current need. [b] This is how Poe the Poet does it.
The text was updated successfully, but these errors were encountered:
I just learned about about Rye today from the uv announcement and I love it! It's by far the most productive Python environment and package management tool that I've used.
I currently want to set up a script for vim so that I can more easily edit the source files with rye run vim <filename.py> and it will automatically prepend src/my-project/ to the path. I couldn't figure out how to do that from the docs and then found this issue. From the comment it looks like it's currently not possible?
+1 for adding the ability to pass positional and named/environment paramters to the script commands.
In the meantime it looks like Poe the Poet should be able to do it so I'll try that. Thanks for the pointer @souliane ! 🙏
Hi, I would like to be able to define local variables for my rye scripts (to avoid copy-pasting over, e.g. if I need to repeat the same filepaths). Also, such variable defined in a
chain
scope should ideally be usable from sub-commands.I tried to workaround using the
env
vars in the scripts' commands, but this doesn't work:Both output
"$TEST"
and not"OK"
. Indeed, the output ofrye run -l
shows that rye handles this by localizing the variable for the command to be called:This is OK, but the env vars can't be used directly [a].
More concerning, I see that the
cmd
words after the first one are encapsulated in single quotes, thus even a defined variable would not be evaluated.I am suggesting to either:
test_env = { cmd = "echo $TEST", var = { TEST = "OK" } }
print"OK"
and not"$TEST"
,As far as I am concerned, both options (local variables, or re-using the env ones) would be OK (I see pros and cons in both).
[a] For the
chain
usecase, the outputs doesn't tell if the env vars will be passed to sub-processes... I assume it does, but this is not relevant for my current need.[b] This is how Poe the Poet does it.
The text was updated successfully, but these errors were encountered: