Closed patrikha closed 2 years ago
Hmm, I'm not sure what's going on, but one thing that jumps out at me is the &&
in your first example. That's a shell operator, but cmd!
doesn't invoke the shell. So that operator and everything after it are getting passed as literal arguments to activate.bat
, which doesn't seem like what you meant.
Ok, makes sense then. Does duct support grabbing the environment after run? Activating a Python venv is basically just setting environment variables and if I could grab the env and then pass it to the next call to invoke Python that would be great.
No duct doesn't have any way to extract a child's environment. But if you're trying to programmatically run Python programs inside a virtualenv, I think it might be cleaner to skip the activate script and do something like this: https://stackoverflow.com/a/48174818/823869
OK clear and thanks for your quick response!
Hi, I'm trying to write a bootstrapper for our proprietary buildsystem which relies a lot on python but I get into issues when trying the following (simplified python script to show the issue):
cmd!(r"products\venv\Scripts\activate.bat", "&&", "python", "-c", "import sys; print(sys.version)")
then I get:
The code works just fine on Linux (when changing the path to activate) Also same issue when using duct_sh::sh_dangerous, works in Linux but not Windows
sh_dangerous("products\\venv\\Scripts\\activate.bat && python -c \"import sys; print(sys.version)\"")
Any suggestions on how to get the last string escaped correctly? Using version 0.13.5