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

rapid-bird-79300

01/11/2022, 9:48 PM
Hey Pants Team, We're having issues reported from M1 mac users regarding
psutil/_psutil_osx.cpython-39-darwin.so
. See this gist for more debug info. We followed directions in https://www.pantsbuild.org/v2.7/docs/installation#macos but no luck. We tried removing the library and installing it directly but still having the same issue. Any help is greatly appreciated!
e

enough-analyst-54434

01/11/2022, 9:59 PM
The relevant bit is:
Copy code
'/Users/jjli/.cache/pants/setup/bootstrap-Darwin-arm64/pants.6KPRax/install/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
So you tried the
arch -x86_64 pants
advice here and no dice?: https://www.pantsbuild.org/docs/prerequisites
Ah, yeah - you pointed to similar docs.
a

ancient-vegetable-10556

01/11/2022, 10:29 PM
@rapid-bird-79300 Does your M1 user have Homebrew at
/opt/homebrew
?
r

rapid-bird-79300

01/11/2022, 10:37 PM
Yeah we tried the steps in those docs and no luck. @ancient-vegetable-10556 Homebrew is installed at
/opt/homebrew/bin/brew
a

ancient-vegetable-10556

01/11/2022, 10:37 PM
What’s in their $PATH?
(I’ve worked through this a few times with others, and it’s often down to PATH being set to prefer x86 pythons)
👍 1
r

rapid-bird-79300

01/11/2022, 10:40 PM
We have this
Copy code
/Users/jjli/.pyenv/shims:/Users/jjli/.pyenv/shims:/Users/jjli/.pyenv/shims:/Users/jjli/.nvm/versions/node/v12.19.1/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jjli/.pyenv/shims:/Users/jjli/.pyenv/bin:/Users/jjli/.pyenv/shims:/Users/jjli/.pyenv/bin:/Users/jjli/.pyenv/shims:/Users/jjli/.poetry/bin:/Users/jjli/.pyenv/shims:/Users/jjli/.pyenv/bin:/Users/jjli/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/Library/Apple/usr/bin
a

ancient-vegetable-10556

01/11/2022, 10:41 PM
Well something is broken in your pyenv setup for starters Well something is broken in your pyenv setup for starters Well something is broken in your pyenv setup for starters Well something is broken in your pyenv setup for starters
😉
r

rapid-bird-79300

01/11/2022, 10:43 PM
lol yeah that definitely feels like this is it let me follow up with the user
a

ancient-vegetable-10556

01/11/2022, 10:43 PM
I’m wondering if you have an x86 version of python 3.9 in ~/.pyenv/versions
You can run e.g.
Copy code
chrisjrn@chrisjrns-MacBook-Pro pants % lipo -info ~/.pyenv/versions/3.8.12/bin/python
Non-fat file: /Users/chrisjrn/.pyenv/versions/3.8.12/bin/python is architecture: x86_64
that shows an x86 binary (obviously), and this one shows an arm binary:
Copy code
chrisjrn@chrisjrns-MacBook-Pro pants % lipo -info /opt/homebrew/bin/python3
Non-fat file: /opt/homebrew/bin/python3 is architecture: arm64
r

rapid-bird-79300

01/11/2022, 10:53 PM
so we have
Copy code
jjli@jingjings-mbp  ~/rippling-main   master ?  lipo -info ~/.pyenv/versions/3.9.5/bin/python                              ✔  1393  14:50:05
Non-fat file: /Users/jjli/.pyenv/versions/3.9.5/bin/python is architecture: arm64
it seems just
3.9.5
and system version is installed.
a

ancient-vegetable-10556

01/11/2022, 11:54 PM
ok, well that’s super weird
r

refined-addition-53644

01/24/2022, 10:16 AM
Hi, we are struggling with same issue on a new Mac M1 owned by a colleague and we checked the architecture for python3.9 which is
arm64
.
One issue we found was, my colleague is using
alacritty
as the terminal emulator. When you run
uname -m
in this terminal, it shows
x86_64
instead of
arm64
and hence the pants bootstrap path was broken
Copy code
PANTS_BOOTSTRAP="${PANTS_SETUP_CACHE}/bootstrap-$(uname -s)-$(uname -m)
But now even after switching back to default mac terminal where
uname -s
returns
arm64
, it's still failing. We are still debugging...
a

