Xpra-org / xpra

Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.
https://xpra.org/
GNU General Public License v2.0
1.98k stars 169 forks source link

PEP 517 wheel build is broken since 6.0 #4263

Closed lazka closed 4 months ago

lazka commented 4 months ago

Describe the bug

See https://github.com/msys2/MINGW-packages/pull/21223

* Building wheel...
  Traceback (most recent call last):
    File "D:/M/msys64/clang64/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in <module>
      main()
    File "D:/M/msys64/clang64/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 357, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:/M/msys64/clang64/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 271, in build_wheel
      return _build_backend().build_wheel(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:/M/msys64/clang64/lib/python3.11/site-packages/setuptools/build_meta.py", line 410, in build_wheel
      return self._build_with_temp_dir(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:/M/msys64/clang64/lib/python3.11/site-packages/setuptools/build_meta.py", line 395, in _build_with_temp_dir
      self.run_setup()
    File "D:/M/msys64/clang64/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 35, in <module>
  ModuleNotFoundError: No module named 'xpra'

It seems xpra switched to setuptools.build_meta as a build backend in 1f47f7872eb2c3e1f91f96638251cacb10989f13, and previously used the default setuptools.build_meta:__legacy__ build backend (the one used if there is no pyproject.toml file). The main difference is that the new one doesn't add the current directory to sys.path.

Possible fixes:

To Reproduce

python -m build --no-isolation

System Information (please complete the following information):

Windows/MSYS2

totaam commented 4 months ago

Is there any reason you can't use python ./setup.py --with-XXXX --without-XXX instead? This is what we use on every platform: https://github.com/Xpra-org/xpra/tree/master/docs/Build Including the native MS Windows builds which use MSYS2 as base, so this should work.

I'm not too keen on supporting yet-another build system just yet, the Debian distros still don't work properly with setuptools: 5e4310545164718f68bc06835c7ea0964dd90117

But if all that is needed is to add this patch: sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) Sure, I can add that in. Is it enough?

lazka commented 4 months ago

Is there any reason you can't use python ./setup.py --with-XXXX --without-XXX instead?

Mainly because it is deprecated since 2021 (https://setuptools.pypa.io/en/stable/history.html#id601) and thus distros are slowly moving to the new way. I don't mind setup.py personally, and I doubt it will cease to work in the near future, but having setup.py work the same as "pip install" or "python -m build" is worthwhile imho.

But if all that is needed is to add this patch: sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) Sure, I can add that in. Is it enough?

Sure, I use the same workaround in one of my packages: https://github.com/quodlibet/mutagen/blob/f95d3ae19e25e3f0a91061566551843d799317c5/setup.py#L242

totaam commented 4 months ago

Applied! (and will backport to v6.x)

Mainly because it is deprecated since 2021

I may have missed something, but setuptools already made it harder to install non-python components in OS specific locations, and the last time I checked, the "new way" of buiding just can't do that any more - at all.

Which means that the all of the files from fs/ would need to be managed separately with the "new way". So forgive me if I am not enthusiastic about yet another packaging tool that feels like a downgrade. / End-of-rant

lazka commented 4 months ago

thanks!

yeah, I feel the pain. I was planing to move my complex setup.py using things to meson eventually (and have two build modes, one for system installs, one for wheels), but it's a lot of work.