indygreg / python-zstandard

Python bindings to the Zstandard (zstd) compression library
BSD 3-Clause "New" or "Revised" License
499 stars 86 forks source link

build: fix building with modern setuptools backend #206

Closed mgorny closed 11 months ago

mgorny commented 11 months ago

Set correct sys.path prior to importing setup_zstd, in order to fix building with the modern setuptools backend, i.e.:

* Getting build dependencies for wheel...
<string>:37: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
<string>:38: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
    main()
  File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
    return hook(config_settings)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-mgz__6r4/lib/python3.12/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-mgz__6r4/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
    self.run_setup()
  File "/tmp/build-env-mgz__6r4/lib/python3.12/site-packages/setuptools/build_meta.py", line 341, in run_setup
    exec(code, locals())
  File "<string>", line 49, in <module>
ModuleNotFoundError: No module named 'setup_zstd'

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel
mgorny commented 11 months ago

Thanks. I wasn't sure if there weren't other problems forcing the legacy backend, so I didn't include that.