ancient-vegetable-10556

01/24/2022, 4:19 PM
@refined-addition-53644 Can you drop in the error message, so we can take a look?
r

refined-addition-53644

01/24/2022, 4:33 PM
Hi @ancient-vegetable-10556, please have a look.
Copy code
niklas.hildebrandt@Niklass-MBP pyfleet % ./pants --version       
Bootstrapping Pants using /opt/homebrew/bin/python3.9
Creating the virtualenv PEX.
Downloading the Pex PEX.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   640  100   640    0     0   5025      0 --:--:-- --:--:-- --:--:--  5161
100 3529k  100 3529k    0     0  2622k      0  0:00:01  0:00:01 --:--:-- 4976k
SHA256 fingerprint of <https://github.com/pantsbuild/pex/releases/download/v2.1.42/pex> verified.
Installing pantsbuild.pants==2.9.0 into a virtual environment at /Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/2.9.0_py39
created virtual environment CPython3.9.10.final.0-64 in 145ms
  creator CPython3Posix(dest=/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/niklas.hildebrandt/Library/Application Support/virtualenv)
    added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Requirement already satisfied: pip in /Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages (21.1.2)
Collecting pip
  Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.2
    Uninstalling pip-21.1.2:
      Successfully uninstalled pip-21.1.2
Successfully installed pip-21.3.1
Collecting pantsbuild.pants==2.9.0
  Using cached pantsbuild.pants-2.9.0-cp39-cp39-macosx_11_0_arm64.whl (7.6 MB)
Collecting packaging==21.0
  Using cached packaging-21.0-py3-none-any.whl (40 kB)
Collecting setproctitle==1.2.2
  Using cached setproctitle-1.2.2-cp39-cp39-macosx_12_0_arm64.whl
Collecting types-PyYAML==5.4.3
  Using cached types_PyYAML-5.4.3-py2.py3-none-any.whl (12 kB)
Collecting pex==2.1.61
  Using cached pex-2.1.61-py2.py3-none-any.whl (2.6 MB)
Collecting types-toml==0.1.3
  Using cached types_toml-0.1.3-py2.py3-none-any.whl (2.1 kB)
Collecting humbug==0.2.7
  Using cached humbug-0.2.7-py3-none-any.whl (11 kB)
Collecting PyYAML<7.0,>=6.0
  Using cached PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl (173 kB)
Collecting psutil==5.8.0
  Using cached psutil-5.8.0-cp39-cp39-macosx_12_0_arm64.whl
Collecting typing-extensions==3.10.0.2
  Using cached typing_extensions-3.10.0.2-py3-none-any.whl (26 kB)
Collecting types-setuptools==57.0.0
  Using cached types_setuptools-57.0.0-py3-none-any.whl (4.8 kB)
Requirement already satisfied: setuptools<58.0,>=56.0.0 in /Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages (from pantsbuild.pants==2.9.0) (57.0.0)
Collecting ansicolors==1.1.8
  Using cached ansicolors-1.1.8-py2.py3-none-any.whl (13 kB)
Collecting toml==0.10.2
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting fasteners==0.16.3
  Using cached fasteners-0.16.3-py2.py3-none-any.whl (28 kB)
