uv icon indicating copy to clipboard operation
uv copied to clipboard

fails to find "Python.h", while pip works

Open wakamex opened this issue 1 year ago • 2 comments
trafficstars

regular command followed up by successful pip install

uv pip install pysha3==1.0.2       
Resolved 1 package in 24ms
error: Failed to download distributions
  Caused by: Failed to fetch wheel: pysha3==1.0.2
  Caused by: Failed to build: pysha3==1.0.2
  Caused by: Build backend failed to build wheel through `build_wheel()`:
--- stdout:
running bdist_wheel
running build
running build_py
running build_ext
building '_pysha3' extension
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DPY_WITH_KECCAK=1 -I/tmp/.tmpEtVDbK/.venv/include -I/usr/include/python3.10 -c Modules/_sha3/sha3module.c -o build/temp.linux-x86_64-cpython-310/Modules/_sha3/sha3module.o
--- stderr:
Modules/_sha3/sha3module.c:18:10: fatal error: Python.h: No such file or directory
   18 | #include "Python.h"
      |          ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
---
  Caused by: This error likely indicates that you need to install a library that provides "Python.h" for pysha3==1.0.2
pip install pysha3==1.0.2 
Collecting pysha3==1.0.2
  Using cached pysha3-1.0.2-cp310-cp310-linux_x86_64.whl
Installing collected packages: pysha3
Successfully installed pysha3-1.0.2

verbose command:

uv pip install pysha3==1.0.2 --verbose              
 uv::requirements::from_source source=pysha3==1.0.2
    0.002104s DEBUG uv_interpreter::virtual_env Found a virtualenv through VIRTUAL_ENV at: /home/mihai/.venvs/hbot
    0.002156s DEBUG uv_interpreter::interpreter Using cached markers for: /home/mihai/.venvs/hbot/bin/python
    0.002162s DEBUG uv::commands::pip_install Using Python 3.10.9 environment at /home/mihai/.venvs/hbot/bin/python
 uv_client::flat_index::from_entries 
 uv_resolver::resolver::solve 
      0.003335s   0ms DEBUG uv_resolver::resolver Solving with target Python version 3.10.9
   uv_resolver::resolver::choose_version package=root
   uv_resolver::resolver::get_dependencies package=root, version=0a0.dev0
        0.003390s   0ms DEBUG uv_resolver::resolver Adding direct dependency: pysha3==1.0.2
   uv_resolver::resolver::choose_version package=pysha3
     uv_resolver::resolver::package_wait package_name=pysha3
 uv_resolver::resolver::process_request request=Versions pysha3
   uv_client::registry_client::simple_api package=pysha3
     uv_client::cached_client::get_cacheable 
       uv_client::cached_client::read_and_parse_cache file=/home/mihai/.cache/uv/simple-v0/pypi/pysha3.rkyv
 uv_resolver::resolver::process_request request=Prefetch pysha3 ==1.0.2
          0.003798s   0ms DEBUG uv_client::cached_client Found fresh response for: https://pypi.org/simple/pysha3/
 uv_resolver::version_map::from_metadata 
   uv_distribution::distribution_database::get_or_build_wheel_metadata dist=pysha3==1.0.2
     uv_client::registry_client::wheel_metadata built_dist=pysha3==1.0.2
       uv_client::cached_client::get_serde 
         uv_client::cached_client::get_cacheable 
           uv_client::cached_client::read_and_parse_cache file=/home/mihai/.cache/uv/wheels-v0/pypi/pysha3/pysha3-1.0.2-cp33-cp33m-win32.msgpack
        0.004038s   0ms DEBUG uv_resolver::resolver Searching for a compatible version of pysha3 (==1.0.2)
        0.004045s   0ms DEBUG uv_resolver::resolver Selecting: pysha3==1.0.2 (pysha3-1.0.2-cp33-cp33m-win32.whl)
   uv_resolver::resolver::get_dependencies package=pysha3, version=1.0.2
     uv_resolver::resolver::distributions_wait package_id=pysha3-1.0.2
              0.004071s   0ms DEBUG uv_client::cached_client Found fresh response for: https://files.pythonhosted.org/packages/a8/30/81aa98538f91d039dc47191807bbdfadbc752df073cf624840e2677c7466/pysha3-1.0.2-cp33-cp33m-win32.whl
