Has anyone had any success working with Python 3.1...
# general
e
Has anyone had any success working with Python 3.12 (removal of distutils)? I set my interpreter constraints to "==3.12.*" when setting up a project, and linting works great, but I can't get testing to work
1
In particular, its on trying to build a 3rd party wheel (for pendulum) that I can't seem to get working
b
We use Python 3.12 and while we don’t use Pendulum directly, there are other libraries that use it as a transitive dependency. What’s the issue that you’re facing?
e
(I'm still new to pants/pex in general, so may be making some wrong assumptions or something here) It seems like anything I try to do that actually involves building a pex eventually leads to needing to build a wheel from pendulum, and it fails when it (eventually) tries to import distutils
b
Do you have a specific error message / stack trace? That may be helpful to understand what part of the build process is failing
e
Copy code
stderr:
pid 14567 -> /home/luke/.cache/pants/named_caches/pex_root/venvs/ef6da4495b7a47865ca7911770eef7a0a15270f6/0de1795ad4486f45ee94cecd983e9905b6b11dc9/bin/python -sE /home/luke/.cache/pants/named_caches/pex_root/venvs/ef6da4495b7a47865ca7911770eef7a0a15270f6/0de1795ad4486f45ee94cecd983e9905b6b11dc9/pex --disable-pip-version-check --no-python-version-warning --exists-action a --no-input --isolated -q --cache-dir /home/luke/.cache/pants/named_caches/pex_root/pip/24.0/pip_cache wheel --no-deps --wheel-dir /home/luke/.cache/pants/named_caches/pex_root/built_wheels/sdists/pendulum-2.1.2.tar.gz/b06a0ca1bfe41c990bbf0c029f0b6501a7f2ec4e38bfec730712015e8860f207/cp312-cp312-manylinux_2_39_x86_64.0fa0cdeeea05490f944877a40c098be8.work /home/luke/.cache/pants/named_caches/pex_root/downloads/b06a0ca1bfe41c990bbf0c029f0b6501a7f2ec4e38bfec730712015e8860f207/pendulum-2.1.2.tar.gz --index-url <https://pypi.org/simple/> --extra-index-url <https://223067015:AKCp8nzWdDFwNWLVBMqvtsWQt1MSnpapyU1r1ALqS94cyiCuk37ev2TZFSQeThYC91XGKb4Ma@dig-grid-artifactory.apps.ge.com/artifactory/api/pypi/opus-one-pypi-virtual/simple> --retries 5 --timeout 15 exited with 1 and STDERR:
  error: subprocess-exited-with-error
  
  × Building wheel for pendulum (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      Traceback (most recent call last):      
File "/home/luke/.cache/pants/named_caches/pex_root/pip/24.0/pip_cache/.tmp/pip-req-build-log3f7ll/build.py", line 5, in <module>
          from distutils.command.build_ext import build_ext
      ModuleNotFoundError: No module named 'distutils'
      Traceback (most recent call last):
        File "/home/luke/.cache/pants/named_caches/pex_root/venvs/ef6da4495b7a47865ca7911770eef7a0a15270f6/0de1795ad4486f45ee94cecd983e9905b6b11dc9/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/luke/.cache/pants/named_caches/pex_root/venvs/ef6da4495b7a47865ca7911770eef7a0a15270f6/0de1795ad4486f45ee94cecd983e9905b6b11dc9/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/luke/.cache/pants/named_caches/pex_root/venvs/ef6da4495b7a47865ca7911770eef7a0a15270f6/0de1795ad4486f45ee94cecd983e9905b6b11dc9/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/luke/.cache/pants/named_caches/pex_root/pip/24.0/pip_cache/.tmp/pip-build-env-lokhfo5r/overlay/lib/python3.12/site-packages/poetry/core/masonry/api.py", line 58, in build_wheel
          return WheelBuilder.make_in(
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/home/luke/.cache/pants/named_caches/pex_root/pip/24.0/pip_cache/.tmp/pip-build-env-lokhfo5r/overlay/lib/python3.12/site-packages/poetry/core/masonry/builders/wheel.py", line 88, in make_in
          wb.build(target_dir=directory)
        File "/home/luke/.cache/pants/named_caches/pex_root/pip/24.0/pip_cache/.tmp/pip-build-env-lokhfo5r/overlay/lib/python3.12/site-packages/poetry/core/masonry/builders/wheel.py", line 123, in build
          self._build(zip_file)
        File "/home/luke/.cache/pants/named_caches/pex_root/pip/24.0/pip_cache/.tmp/pip-build-env-lokhfo5r/overlay/lib/python3.12/site-packages/poetry/core/masonry/builders/wheel.py", line 172, in _build
          self._run_build_script(self._package.build_script)
        File "/home/luke/.cache/pants/named_caches/pex_root/pip/24.0/pip_cache/.tmp/pip-build-env-lokhfo5r/overlay/lib/python3.12/site-packages/poetry/core/masonry/builders/wheel.py", line 262, in _run_build_script
          subprocess.check_call([self.executable.as_posix(), build_script])
        File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/home/luke/.cache/pants/named_caches/pex_root/venvs/ef6da4495b7a47865ca7911770eef7a0a15270f6/0de1795ad4486f45ee94cecd983e9905b6b11dc9/bin/python', 'build.py']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pendulum
ERROR: Failed to build one or more wheels
b
Looks like Pendulum 2.x is not compatible with Python 3.12: https://github.com/sdispater/pendulum/issues/696 This is caused by the deprecation of distutils: https://peps.python.org/pep-0632/ You’ll probably have to update Pendulum to 3.x to get rid of the distutils dependency, or use Python 3.11 until your application is ready to upgrade Pendulum
We are using Pendulum 3.0.0, which is why we’re able to make it work with Python 3.12
e
aah, that's a surprising dependency. I guess I didn't do my research. Thanks!