Hi, I'm playing around with `experimental_shell_co...
# general
r
Hi, I'm playing around with
experimental_shell_command
to generate c++ extensions using cmake and pybind11 for python, the build file I'm using right now:
Copy code
shell_sources(name="build-c-exts", sources=["./**/*"])

experimental_shell_command(
  name="c-deps",
  command="./build.sh",
  log_output=True,
  tools=["make", "cmake", "cat", "bash", "env", "chmod", "gcc", "g++", "as", "ld"],
  dependencies=[":build-c-exts"],
  outputs=["results/", "logs/my-script.log"],
)
But I get an error that it can't find
Python.h
(I'm using pyenv), error in the thread ⬇️
Copy code
....
In file included from /usr/include/pybind11/pytypes.h:12,
                 from /usr/include/pybind11/cast.h:13,
                 from /usr/include/pybind11/attr.h:13,
                 from /usr/include/pybind11/pybind11.h:44,
                 from /usr/include/pybind11/numpy.h:12,
                 from /tmp/process-executionkJc7y1/src/lib/pybind11/farmwise_cv_utils.cpp:11:
/usr/include/pybind11/detail/common.h:112:10: fatal error: Python.h: No such file or directory
  112 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
.....
using pants @2.9.0
h
Hello! Is this working when not using Pants? It's plausible this is an issue w/ Pants not setting up the correct environment variables because it tries stripping things. But another hypothesis is missing certain system dependencies like
python3-dev
r
yes, it works when not using pants. And it's definitely because
python3-dev
is missing from the system^^, adding it works Here the expected behavior I think is to use pyenv to find the python headers ?
h
adding it works
Adding it how so? Installing via
apt-get
for example? Adding to
tools=[]
?
r
installing via apt-get
👍 1
h
Cool
Here the expected behavior I think is to uses pyenv to find the python headers ?
Perhaps Pants is using a different interpreter than what you use when running directly? Is your
build.sh
doing the Python interpreter selection for you? (Altho does it even call Python directly?)
r
it doesn't call python directly but runs a cmake build
I't probable that pants uses the local python instead of pyenv, I'll run a test with only pyenv as a python source to check
w
the
env
and
PATH
will be highly filtered in the script, so my guess is that a particular variable you’re expecting is not present
it doesn’t look like it currently supports allowing through particular environment variables, but that would definitely be something that would be worth adding. if you determine that that is the problem, would you mind opening a Github issue about it?
1
h
To determine that's it's an issue, you could try running
env
in your terminal to see all your env vars. Then try running that same script directly w/o Pants where you set the env vars to empty values like
CPPFLAGS=''
for example. Might be hard to reproduce now that you installed
python3-dev
tho
r
if you determine that that is the problem, would you mind opening a Github issue about it?
yes, it's definitely worth adding ^^, but I don't think it's the problem here It was simply that pants was using my
<PATH>
python instead of
<PYENV>
since I defined both in the config. On a similar note, about the experimental_run_shell_command, does it support pass through args ? I'm trying to create a command that add a poetry dep and updates the constraints.txt file
./pants run  poetry:add -- requests tqdm
and will be passed to the
poetry/add.sh
script as classic sh arg vars
w
On a similar note, about the experimental_run_shell_command, does it support pass through args ?
I’m trying to create a command that add a poetry dep and updates the constraints.txt file
if it doesn’t, it should. lemme see.
yes, it should support them: the
run
goal always appends those arguments
👍 1