I'm running into an error when using the `package`...
# general
i
I'm running into an error when using the
package
goal on a project that has CPython>=3.6.* as an interpreter constraint (pants 2.11). Has anyone else experienced this issue? (Note: [setuptools.lockfile] is set to
"<none>"
)
Copy code
File "/Users/KHowa8/.pyenv/versions/3.7.13/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Full stack trace
Copy code
➜  monorepo git:(developer-tooling/pants-upgrade) ✗ ./pantsv2 package products/datalogue/dtl-python-sdk:dist
08:48:50.76 [INFO] Initializing scheduler...
08:48:50.83 [INFO] Scheduler initialized.
08:48:55.79 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Run setuptools.build_meta:__legacy__ for products/datalogue/dtl-python-sdk:dist' failed with exit code 1.
stdout:

stderr:
Traceback (most recent call last):
  File "/private/var/folders/qs/501mdfv5309fbjv3wxcln9gw0000gp/T/process-executionFKQeX2/chroot/../.cache/pex_root/venvs/0621634ca5ceb222971326822525fc4b02f719c6/82b4909efecc2bbe750b1ca2cb66a81ec429d15a/pex", line 166, in <module>
    exec(ast, globals_map, locals_map)
  File "backend_shim.py", line 4, in <module>
    import setuptools.build_meta
  File "/Users/KHowa8/.cache/pants/named_caches/pex_root/venvs/s/e5a3085f/venv/lib/python3.7/site-packages/setuptools/__init__.py", line 18, in <module>
    from setuptools.dist import Distribution
  File "/Users/KHowa8/.cache/pants/named_caches/pex_root/venvs/s/e5a3085f/venv/lib/python3.7/site-packages/setuptools/dist.py", line 38, in <module>
    from setuptools import windows_support
  File "/Users/KHowa8/.cache/pants/named_caches/pex_root/venvs/s/e5a3085f/venv/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in <module>
    import ctypes
  File "/Users/KHowa8/.pyenv/versions/3.7.13/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'



Use `--no-process-cleanup` to preserve process chroots for inspection.
h
e
Note ctypes is a standard lib package (even if you don't know that, note it is not in site-packages above). This means your pyenv 3.7.13 interpreter install is broken.
👍 1
i
right. This might be a "my machine" problem since i'm on an M1 mac and can't use anything less than Python 3.9
I'll see if I can get this running in CI.
h
Ah, I have to use Py39 for anything to work too. I set that in
.pants.rc
config file https://www.pantsbuild.org/docs/options#pantsrc-file
i
whoops..
pyenv uninstall 3.7.13
fixed that issue. Now I'm onto this one:
Copy code
09:52:30.95 [ERROR] 1 Exception encountered:

  ProcessExecutionFailure: Process 'Run setuptools.build_meta:__legacy__ for products/datalogue/dtl-python-sdk:dist' failed with exit code 1.
stdout:

stderr:
../build_backend.pex_pex_shim.sh: /private/var/folders/qs/501mdfv5309fbjv3wxcln9gw0000gp/T/process-executionrvxpZ6/chroot/../.cache/pex_root/venvs/0621634ca5ceb222971326822525fc4b02f719c6/82b4909efecc2bbe750b1ca2cb66a81ec429d15a/pex: /Users/KHowa8/.cache/pants/named_caches/pex_root/venvs/s/e5a3085f/venv/bin/pyt: bad interpreter: No such file or directory
../build_backend.pex_pex_shim.sh: line 54: /private/var/folders/qs/501mdfv5309fbjv3wxcln9gw0000gp/T/process-executionrvxpZ6/chroot/../.cache/pex_root/venvs/0621634ca5ceb222971326822525fc4b02f719c6/82b4909efecc2bbe750b1ca2cb66a81ec429d15a/pex: Undefined error: 0



Use `--no-process-cleanup` to preserve process chroots for inspection.
@hundreds-father-404 I did use the pants.rc file which the project overrides the constraints, so not sure how to handle that.
FYI I was able to get the package command working in CI. It's a "my machine" issue that I'll work out later.
h
hmmm, I'm not sure what that is -- maybe try
mv ~/.cache/pants ~/cache/pants_old
-- it could be a corrupt cache?
i
@hundreds-father-404 yep!
Copy code
➜  monorepo git:(developer-tooling/pants-upgrade) ./pantsv2 package products/datalogue/dtl-python-sdk:dist
Bootstrapping Pants using /Users/KHowa8/.pyenv/shims/python3.9
Creating the virtualenv PEX.
Downloading the Pex PEX.
SHA256 fingerprint of <https://github.com/pantsbuild/pex/releases/download/v2.1.62/pex> verified.
Installing pantsbuild.pants==2.11.0 into a virtual environment at /Users/KHowa8/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0_py39
New virtual environment successfully created at /Users/KHowa8/.cache/pants/setup/bootstrap-Darwin-arm64/2.11.0_py39.
11:36:55.78 [INFO] Initializing scheduler...
11:36:55.86 [INFO] Scheduler initialized.
11:37:05.38 [INFO] Completed: Building build_backend.pex with 2 requirements: setuptools>=50.3.0,<58.0, wheel>=0.35.1,<0.38
11:37:06.04 [INFO] Wrote dist/datalogue-dev-build.tar.gz
11:37:06.04 [INFO] Wrote dist/datalogue-dev_build-py3-none-any.whl
h
Okay great! If you're willing to keep the old cache around until we hear back here...@enough-analyst-54434 would it help to have a copy of the cache?
i
I've got it if you want it
👍 1
e
I don't think we need to see the cache. You should expect any venv that was built from a Python you later remove to fail. Python venvs are not hermetic. Various bits depending on the venv technology (-mvenv or virtualenv) will link back to the original interpreter.
👍 2