Resolved 1 package in 0ms
    0.004247s DEBUG uv_installer::plan Identified uncached requirement: pysha3 ==1.0.2
    0.004262s DEBUG uv_installer::plan Unnecessary package: pip==24.0
    0.004265s DEBUG uv_installer::plan Unnecessary package: setuptools==69.1.0
    0.004268s DEBUG uv_installer::plan Unnecessary package: wheel==0.42.0
 uv_installer::downloader::download total=1
   uv_installer::downloader::get_wheel name=pysha3==1.0.2, size=Some(829192), url="https://files.pythonhosted.org/packages/73/bf/978d424ac6c9076d73b8fdc8ab8ad46f98af0c34669d736b1d83c758afee/pysha3-1.0.2.tar.gz"
     uv_distribution::distribution_database::get_or_build_wheel dist=Source(Registry(RegistrySourceDist { filename: SourceDistFilename { name: PackageName("pysha3"), version: "1.0.2", extension: TarGz }, file: File { dist_info_metadata: None, filename: "pysha3-1.0.2.tar.gz", hashes: Hashes { md5: None, sha256: Some("fe988e73f2ce6d947220624f04d467faf05f1bbdbc64b0a201296bb3af92739e") }, requires_python: None, size: Some(829192), upload_time_utc_ms: Some(1486312928678), url: AbsoluteUrl("https://files.pythonhosted.org/packages/73/bf/978d424ac6c9076d73b8fdc8ab8ad46f98af0c34669d736b1d83c758afee/pysha3-1.0.2.tar.gz"), yanked: Some(Bool(false)) }, index: Pypi }))
       uv_client::cached_client::get_serde 
         uv_client::cached_client::get_cacheable 
           uv_client::cached_client::read_and_parse_cache file=/home/mihai/.cache/uv/built-wheels-v0/pypi/pysha3/1.0.2/manifest.msgpack
              0.004367s   0ms DEBUG uv_client::cached_client Found fresh response for: https://files.pythonhosted.org/packages/73/bf/978d424ac6c9076d73b8fdc8ab8ad46f98af0c34669d736b1d83c758afee/pysha3-1.0.2.tar.gz
       uv_distribution::source::build_source_dist 
            0.004393s   0ms DEBUG uv_distribution::source Building: pysha3==1.0.2
         uv_dispatch::setup_build package_id="pysha3==1.0.2", subdirectory=None
           uv_resolver::resolver::solve 
                0.005091s   0ms DEBUG uv_resolver::resolver Solving with target Python version 3.10.9
             uv_resolver::resolver::choose_version package=root
             uv_resolver::resolver::get_dependencies package=root, version=0a0.dev0
                  0.005114s   0ms DEBUG uv_resolver::resolver Adding direct dependency: setuptools>=40.8.0
                  0.005119s   0ms DEBUG uv_resolver::resolver Adding direct dependency: wheel*
             uv_resolver::resolver::choose_version package=setuptools
               uv_resolver::resolver::package_wait package_name=setuptools
           uv_resolver::resolver::process_request request=Versions setuptools
             uv_client::registry_client::simple_api package=setuptools
               uv_client::cached_client::get_cacheable 
                 uv_client::cached_client::read_and_parse_cache file=/home/mihai/.cache/uv/simple-v0/pypi/setuptools.rkyv
           uv_resolver::resolver::process_request request=Versions wheel
             uv_client::registry_client::simple_api package=wheel
               uv_client::cached_client::get_cacheable 
                 uv_client::cached_client::read_and_parse_cache file=/home/mihai/.cache/uv/simple-v0/pypi/wheel.rkyv
           uv_resolver::resolver::process_request request=Prefetch wheel *
           uv_resolver::resolver::process_request request=Prefetch setuptools >=40.8.0
                    0.005546s   0ms DEBUG uv_client::cached_client Found fresh response for: https://pypi.org/simple/wheel/
 uv_resolver::version_map::from_metadata 
                    0.005685s   0ms DEBUG uv_client::cached_client Found fresh response for: https://pypi.org/simple/setuptools/
 uv_resolver::version_map::from_metadata 
             uv_distribution::distribution_database::get_or_build_wheel_metadata dist=wheel==0.42.0
               uv_client::registry_client::wheel_metadata built_dist=wheel==0.42.0
                 uv_client::cached_client::get_serde 
                   uv_client::cached_client::get_cacheable 
                     uv_client::cached_client::read_and_parse_cache file=/home/mihai/.cache/uv/wheels-v0/pypi/wheel/wheel-0.42.0-py3-none-any.msgpack
                        0.006107s   0ms DEBUG uv_client::cached_client Found fresh response for: https://files.pythonhosted.org/packages/c7/c3/55076fc728723ef927521abaa1955213d094933dc36d4a2008d5101e1af5/wheel-0.42.0-py3-none-any.whl
             uv_distribution::distribution_database::get_or_build_wheel_metadata dist=setuptools==69.1.0
               uv_client::registry_client::wheel_metadata built_dist=setuptools==69.1.0
                 uv_client::cached_client::get_serde 
                   uv_client::cached_client::get_cacheable 
                     uv_client::cached_client::read_and_parse_cache file=/home/mihai/.cache/uv/wheels-v0/pypi/setuptools/setuptools-69.1.0-py3-none-any.msgpack
                  0.006226s   1ms DEBUG uv_resolver::resolver Searching for a compatible version of setuptools (>=40.8.0)
                  0.006231s   1ms DEBUG uv_resolver::resolver Selecting: setuptools==69.1.0 (setuptools-69.1.0-py3-none-any.whl)
             uv_resolver::resolver::get_dependencies package=setuptools, version=69.1.0
               uv_resolver::resolver::distributions_wait package_id=setuptools-69.1.0
                        0.006252s   0ms DEBUG uv_client::cached_client Found fresh response for: https://files.pythonhosted.org/packages/bb/0a/203797141ec9727344c7649f6d5f6cf71b89a6c28f8f55d4f18de7a1d352/setuptools-69.1.0-py3-none-any.whl
             uv_resolver::resolver::choose_version package=wheel
               uv_resolver::resolver::package_wait package_name=wheel
                  0.006322s   0ms DEBUG uv_resolver::resolver Searching for a compatible version of wheel (*)
                  0.006326s   0ms DEBUG uv_resolver::resolver Selecting: wheel==0.42.0 (wheel-0.42.0-py3-none-any.whl)
             uv_resolver::resolver::get_dependencies package=wheel, version=0.42.0
               uv_resolver::resolver::distributions_wait package_id=wheel-0.42.0
           uv_dispatch::install resolution="setuptools==69.1.0, wheel==0.42.0", venv="/tmp/.tmp3U6RAL/.venv"
                0.006370s   0ms DEBUG uv_dispatch Installing in setuptools==69.1.0, wheel==0.42.0 in /tmp/.tmp3U6RAL/.venv
                0.006424s   0ms DEBUG uv_installer::plan Requirement already cached: setuptools==69.1.0
                0.006447s   0ms DEBUG uv_installer::plan Requirement already cached: wheel==0.42.0
                0.006455s   0ms DEBUG uv_dispatch Installing build requirements: setuptools==69.1.0, wheel==0.42.0
             uv_installer::installer::install num_wheels=2
         uv_build::build package_id="pysha3==1.0.2"
              0.011171s   0ms DEBUG uv_build Calling `setuptools.build_meta:__legacy__.build_wheel(metadata_directory=None)`
           uv_build::run_python_script script="build_wheel", python_version=3.10.9
