Actually, after using `file` to check the binary, ...
# general
g
Actually, after using
file
to check the binary, it was in fact
x86_64
- I get the same error with
arm64
. Has anyone seen this with python3.12 on MacOS, or have any ideas for troubleshooting? The interpreter seems to be working fine when used directly.
I found one issue, which was broken SSL support in the environment, causing an ImportError when pants tried to use the interpreter. I'm now stuck on this error when trying to get the interpreter to be recognized:
Copy code
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/Users/lilyhahn/.cache/pants/named_caches/pex_root/isolated/3754108aac57ec0c996f3414782585924aee601c/pex/atomic_directory.py", line 23, in <module>
    from pex.third_party import attr
ImportError: cannot import name 'attr' from 'pex.third_party' (/Users/lilyhahn/.cache/pants/named_caches/pex_root/isolated/3754108aac57ec0c996f3414782585924aee601c/pex/third_party/__init__.py)
It appears to work fine on Cpython==3.11.*
b
Sorry for the trouble! Which version of pants? What’s in your pants.toml? I’m on phone so can’t check the details, but I believe the PEX project only added support for 3.12 relatively recently, so older versions of pants might use a version of pex by default that doesn’t have support. One can manually upgrade… but let’s work out the details firsts
g
Hi Huon, thanks for the response! This is using pants 2.18.0. My pants.toml:
Copy code
[GLOBAL]
pants_version = "2.18.0"
backend_packages.add = [
  # "pants.backend.awslambda.python",
  "pants.backend.docker",
  "pants.backend.docker.lint.hadolint",  
  "pants.backend.python",
  "pants.backend.python.lint.autoflake",
  "pants.backend.python.lint.pyupgrade",
  "pants.backend.python.lint.black",
  "pants.backend.python.lint.flake8",
  "pants.backend.python.lint.isort",
  "pants.backend.python.lint.docformatter",
  # "pants.backend.python.lint.bandit",
  "pants.backend.python.lint.pylint",
  "pants.backend.python.typecheck.mypy",
  "pants.backend.shell",
  "pants.backend.shell.lint.shellcheck",
  "pants.backend.shell.lint.shfmt",
]
[python]
interpreter_constraints = ["==3.11.*"]
enable_resolves = true

[python.resolves]
pylint = "3rdparty/python/pylint.lock"
python-default = "3rdparty/python/default.lock"

[python.resolves_to_no_binary]
python-default = ["pyspark"]
Also, another issue I came across, the default resolve for
pylint
seems to come across all sorts of issues with
no-member
false positives on builtin modules like
os
and
abc
when used with 3.11. It looks like it's using an outdated version of pylint which doesn't support newer versions of Python. I managed to fix it by creating a resolve which specified
pylint>=3.0.0
.
👍 1
b
Ah okay, it looks like Pants 2.18 uses pex 2.1.134 (https://www.pantsbuild.org/docs/reference-pex-cli#version), but Python 3.12 support was added in https://github.com/pantsbuild/pex/releases/tag/v2.1.139 You can tell pants to use a newer version manually by the values for that subsystem manually (I'd suggest choosing the latest version https://github.com/pantsbuild/pex/releases/tag/v2.1.154):
Copy code
[pex-cli]
version = "2.1.154"
known_versions = [
   "..."
]
You'll have to reproduce an appropriate known versions value. One way is using the existing one as inspiration, and changing by downloading the
pex
file from that release and computing the hash and length and using that to fill out the four rows per platform (same for every platform, the
pex
file is universal)
h
@gray-quill-76268 if you get this to work and want to send a PR to upgrade the default version of Pex that Pants uses, that would be much appreciated!
b
(I think the upcoming Pants 2.19 uses 2.1.148 by default)