https://pantsbuild.org/ logo
#general
Title
# general
g

green-tiger-17672

03/09/2023, 3:41 PM
Hello , I am receiving this error for psycopg2-binary anytime dependencies are built when running pants , Initialization options changed: reinitializing scheduler...
Copy code
09:36:02.92 [INFO] Scheduler initialized.
09:36:05.09 [INFO] Preserving local process execution dir /private/var/folders/8b/_mfgyxjj7wg972pfzn9rqnw40000gn/T/pants-sandbox-5BvC0E for Building 7 requirements for requirements.pex from the python-default.lock resolve: SQLAlchemy==1.4, loguru==0.6.0, psycopg2-binary==2.9.5, requests==2.27.1, sqlalchemy-stubs==0.4, types-requests==2.28.11.2, typing_extensions==4.4.0
09:36:05.09 [INFO] Completed: Building 7 requirements for requirements.pex from the python-default.lock resolve: SQLAlchemy==1.4, loguru==0.6.0, psycopg2-binary==2.9.5, requests==2.27.1, sqlalchemy-stubs==0.4, types-requests==2.28... (31 characters truncated)
09:36:05.09 [ERROR] 1 Exception encountered:

 ProcessExecutionFailure: Process 'Building 7 requirements for requirements.pex from the python-default.lock resolve: SQLAlchemy==1.4, loguru==0.6.0, psycopg2-binary==2.9.5, requests==2.27.1, sqlalchemy-stubs==0.4, types-requests==2.28.11.2, typing_extensions==4.4.0' failed with exit code 1.
stdout:

stderr:
There was 1 error downloading required artifacts:
1. psycopg2-binary 2.9.5 from <https://files.pythonhosted.org/packages/8c/45/77147700f5088efaf9235a3a62b611b594d477a5c5613b5316d0ebd18be0/psycopg2-binary-2.9.5.tar.gz>
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Im currently on an M1 mac and this error presented itself after pulling down code from another colleague, however there were no major code changes. Has anyone encountered this before?
h

happy-kitchen-89482

03/09/2023, 4:20 PM
Ugh,
psycopg2-binary
is the gift that keeps on giving. If you search for it on this Slack you'll get so many issues... 😞 The gist is that
psycopg2-binary
is distributed as an sdist, and contains native code, so it has to be compiled on your platform, which is done by Pip (via Pex). And that is failing on your system.
To debug this, run with
--keep-sandboxes=on_failure
, and Pants will log the sandbox directory that the pex process ran in. Then
cd
to that directory, and run
./__run.sh
to confirm that the failure still happens if you re-run manually in the sandbox. • If the failure doesn't happen, it almost certainly means that there's an env var that the pip build is relying on that isn't being plumbed into the sandbox (
./__run.sh
doesn't isolate your environment the way Pants does). So then we can figure out which env var that is. • If the failure does happen, you can edit
./__run.sh
to add
--preserve-pip-download-log
to the Pex command line. Then run it again. It'll log the location of that pip log, and you can poke in that to see what the issue might be.
When you pulled the changes, did they include an upgrade of psycopg2-binary?
g

green-tiger-17672

03/14/2023, 6:46 PM
Thank you for your assistance! I tried the steps you outlined, I ran the ./__run.sh command in the directory that was logged after directing it to keep sandboxes . When I ran this in the directory given, the same error occurred. When I ran with the preserve pip download log command , I was unable to find the location of the pip log. I checked the pants log files and was unable to locate it anywhere in the log. Am I missing something? Also , no there was not an update to the psycopg2-binary when I pulled.
h

happy-kitchen-89482

03/14/2023, 9:13 PM
Hmm, try running Pants with
-ldebug
, maybe that will emit the Pex output (which in turn should emit the pip output)
3 Views