Collecting ijson==3.1.4
  Using cached ijson-3.1.4-py3-none-any.whl
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting requests
  Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-3.0.7-py3-none-any.whl (98 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
Collecting charset-normalizer~=2.0.0
  Using cached charset_normalizer-2.0.10-py3-none-any.whl (39 kB)
Installing collected packages: urllib3, idna, charset-normalizer, certifi, six, requests, pyparsing, typing-extensions, types-toml, types-setuptools, types-PyYAML, toml, setproctitle, PyYAML, psutil, pex, packaging, ijson, humbug, fasteners, ansicolors, pantsbuild.pants
Successfully installed PyYAML-6.0 ansicolors-1.1.8 certifi-2021.10.8 charset-normalizer-2.0.10 fasteners-0.16.3 humbug-0.2.7 idna-3.3 ijson-3.1.4 packaging-21.0 pantsbuild.pants-2.9.0 pex-2.1.61 psutil-5.8.0 pyparsing-3.0.7 requests-2.27.1 setproctitle-1.2.2 six-1.16.0 toml-0.10.2 types-PyYAML-5.4.3 types-setuptools-57.0.0 types-toml-0.1.3 typing-extensions-3.10.0.2 urllib3-1.26.8
New virtual environment successfully created at /Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/2.9.0_py39.
Traceback (most recent call last):
  File "/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/2.9.0_py39/bin/pants", line 5, in <module>
    from pants.bin.pants_loader import main
  File "/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 19, in <module>
    from pants.bin.pants_runner import PantsRunner
  File "/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages/pants/bin/pants_runner.py", line 11, in <module>
    from pants.base.exception_sink import ExceptionSink
  File "/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages/pants/base/exception_sink.py", line 15, in <module>
    import psutil
  File "/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages/psutil/__init__.py", line 121, in <module>
    from . import _psosx as _psplatform
  File "/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages/psutil/_psosx.py", line 15, in <module>
    from . import _psutil_osx as cext
ImportError: dlopen(/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried: '/Users/niklas.hildebrandt/.cache/pants/setup/bootstrap-Darwin-arm64/pants.JSvioR/install/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_psutil_osx.cpython-39-darwin.so' (no such file), '/usr/lib/_psutil_osx.cpython-39-darwin.so' (no such file)
a

ancient-vegetable-10556

01/24/2022, 4:35 PM
You may want to try deleting
~/.cache/pants
— I find that using
rm -rf
can take a long time, but running
open ~/.cache
and dragging
pants
to trash is quite fast.
r

refined-addition-53644

01/24/2022, 4:36 PM
we did do that already few times
a

ancient-vegetable-10556

01/24/2022, 4:37 PM
Interesting
r

refined-addition-53644

01/24/2022, 4:39 PM
It's weird - one of the colleagues has M1 and it worked without any issue. This is happening with another colleague who has M1 pro
a

ancient-vegetable-10556

01/24/2022, 4:39 PM
Right. It looks like the fix is to get the
ARCHFLAGS
environment variable passed into the bootstrap process
(we need to pass in
ARCHFLAGS="-arch arm64"
into the bootstrap process)
r

refined-addition-53644

01/24/2022, 4:41 PM
This way?
Copy code
ARCHFLAGS="-arch arm64" ./pants --version
is
amd64
or
arm64
?
a

ancient-vegetable-10556

01/24/2022, 4:42 PM
arm64
sorry, two decades of muscle memory 🙂
😄 1
Try that. I am not entirely certain it’ll work, but that’s a good starting point
r

refined-addition-53644

01/24/2022, 4:56 PM
same error
a

ancient-vegetable-10556

01/24/2022, 5:00 PM
I can’t find the relevant docs here, so I’m checking in with a colleague
h

hundreds-father-404

01/24/2022, 5:07 PM
Have you tried
rm -rf ~/.cache/pants
? It looks like this issue is happening when bootstrapping Pants itself to run it, rather than when Pants is already running. So there wouldn't be any relevant Pants option to change And that sounds useful to start with getting normal macOS terminal to work before trying alacracity
e

enough-analyst-54434

01/24/2022, 5:30 PM
One thing to note in all these logs is:
Copy code
Collecting pantsbuild.pants==2.9.0
  Using cached pantsbuild.pants-2.9.0-cp39-cp39-macosx_11_0_arm64.whl (7.6 MB)
That should be mildly surprising. So Pip is grabbing wheels from its cache. If you look at psutil 5.8.0, although they added pre-built wheel support (used to be sdist only), they did not cover mac silicon; so ... presumably psutil gets a fresh build if you clear the Pip cache (that's
~/.cache/pip/
I believe...) Not sure that helps debugging at all, but its a variable it looks like folks are overlooking.
💯 1
1
🙌 1
a

ancient-vegetable-10556

01/24/2022, 5:39 PM
@hundreds-father-404 re deleting cache: https://pantsbuild.slack.com/archives/C046T6T9U/p1643042154235100?thread_ts=1641937720.178900&amp;cid=C046T6T9U — first thing I suggested both times.
👍 1
h

hundreds-father-404

01/24/2022, 5:43 PM
Ah oops, although would be good to repeatedly do that after trying new things, to reset back to a blank slate.
a

ancient-vegetable-10556

01/24/2022, 5:49 PM
OK, but generally, it looks like psutil is building with the wrong archflags, I’m wondering if there’s anything we can do to get it to build with the correct arch flags (that’s the env var I pointed out earlier)?
e

enough-analyst-54434

01/24/2022, 5:59 PM
There should be no intervening armor. Pex is out of the way and Pants isn't even bootstrapped. I'm starting to know Pip quite well and I'm pretty sure it does not filter env vars; so any env var in the environment should pass right through the
pants
bootstrap bash to
pip
and its subprocesses.
👍 2
There is this deliberate scrubbing - but its for PEX env vars: https://github.com/pantsbuild/setup/blob/f58bc5a44ef738325c57308349ccda3fc39567ec/pants#L271-L278 I don't think that's running astray and nuking other env vars, but worth more eyes.
It's deliberately run in a subshell though; so even if, there really is no way: https://github.com/pantsbuild/setup/blob/f58bc5a44ef738325c57308349ccda3fc39567ec/pants#L292-L295
Oh right, PEX is potentially in the way, we run virtualenv via a
virtualenv.pex
. That said, PEX, in turn, only scrubs
PEX*
env vars, but ... OK, this should not be it since this code is only used for Pex CLI subprocesses and not the PEX runtime: https://github.com/pantsbuild/pex/blob/a81f49b50368fcabb2096760401a49d0f5618aea/pex/interpreter.py#L1124-L1178 But it is a mac hoop that could be related to this style issue in the case this code path was taken at runtime (it isn't after the final re-exec): https://github.com/pantsbuild/pex/blob/a81f49b50368fcabb2096760401a49d0f5618aea/pex/interpreter.py#L1124-L1178 So, for sanity sake, we can rule this all out with the following edit to the
pants
script:
Copy code
diff --git a/pants b/pants
index 995e5806a..b843efbef 100755
--- a/pants
+++ b/pants
@@ -291,7 +291,7 @@ function bootstrap_virtualenv {
       echo "${VIRTUALENV_REQUIREMENTS}" > requirements.txt
       (
         scrub_PEX_env_vars
-        "${python}" "${pex_path}" -r requirements.txt -c virtualenv -o virtualenv.pex
+        "${python}" "${pex_path}" -r requirements.txt -c virtualenv -o virtualenv.pex --venv -v
       )
       mkdir -p "$(dirname "${bootstrapped}")"
       mv -f "${staging_dir}/virtualenv.pex" "${bootstrapped}"
@rapid-bird-79300 or @refined-addition-53644 can you try applying this patch in your repo,
rm -rf ~/.cache/pip ~/.cache/pants/setup
and report back? I suspect this will solve nothing, but that will rule out Pex completely and allow unclouded pursuit of other angles.
🤞 1
👀 1
r

refined-addition-53644

01/25/2022, 9:54 AM
What worked in the end was clearing up the pip cache which was suggested above by @enough-analyst-54434. So now my question is if pants is using its own virtualenv, shouldn't it clean up this pip cache too, if we delete pants cache?
e

enough-analyst-54434

01/25/2022, 8:01 PM
Perhaps (i.e.: run Pip with
--no-cache-dir
). That said, nuking caches is a "fix" that leaves us all ignorant. It's great it fixes the issue, but the issue is still not understood. Those sorts of "solved" issues ~always come back to bite you.
👍 2
r

refined-addition-53644

01/25/2022, 8:51 PM
r

rapid-bird-79300

01/27/2022, 6:41 PM
We're still facing this issue after trying the suggestions above (nuking pip cache and pants cache) @enough-analyst-54434 We updated the pants script as you suggested and this is the output we got: https://gist.github.com/njgrisafi/3708058a8b03f8e6a2d601cc8c76678f
e

enough-analyst-54434

01/27/2022, 6:47 PM
Ok, great - thank you. This takes Pex out of the debug loop. All other possibilities are still on the table though, so more brainpower is still needed.
r

rapid-bird-79300

02/16/2022, 9:35 PM
we got another report of this issue, debug logs: https://gist.github.com/njgrisafi/49de641e678e35e8b75183d17aaa3cb7 seems to be same situation we have above
cc: @creamy-monitor-52086 who has M1 laptop to test with
c

creamy-monitor-52086

02/16/2022, 9:36 PM
Hey all!
👋 1
e

enough-analyst-54434

02/16/2022, 9:44 PM
Hey. So @rapid-bird-79300 said he nuked Pip caches and same issue. The latest gist shows Pip cahces being used. For sanity sake, can you post a new gist @creamy-monitor-52086 after a
rm -rf ~/.cache/pants/setup ~/.cache/pip
?
c

creamy-monitor-52086

02/16/2022, 9:48 PM
Copy code
Bootstrapping Pants using /opt/homebrew/bin/python3.9
Creating the virtualenv PEX.
Downloading the Pex PEX.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   640  100   640    0     0   2095      0 --:--:-- --:--:-- --:--:--  2119
100 3529k  100 3529k    0     0  2586k      0  0:00:01  0:00:01 --:--:-- 19.5M
SHA256 fingerprint of <https://github.com/pantsbuild/pex/releases/download/v2.1.42/pex> verified.
Installing pantsbuild.pants==2.7.0 into a virtual environment at /Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py39
created virtual environment CPython3.9.10.final.0-64 in 316ms
  creator CPython3Posix(dest=/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/alexstephen/Library/Application Support/virtualenv)
    added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Requirement already satisfied: pip in /Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages (21.1.2)
Collecting pip
  Using cached pip-22.0.3-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.1.2
    Uninstalling pip-21.1.2:
      Successfully uninstalled pip-21.1.2
Successfully installed pip-22.0.3
Collecting pantsbuild.pants==2.7.0
  Using cached pantsbuild.pants-2.7.0-cp39-cp39-macosx_11_0_arm64.whl (8.9 MB)
Collecting ansicolors==1.1.8
  Using cached ansicolors-1.1.8-py2.py3-none-any.whl (13 kB)
Collecting types-setuptools==57.0.0
  Using cached types_setuptools-57.0.0-py3-none-any.whl (4.8 kB)
Collecting typing-extensions==3.7.4.3
  Using cached typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting setproctitle==1.2.2
  Using cached setproctitle-1.2.2-cp39-cp39-macosx_12_0_arm64.whl
Collecting types-PyYAML==5.4.3
  Using cached types_PyYAML-5.4.3-py2.py3-none-any.whl (12 kB)
Collecting fasteners==0.16
  Using cached fasteners-0.16-py2.py3-none-any.whl (28 kB)
Collecting packaging==21.0
  Using cached packaging-21.0-py3-none-any.whl (40 kB)
Collecting toml==0.10.2
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting psutil==5.8.0
  Using cached psutil-5.8.0-cp39-cp39-macosx_12_0_arm64.whl
Collecting humbug==0.2.6
  Using cached humbug-0.2.6-py3-none-any.whl (11 kB)
Collecting pex==2.1.44
  Using cached pex-2.1.44-py2.py3-none-any.whl (2.6 MB)
Requirement already satisfied: setuptools<58.0,>=56.0.0 in /Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages (from pantsbuild.pants==2.7.0) (57.0.0)
Collecting PyYAML<5.5,>=5.4
  Using cached PyYAML-5.4.1-cp39-cp39-macosx_12_0_arm64.whl
Collecting types-toml==0.1.3
  Using cached types_toml-0.1.3-py2.py3-none-any.whl (2.1 kB)
Collecting ijson==3.1.4
  Using cached ijson-3.1.4-py3-none-any.whl
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting requests
  Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-3.0.7-py3-none-any.whl (98 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting charset-normalizer~=2.0.0
  Using cached charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Installing collected packages: typing-extensions, types-toml, types-setuptools, types-PyYAML, ijson, certifi, ansicolors, urllib3, toml, six, setproctitle, PyYAML, pyparsing, psutil, pex, idna, charset-normalizer, requests, packaging, fasteners, humbug, pantsbuild.pants
Successfully installed PyYAML-5.4.1 ansicolors-1.1.8 certifi-2021.10.8 charset-normalizer-2.0.12 fasteners-0.16 humbug-0.2.6 idna-3.3 ijson-3.1.4 packaging-21.0 pantsbuild.pants-2.7.0 pex-2.1.44 psutil-5.8.0 pyparsing-3.0.7 requests-2.27.1 setproctitle-1.2.2 six-1.16.0 toml-0.10.2 types-PyYAML-5.4.3 types-setuptools-57.0.0 types-toml-0.1.3 typing-extensions-3.7.4.3 urllib3-1.26.8
New virtual environment successfully created at /Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py39.
Traceback (most recent call last):
  File "/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/2.7.0_py39/bin/pants", line 5, in <module>
    from pants.bin.pants_loader import main
  File "/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 20, in <module>
    from pants.bin.pants_runner import PantsRunner
  File "/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages/pants/bin/pants_runner.py", line 11, in <module>
    from pants.base.exception_sink import ExceptionSink
  File "/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages/pants/base/exception_sink.py", line 15, in <module>
    import psutil
  File "/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages/psutil/__init__.py", line 121, in <module>
    from . import _psosx as _psplatform
  File "/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages/psutil/_psosx.py", line 15, in <module>
    from . import _psutil_osx as cext
ImportError: dlopen(/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried: '/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.lKbdWs/install/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_psutil_osx.cpython-39-darwin.so' (no such file), '/usr/lib/_psutil_osx.cpython-39-darwin.so' (no such file)
e

enough-analyst-54434

02/16/2022, 9:52 PM
Still seeing
Using cached ...
... hrm
Let me see if there is some advice I can give to unearth where the Pip cache is in this case - clearly it's not in
~/.cache/pip
!
It won't make a difference, but as an aside, you really should be bumping along on your stable release when you get chances to do so: https://pypi.org/project/pantsbuild.pants/2.7.2/
Yeah, when I nuke those dirs I see
Downloading ...
I'm on Linux with standard XDG_*, I'm not sure how Pip determines its cache dir though. Yours (or Macs) seems to be different.
So @creamy-monitor-52086 just to double check - do you have a
~/.cache/pip
directory with things in it after the failure? Are they owned by you?
c

creamy-monitor-52086

02/16/2022, 11:14 PM
I do not have a ~/.cache/pip folder
e

enough-analyst-54434

02/16/2022, 11:18 PM
Ok. Can you get your hands dirty? I'll poke around a bit more for docs online about this, but I don't have a mac.
Perhaps this will reveal useful info? Please provide all output:
Copy code
rm -rf ~/.cache/pants/setup
PIP_VERBOSE=3 ./pants -V
Try this:
Copy code
$ diff -u pants.orig pants
--- pants.orig	2022-02-16 15:22:43.904301410 -0800
+++ pants	2022-02-16 15:24:27.236192364 -0800
@@ -359,6 +359,7 @@
         "${python}" "${virtualenv_path}" --no-download "${staging_dir}/install" && \
         # Grab the latest pip, but don't advance setuptools past 58 which drops support for the
         # `setup` kwarg `use_2to3` which Pants 1.x sdist dependencies (pystache) use.
+        echo ">>> PIP Cache is here: $("${staging_dir}/install/bin/pip" cache dir)"
         "${staging_dir}/install/bin/pip" install -U pip "setuptools<58" && \
         "${staging_dir}/install/bin/pip" install ${maybe_find_links} --progress-bar off "${pants_requirement}"
       ) && \
$ rm -rf ~/.cache/pants/setup
$ ./pants -V 2>&1 | grep ">>> PIP"
>>> PIP Cache is here: /home/jsirois/.cache/pip
c

creamy-monitor-52086

02/16/2022, 11:34 PM
Here's the output from the first command
What do you want me to do for the next command? I'm seeing a diff, but I'm not sure what to do with it or where
e

enough-analyst-54434

02/16/2022, 11:35 PM
The diff is against the pants script at the root of your repo. You should be able to apply it with
patch
or else just add the line yourself since its only 1 line.
Ok, thans for the detailed log output. Your cache is here:
/Users/alexstephen/Library/Caches/pip
c

creamy-monitor-52086

02/16/2022, 11:43 PM
PIP Cache is here: /Users/alexstephen/Library/Caches/pip
e

enough-analyst-54434

02/16/2022, 11:43 PM
Can you try
rm -rf ~/Library/Caches/pip ~/.cache/pants/setup && PIP_VERBOSE=3 ./pants -V 2>&1 | tee output
? Thanks again.
c

creamy-monitor-52086

02/16/2022, 11:44 PM
It did a whole bunch of stuff and then eventually had the same error as before
e

enough-analyst-54434

02/16/2022, 11:47 PM
Can you please do exactly https://pantsbuild.slack.com/archives/C046T6T9U/p1645055031508629?thread_ts=1641937720.178900&amp;cid=C046T6T9U ? I know this is not fun, but I'm flying super-blind here without a mac of my own. You're my eyes.
c

creamy-monitor-52086

02/17/2022, 12:44 AM
Yeah, sorry about that!
Here's the output from that command
e

enough-analyst-54434

02/17/2022, 1:05 AM
Thanks.
So, its not a root cause, but check out these lines. Top from psutil build, bottom from setproctitle build:
Copy code
running build_ext
  building 'psutil._psutil_osx' extension
  creating build/temp.macosx-12-arm64-3.9
  creating build/temp.macosx-12-arm64-3.9/psutil
  creating build/temp.macosx-12-arm64-3.9/psutil/arch
  creating build/temp.macosx-12-arm64-3.9/psutil/arch/osx
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=580 -DPSUTIL_OSX=1 -I/opt/homebrew/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/sqlite/include -I/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.xAEECz/install/include -I/opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c psutil/_psutil_common.c -o build/temp.macosx-12-arm64-3.9/psutil/_psutil_common.o

Created temporary directory: /private/var/folders/tw/5yj9fblj2374tt4ntr11p7bc0000gn/T/pip-wheel-oipdj8sh
  Destination directory: /private/var/folders/tw/5yj9fblj2374tt4ntr11p7bc0000gn/T/pip-wheel-oipdj8sh
  Building wheel for setproctitle (pyproject.toml): started
  Running command Building wheel for setproctitle (pyproject.toml)
  running bdist_wheel
  running build
  running build_ext
  building 'setproctitle' extension
  creating build
  creating build/temp.macosx-12-arm64-3.9
  creating build/temp.macosx-12-arm64-3.9/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DSPT_VERSION=1.2.2 -D__darwin__=1 -I/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.xAEECz/install/include -I/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/setproctitle.c -o build/temp.macosx-12-arm64-3.9/src/setproctitle.o
Note the Python includes. For psutil:
Copy code
-I/Users/alexstephen/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.xAEECz/install/include
For setproctitle:
Copy code
-I/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/include/python3.9
So it looks like the psutil build is somehow thinking its being executed by an x86_64 interpreter whereas setproctitle is seeing the homebrew interpreter.
I don't know what to make of that, but that's a clear difference and a problematic one.
Oh wait, they both have each 😕
Nonetheless, we're failing to load psutil and I'd bet we'd also fail to load setproctitile. SO the issue is still there, but its everywhere. The interpreter being picked for the build is making distutils think this is x86_64. When Pants later runs, it thinks its arm64(e)
So, this looks like bootstrap picks one Python 3.9 interpreter and then runtime picks another - sort of. The thing is the wheel is built during bootstrap with an arm64 wheel tag, but, apparently, x86_64 guts.
r

rapid-bird-79300

03/11/2022, 12:18 AM
Hey quick update on this. @creamy-monitor-52086 got this resolved on M1 after running
rm -rf ~/Library/Caches/pip
👀 1
1
🤔 1
e

enough-analyst-54434

03/11/2022, 12:28 AM
Hrm. He tried exactly that up-thread and that failed. I'm glad it's working but ... I'm still clear as mud on what's going on here!
c

creamy-monitor-52086

03/11/2022, 1:43 AM
I also deleted + reinstalled pyenv as well as some other things. I'm assuming the pyenv reinstall is what fixed it. I don't think I deleted the pip cache after the pyenv reinstall
👍 2
5 Views