error: Failed to download distributions
  Caused by: Failed to fetch wheel: pysha3==1.0.2
  Caused by: Failed to build: pysha3==1.0.2
  Caused by: Build backend failed to build wheel through `build_wheel()`:
--- stdout:
running bdist_wheel
running build
running build_py
running build_ext
building '_pysha3' extension
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DPY_WITH_KECCAK=1 -I/tmp/.tmp3U6RAL/.venv/include -I/usr/include/python3.10 -c Modules/_sha3/sha3module.c -o build/temp.linux-x86_64-cpython-310/Modules/_sha3/sha3module.o
--- stderr:
Modules/_sha3/sha3module.c:18:10: fatal error: Python.h: No such file or directory
   18 | #include "Python.h"
      |          ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
---
  Caused by: This error likely indicates that you need to install a library that provides "Python.h" for pysha3==1.0.2

wakamex avatar Feb 17 '24 08:02 wakamex

Hi! It looks like pip is using a cached wheel

pip install pysha3==1.0.2 
Collecting pysha3==1.0.2
  Using cached pysha3-1.0.2-cp310-cp310-linux_x86_64.whl

whereas we do not have access to the pip cache and are attempting to build the wheel. Does pip succeed with caching disabled?

zanieb avatar Feb 17 '24 19:02 zanieb

Here's pip's output on my machine

❯ pip install pysha3==1.0.2
Collecting pysha3==1.0.2
  Downloading pysha3-1.0.2.tar.gz (829 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 829.2/829.2 kB 11.7 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pysha3
  Building wheel for pysha3 (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pysha3 (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-14.0-arm64-cpython-312
      copying sha3.py -> build/lib.macosx-14.0-arm64-cpython-312
      running build_ext
      building '_pysha3' extension
      creating build/temp.macosx-14.0-arm64-cpython-312
      creating build/temp.macosx-14.0-arm64-cpython-312/Modules
      creating build/temp.macosx-14.0-arm64-cpython-312/Modules/_sha3
      clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -DPY_WITH_KECCAK=1 -I/Users/mz/.pyenv/versions/3.12.0/include/python3.12 -c Modules/_sha3/sha3module.c -o build/temp.macosx-14.0-arm64-cpython-312/Modules/_sha3/sha3module.o
      In file included from Modules/_sha3/sha3module.c:20:
      Modules/_sha3/backport.inc:78:10: fatal error: 'pystrhex.h' file not found
      #include "pystrhex.h"
               ^~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pysha3
Failed to build pysha3

zanieb avatar Feb 17 '24 19:02 zanieb

looks like I was missing python development headers on this machine. solved by:

>> sudo dnf install python3.10-devel

wakamex avatar Apr 11 '24 20:04 wakamex