Skip to content

scikit-build-core imports incorrect version of packaging when performing global install on Ubuntu 22.04 #1190

@gareth-lyte

Description

@gareth-lyte

I have an environment in which I need to install a python package globally. I realize this is not a recommended pattern, but unfortunately for now it is unavoidable:

My configuration is as follows:

  • OS: Ubuntu 22.04.5
  • Python: 3.10
  • sciki-build-core: 0.11.6

My pyproject.toml looks like the following:

[project]
name = "foo"
version = "0.0.1"
requires-python = ">=3.10"
authors = [{ name = "Foo", email = "[email protected]" }]
description = "Lorem Ipsum"
license = { text = "UNLICENSED" }
readme = "README.md"
keywords = []
classifiers = []
dependencies = ["numpy"]

[build-system]
requires = [
    "scikit-build-core==0.11.6",
    "nanobind>=2.9.1",
]
build-backend = "scikit_build_core.build"

[tool.scikit-build]
cmake.version = ">=3.20,<4"
cmake.args = [
    "-Wno-deprecated",
    "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
]
cmake.build-type = "RelWithDebInfo"
ninja.version = ">=1.5"
logging.level = "INFO"
wheel.packages = []
wheel.license-files = []
build.verbose = true

When running pip install . -vv (using the system wide pip), I encounter the following error:

Defaulting to user installation because normal site-packages is not writeable                                                                                                                                    
Processing <...>                                                                                                                     
  Installing build dependencies ... done                                                                                                                                                                         
  Getting requirements to build wheel ... done                                                                                                                                                                   
  Preparing metadata (pyproject.toml) ... error                                                                                                                                                                  
  error: subprocess-exited-with-error                                                                                                                                                                            
                                                                                                                                                                                                                 
  × Preparing metadata (pyproject.toml) did not run successfully.                                                                                                                                                
  │ exit code: 1                                                                                                                                                                                                 
  ╰─> [30 lines of output]
      Traceback (most recent call last):
        File "/tmp/pip-build-env-qw9lltm1/overlay/local/lib/python3.10/dist-packages/scikit_build_core/_vendor/pyproject_metadata/__init__.py", line 515, in validate
          packaging.utils.canonicalize_name(self.name, validate=True)
      TypeError: canonicalize_name() got an unexpected keyword argument 'validate'

Diagnostic steps

So far I have established the following:

  • The build overlay has packaging 25.0, which has the correct function signature for canonicalize_name.
  • The system itself has two copies of packaging:

One in /usr/local/lib/python3.10/dist-packages/, which has the correct signature:

$ cat /usr/local/lib/python3.10/dist-packages/packaging/utils.py | grep canonicalize_name
def canonicalize_name(name: str, *, validate: bool = False) -> NormalizedName:

And another in /usr/lib/python3/dist-packages which does not:

$ cat /usr/lib/python3/dist-packages/packaging/utils.py | grep canonicalize_name
def canonicalize_name(name: str) -> NormalizedName:

It would appear like scikit-build-core ends up importing the version from /usr/lib/python3/dist-packages, which is incompatible.

Expected behavior:

I realize on some level the answer to my question is "do not use global package installs". That being said, I would have hoped in this instance that scikit-build-core would import the version of packaging in the build overlay (which is the correct version).

Any insights you might have would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions