Skip to content

Commit

Permalink
build: fix building with modern setuptools backend
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
mgorny authored and indygreg committed Nov 3, 2023
1 parent 45f2337 commit 1dc0596
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
except ImportError:
cffi = None

sys.path.insert(0, ".")

import setup_zstd

SUPPORT_LEGACY = False
Expand Down

0 comments on commit 1dc0596

Please sign in to comment.