OK, testing out docker support in the example repo...
# development
c
OK, testing out docker support in the example repo, and funny thing is, it uses protobuf’s 😛
So, seems like I need to cross-compile for another target, OR, compile in docker…
Copy code
$ ./pants_from_sources run docker:helloworld
Traceback (most recent call last):
  File "/bin/helloworld/.bootstrap/pex/pex.py", line 483, in execute
  File "/bin/helloworld/.bootstrap/pex/pex.py", line 139, in activate
  File "/bin/helloworld/.bootstrap/pex/pex.py", line 126, in _activate
  File "/bin/helloworld/.bootstrap/pex/environment.py", line 428, in activate
  File "/bin/helloworld/.bootstrap/pex/environment.py", line 784, in _activate
  File "/bin/helloworld/.bootstrap/pex/environment.py", line 608, in resolve
  File "/bin/helloworld/.bootstrap/pex/environment.py", line 629, in resolve_dists
  File "/bin/helloworld/.bootstrap/pex/environment.py", line 573, in _root_requirements_iter
pex.environment.ResolveError: A distribution for protobuf could not be resolved in this environment.Found 2 distributions for protobuf that do not apply:
1.) The wheel tags for protobuf 3.17.0 are cp38-cp38-macosx_10_9_x86_64 which do not match the supported tags of DistributionTarget(interpreter=PythonInterpreter('/usr/local/bin/python3.8', PythonIdentity('/usr/local/bin/python3.8', 'cp38', 'cp38', 'manylinux_2_28_x86_64', (3, 8, 11)))):
cp38-cp38-manylinux_2_28_x86_64
cp38-cp38-manylinux_2_27_x86_64
[...]
py31-none-any
py30-none-any
2.) The wheel tags for protobuf 3.17.0 are cp39-cp39-macosx_10_9_x86_64 which do not match the supported tags of DistributionTarget(interpreter=PythonInterpreter('/usr/local/bin/python3.8', PythonIdentity('/usr/local/bin/python3.8', 'cp38', 'cp38', 'manylinux_2_28_x86_64', (3, 8, 11)))):
cp38-cp38-manylinux_2_28_x86_64
cp38-cp38-manylinux_2_27_x86_64
[...]
OK, so I’ve found the
platforms
option for
pex_binary
which should do what I want, I guess… however, I get stuck on
lxml
..
Copy code
Exception message: 1 Exception encountered:

  ProcessExecutionFailure: Process 'Building helloworld/pex_binary.pex with 4 requirements: ansicolors>=1.0.2, protobuf>=3.11.3, setuptools<54.0,>=50.3.0, translate>=3.2.1' failed with exit code 1.
stdout:

stderr:
ERROR: Could not find a version that satisfies the requirement lxml (from translate)
ERROR: No matching distribution found for lxml
pid 86625 -> /Users/aadt/.cache/pants/named_caches/pex_root/venvs/7862918fbb6656dd8d7eff1dd55ba13dcb07002e/739d26ded7518b7bd7f0ef93c3b66e0e826d110e/pex --disable-pip-version-check --no-python-version-warning --exists-action a --isolated -q --cache-dir /Users/aadt/.cache/pants/named_caches/pex_root --log /private/var/folders/8j/c8jf_msj009947wyw82xvdkw0000gn/T/process-executionogR8Wu/.tmp/tmpyys8sxqc/pip.log download --dest /private/var/folders/8j/c8jf_msj009947wyw82xvdkw0000gn/T/process-executionogR8Wu/.tmp/tmp4c9kk8i2/linux_x86_64-cp-38-cp38none --platform manylinux2014_x86_64 --platform linux_x86_64 --implementation cp --python-version 38 --abi cp38none --only-binary :all: --constraint constraints.txt ansicolors>=1.0.2 protobuf>=3.11.3 setuptools<54.0,>=50.3.0 translate>=3.2.1 --index-url <https://pypi.org/simple/> --retries 5 --timeout 15 exited with 1 and STDERR:
None
With this in the
BUILD
file:
Copy code
platforms=['linux-x86_64-cp-38-none']
also tried with
"linux-x86_64-cp-38-m"
with about as much luck… does that imply that there are no bdist of lxml, or… how can I get around it..? any ideas 🙂
f
Copy code
linux_x86_64-cp-38-cp38
is the one I use! Make sure not to use 3.8*m* as
m
was removed in 3.8! https://docs.python.org/3/whatsnew/3.8.html#build-and-c-api-changes I was bitten by it a few times
🎯 2
👍 2
https://pypi.org/project/lxml/4.6.3/#files does have wheels for the target platform of yours, for 3.8
❤️ 1
c
Awesome! It worked!! ❤️
Copy code
$ ./pants_from_sources package docker:helloworld
17:35:15.96 [INFO] Completed: Building helloworld/pex_binary.pex with 4 requirements: ansicolors>=1.0.2, protobuf>=3.11.3, setuptools<54.0,>=50.3.0, translate>=3.2.1
17:35:23.72 [INFO] Completed: Building docker image helloworld:latest
17:35:23.72 [INFO] Built docker image: helloworld:latest
To try out the image interactively: docker run -it --rm helloworld:latest [entrypoint args...]
  or using pants: ./pants run docker/Dockerfile:helloworld -- [args...]
To push your image: docker push helloworld:latest

$ ./pants_from_sources run docker:helloworld
Hello, world!
f
lovely, did you use
linux_x86_64-cp-38-cp38
or something else? 🙂
c
yes, precisely that one. Earned you the 🎯 reaction on your message 😉 https://github.com/pantsbuild/pants/pull/12363#issuecomment-885727774
🙌 2