wlav / cppyy-backend

23 stars 27 forks source link

Can't install `cppyy-backend` 1.15.1 from PyPI as `--user` for Python 3.12 on Fedora 39 #19

Closed torokati44 closed 8 months ago

torokati44 commented 8 months ago

When running the following command, I get the error below.

$ python3 -m pip install --user --upgrade cppyy-backend

Collecting cppyy-backend
  Using cached cppyy-backend-1.15.1.tar.gz (35 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting cppyy-cling==6.30.0 (from cppyy-backend)
  Obtaining dependency information for cppyy-cling==6.30.0 from https://files.pythonhosted.org/packages/bc/de/8e15b32bb34f8726fa2cf9e2efcfb1b64b476aef482ac30d8023146e3caf/cppyy_cling-6.30.0-py2.py3-none-manylinux2014_x86_64.whl.metadata
  Using cached cppyy_cling-6.30.0-py2.py3-none-manylinux2014_x86_64.whl.metadata (2.0 kB)
Using cached cppyy_cling-6.30.0-py2.py3-none-manylinux2014_x86_64.whl (42.2 MB)
Building wheels for collected packages: cppyy-backend
  Building wheel for cppyy-backend (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for cppyy-backend (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [38 lines of output]
      running bdist_wheel
      running build
      running build_ext
      checking for build/temp.linux-x86_64-cpython-312
      creating build/temp.linux-x86_64-cpython-312
      creating build/temp.linux-x86_64-cpython-312/src
      gcc -fno-strict-overflow -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -fcf-protection -fexceptions -fcf-protection -fexceptions -fcf-protection -fexceptions -fPIC -I/tmp/pip-build-env-85x0u7o0/overlay/lib/python3.12/site-packages/cppyy_backend/include -I/usr/include/python3.12 -c src/clingwrapper.cxx -o build/temp.linux-x86_64-cpython-312/src/clingwrapper.o -O2 -pthread -std=c++2a -m64
      now building libcppyy_backend.so
      creating build/lib.linux-x86_64-cpython-312
      creating build/lib.linux-x86_64-cpython-312/cppyy_backend
      creating build/lib.linux-x86_64-cpython-312/cppyy_backend/lib
      g++ -shared build/temp.linux-x86_64-cpython-312/src/clingwrapper.o -L/usr/lib64 -o build/lib.linux-x86_64-cpython-312/cppyy_backend/lib/libcppyy_backend.so -Wl,-Bsymbolic-functions
      installing to build/bdist.linux-x86_64/wheel
      running install
      running install_lib
      creating build/bdist.linux-x86_64
      creating build/bdist.linux-x86_64/wheel
      creating build/bdist.linux-x86_64/wheel/cppyy_backend-1.15.1.data
      creating build/bdist.linux-x86_64/wheel/cppyy_backend-1.15.1.data/platlib
      creating build/bdist.linux-x86_64/wheel/cppyy_backend-1.15.1.data/platlib/cppyy_backend
      creating build/bdist.linux-x86_64/wheel/cppyy_backend-1.15.1.data/platlib/cppyy_backend/lib
      copying build/lib.linux-x86_64-cpython-312/cppyy_backend/lib/libcppyy_backend.so -> build/bdist.linux-x86_64/wheel/cppyy_backend-1.15.1.data/platlib/cppyy_backend/lib
      running install_egg_info
      running egg_info
      writing cppyy_backend.egg-info/PKG-INFO
      writing dependency_links to cppyy_backend.egg-info/dependency_links.txt
      writing requirements to cppyy_backend.egg-info/requires.txt
      writing top-level names to cppyy_backend.egg-info/top_level.txt
      reading manifest file 'cppyy_backend.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE.txt'
      writing manifest file 'cppyy_backend.egg-info/SOURCES.txt'
      Copying cppyy_backend.egg-info to build/bdist.linux-x86_64/wheel/cppyy_backend-1.15.1.data/platlib/cppyy_backend-1.15.1-py3.12.egg-info
      running install_scripts
      Now installing cppyy_backend
      Copying installation to: /usr/local/lib/python3.12/site-packages ...
      creating /usr/local/lib/python3.12
      error: could not create '/usr/local/lib/python3.12': Permission denied
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cppyy-backend
Failed to build cppyy-backend
ERROR: Could not build wheels for cppyy-backend, which is required to install pyproject.toml-based projects
WARNING: There was an error checking the latest version of pip.

The three lines before [end of output] are a bit sus, why is it trying to copy anything into anywhere else other than ~/.local/lib/python3.12/site-packages/ when --user is passed in?

torokati44 commented 8 months ago

https://github.com/wlav/cppyy/issues/191 is possibly related.

wlav commented 8 months ago

191 is supposed to be fixed by 1.15.1, you can try installing 1.15.0 to see whether that fix is the cause of the problem (1.15.0's installation is the same as 1.14.x):

python3 -m pip install --user --upgrade cppyy-backend==1.15.0

The difference between .1 and .0 is that the former makes sure that cppyy-cling and cppyy-backend install in the same location, otherwise loader.py can not find cppyy_backend.so (that's the issue in #191): Fedora seems to be one of the few platforms that have a different purelib from platlib; on most other installations, they're the same.

All that said ... cppyy-backend uses PEP517, meaning that the installation works by creating a wheel in a separated build environment, followed by pip installing from that wheel. Wheels do not have absolute locations, but rather have placeholders at the start of the directories, such as "platlib" and "purelib" that are then filled in from Python's sysconfig. By design then, cppyy-backend thus does not control the final installation, that's up to pip.

For your platform, what do these show:

$ python -c 'import sysconfig; print(sysconfig.get_paths()["platlib"])'
$ python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'

And what does the wheel have:

$ unzip -l `python -m pip cache list cppyy_backend --format=abspath |& grep 1.15.1`
torokati44 commented 8 months ago

python3 -m pip install --user --upgrade cppyy-backend==1.15.0

This worked, thank you!

The command outputs you asked for:

attila ~ $ python -c 'import sysconfig; print(sysconfig.get_paths()["platlib"])'
/usr/local/lib64/python3.12/site-packages
attila ~ $ python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
/usr/local/lib/python3.12/site-packages

python3 -m pip cache list cppyy_backend --format=abspath does not list 1.15.1 for some reason.

wlav commented 8 months ago

I'm able to reproduce it now: when not in a virtual environment, then the temporary copy to the alternative path during build of the wheel goes into /usr/local/lib. Will fix and re-release shortly.

torokati44 commented 8 months ago

Great, thank you!

wlav commented 8 months ago

3.1.2 should have this fixed.

torokati44 commented 8 months ago

Can confirm, python3 -m pip install --user --upgrade cppyy-backend==1.15.2 and python3 -m pip install --user --upgrade cppyy==3.1.2 works again! Your quick response is much appreciated!