Hello. Is there a way to run a shell command, e.g....
# general
m
Hello. Is there a way to run a shell command, e.g. a code editor, inside a prepared python environment similar to the
go-env
task?
e
No. If you have your third-party dependencies uniformly arranged under a third party tree though, you can script up creation of a virtualenv via:
Copy code
$ ./pants dependencies --external-only 3rdparty/python::
twitter.common.collections<0.4,>=0.3.1
twitter.common.dirutil<0.4,>=0.3.1
twitter.common.confluence<0.4,>=0.3.1
pywatchman==1.4.1
pyopenssl==17.3.0
setproctitle==1.1.10
future==0.16.0
pyflakes==2.0.0
thrift>=0.9.1
contextlib2==0.5.5
coverage<4.6,>=4.5
wheel==0.29.0
requests[security]<2.19,>=2.5.0
fasteners==0.14.1
s3-log-parse==0.1.1
pathspec==0.5.0
pytest<4.0,>=3.4
Markdown==2.1.1
packaging==16.8
psutil==4.3.0
pex==1.4.5
futures==3.0.5; python_version < "3"
six<2,>=1.9.0
beautifulsoup4<4.7,>=4.6.0
faulthandler==2.6; python_version < "3"
parameterized==0.6.1
pytest-cov<2.6,>=2.5
mock==2.0.0
antlr_python_runtime==3.1.3
configparser==3.5.0
pystache==0.5.3
ansicolors==1.0.2
cffi==1.11.1
Pygments==1.4
subprocess32==3.2.7; python_version < "3"
docutils<0.13,>=0.12
setuptools==33.1.1
scandir==1.2
pycodestyle==2.4.0
In other words, you can export all your pants `python_requirement_library`/`python_requirement_libraries` targets as a uniform
requirements.txt
format compatible stream.
m
Cool, thanks. Just tried it and it works for single targets as well. I should be able to glue something together from that.
Is there any technical reason that something like go-env can't be implemented for python? Otherwise I might take a jab at it.
e
None at all. That would be wonderful!
m
Ok, good to know. I'll see if I find the time 🙂
w
also related to something @strong-garage-46607 is working on for the node.js side: https://github.com/pantsbuild/pants/pull/6367
s
I think for node.js side, we have the ability to run commands through
./pants run.node --script-name <target>
e
That's not exactly the feature @magnificent-coat-60998 refers to. He wants to be able run say vim or sublime with an appropriate GOROOT & GOPATH or PYTHONPATH. I'm not sure what the equivalent feature would be for node. If pants uniformly used package.json instead of BUILD no feature would be needed of course, it's only BUILD files and the fact ~no editors understand them or else
./pants export
that leads to the need for the feature.
w
i think it's related, but "externalized"... after running
./pants node-install $target
, you can open an editor for that target... but without having done that, your editor will not know that it needs to transitively install things
(and "install" is super overloaded. but in this context, it means something like "having run the relevant setup scripts", similar to setup.py translation)
e
Ok,
node-install
makes sense for this use case.