Good morning guys, I am trying to build a `pex_bin...
# general
a
Good morning guys, I am trying to build a
pex_binary()
target using
package
goal but it fails with following error:
Copy code
(pants) [root@9a5752857756 pants-training]# ./pants package src/client:greeter_client
13:07:32.60 [ERROR] 1 Exception encountered:

 BinaryNotFoundError: Cannot find `unzip` on `['/bin', '/usr/bin', '/usr/local/bin']`. Please ensure that it is installed so that Pants can download the tools Pants needs to run.

(pants) [root@9a5752857756 pants-training]#
I have the unzip package in `/usr/bin/`:
Copy code
(pants) [root@9a5752857756 pants-training]# ls -ltra /usr/bin/unzip
-rwxr-xr-x 2 root root 206728 Dec 16 2021 /usr/bin/unzip
(pants) [root@9a5752857756 pants-training]#
Could someone please help with this?
h
Hey good morning. Fishy.. What does
/usr/bin/unzip -v
do? We try running that to make sure the binary works https://github.com/pantsbuild/pants/blob/9449f42fb37c2663f28da7b33bb4d91d3d1851e7/src/python/pants/core/util_rules/system_binaries.py#L665-L674
a
It provides version info along with some other info:
Copy code
(pants) [root@9a5752857756 pants-training]# /usr/bin/unzip -v
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using <http://www.info-zip.org/zip-bug.html>; see README for details.

Latest sources and executables are at <ftp://ftp.info-zip.org/pub/infozip/> ;
see <ftp://ftp.info-zip.org/pub/infozip/UnZip.html> for other sites.

Compiled with gcc 8.5.0 20210514 (Red Hat 8.5.0-7) for Unix (Linux ELF) on Dec 16 2021.

UnZip special compilation options:
    COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)
    SET_DIR_ATTRIB
    SYMLINKS (symbolic links supported, if RTL and file system permit)
    TIMESTAMP
    UNIXBACKUP
    USE_EF_UT_TIME
    USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported)
    USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported)
    UNICODE_SUPPORT [wide-chars, char coding: UTF-8] (handle UTF-8 paths)
    MBCS-support (multibyte character support, MB_CUR_MAX = 6)
    LARGE_FILE_SUPPORT (large files over 2 GiB supported)
    ZIP64_SUPPORT (archives using Zip64 for large files supported)
    USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version 1.0.6, 6-Sept-2010)
    VMS_TEXT_CONV
    [decryption, version 2.11 of 05 Jan 2007]

UnZip and ZipInfo environment options:
      UNZIP: [none]
    UNZIPOPT: [none]
     ZIPINFO: [none]
   ZIPINFOOPT: [none]
(pants) [root@9a5752857756 pants-training]#
👍 1
h
Hm, okay thanks. I think the best way to debug this if you're willing is to use
--no-process-cleanup
https://www.pantsbuild.org/docs/troubleshooting#debug-tip-inspect-the-sandbox-with---no-process-cleanup Then we can run the
__run.sh
script with
set -x
enabled in the bash script we use to search for binaries to see what exactly is happening.
a
Ok, let me try.
Ok, so now it gave some other error similar to the Docker build -
python setup.py egg_info Check the logs for full command output.
Now, it doesn’t seem to be a python error because I am running both Docker and Pex build on two completely isolated envs.
I think this too will be resolved with the modification you suggested in
3rdparty/BUILD
in the Docker thread.
1
h
Agreed, and that's interesting that the logs suggest
unzip
was able to be discovered
a
Yeah, I saw that too and was surprised.
The next time I run
package
without
--no-process-cleanup
, it will automatically remove the temp files from previous run too?
h
it won't, you may want to delete
/tmp/process-execution*
👍 1
a
Yes, I was able to build Pex successfully with the change in
3rdparty/BUILD
. Moving to Docker now.
❤️ 1
So, there’s something weird (to me at least) that I noticed: The pex target that I built is:
pex_binary(
name="greeter_client",
entry_point="greeter_client.py",
)
It doesn’t mention any dependency to any proto (or any python source that imports those protos) but still the pex file has the generated stubs in it. However, the
python_distribution()
required me to explicitly mention the dependency on the source from where it could read the import statements based on which it would generate the stubs.
h
Yeah, so
pex_binary
has dependency inference. We're able to infer a dependency on
greeter_client.py
, which then pulls in the transitive deps on the protos But for
python_distribution
, we don't have any field like
entry_point
where we can deduce what your dependencies are. So you have to explicitly tell us. But we still pull in your transitive deps for you, like the protos
a
Ok.