Skip to content

Add support for Python 3.12 #725

@PacificGilly

Description

@PacificGilly

Issue summary

In Python 3.12, there are numerous changes low-level changes that were implemented. The most important was PEP-632. This seems to impact transient packages like PyYaml for versions <=6.0.0 (see below for stacktrace). By forcing the PyYaml dependency for PY3.12 implementations to use 6.0.1 or later resolves the issue.

Expected behavior

Installing the shopify API library builds successfully

Actual behavior

The build fails to install if its coupled with PyYaml 6.0.0 or earlier. The following stacktrace is raised:

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel
  
  running egg_info
  writing lib/PyYAML.egg-info/PKG-INFO
  writing dependency_links to lib/PyYAML.egg-info/dependency_links.txt
  writing top-level names to lib/PyYAML.egg-info/top_level.txt
  Traceback (most recent call last):
    File "/home/circleci/.local/share/pypoetry/venv/lib/python****/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/circleci/.local/share/pypoetry/venv/lib/python****/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/circleci/.local/share/pypoetry/venv/lib/python****/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
             ^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
      self.run_setup()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 288, in <module>
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/__init__.py", line 103, in setup
      return distutils.core.setup(**attrs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/_distutils/core.py", line 184, in setup
      return run_commands(dist)
             ^^^^^^^^^^^^^^^^^^
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
      dist.run_commands()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
      self.run_command(cmd)
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/dist.py", line 968, in run_command
      super().run_command(command)
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/command/egg_info.py", line 321, in run
      self.find_sources()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/command/egg_info.py", line 329, in find_sources
      mm.run()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/command/egg_info.py", line 550, in run
      self.add_defaults()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/command/egg_info.py", line 588, in add_defaults
      sdist.add_defaults(self)
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/command/sdist.py", line 102, in add_defaults
      super().add_defaults()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/_distutils/command/sdist.py", line 250, in add_defaults
      self._add_defaults_ext()
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/_distutils/command/sdist.py", line 335, in _add_defaults_ext
      self.filelist.extend(build_ext.get_source_files())
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<string>", line 204, in get_source_files
    File "/tmp/tmplgj9ejjh/.venv/lib/python****/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
      raise AttributeError(attr)
  AttributeError: cython_sources
  

  at ~/.local/share/pypoetry/venv/lib/python****/site-packages/poetry/installation/chef.py:164 in _prepare
      160│ 
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│ 
      163│             if error is not None:
    → 164│                 raise error from None
      165│ 
      166│             return path
      167│ 
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with pyyaml (6.0) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "pyyaml (==6.0)"'.

Steps to reproduce the problem

  1. In a virtual env, install any PY 3.12 version
  2. Install shopify python API library and (if not force PyYaml 6.0.0 or lower)
  3. Observe how the shopify library fails to build and install.

Solution

Simply use dependency pin (using PEP 508 standards) for PY3.12 to install PyYaml >6.0.0 and for <PY3.12 leave unpinned, as it currently is specified in the setup.py file.

I'm happy to raise a quick PR to remedy this issue to finally add support for PY3.12 to this library

Checklist

  • I have described this issue in a way that is actionable (if possible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions