NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.13k stars 14.17k forks source link

Build failure: setuptools for python39 #353830

Open Antares0982 opened 1 week ago

Antares0982 commented 1 week ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix develop with dev shell:
    {pkgs ? import <nixpkgs> { }}:let
    myPython = pkgs.python39;
    myPythonWithPackages = myPython.withPackages (pypkgs: with pypkgs; [setuptools]);
    in
    pkgs.mkShell {
    packages = [
    myPythonWithPackages
    ];
    }

Build log

Sourcing python-remove-tests-dir-hook
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing pypa-build-hook
Using pypaBuildPhase
Sourcing python-runtime-deps-check-hook
Using pythonRuntimeDepsCheckHook
Sourcing pypa-install-hook
Using pypaInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing python-namespaces-hook
Sourcing python-catch-conflicts-hook.sh
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/ih3kgq60qawa8a0r5y0fiaps9g491pv0-source
source root is source
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/tox.ini
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
applying patch /nix/store/1m3fp3vq2w7hv5y2slpd2kqni73i9a4w-tag-date.patch
patching file setup.cfg
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
no configure script, doing nothing
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Executing pypaBuildPhase
Creating a wheel...
* Getting build dependencies for wheel...
/build/source/setuptools/config/pyprojecttoml.py:71: _ExperimentalConfiguration: `[tool.distutils]` in `pyproject.toml` is still *experimental* and likely to change in future releases.
  config = read_configuration(filepath, True, ignore_option_errors, dist)
running egg_info
creating setuptools.egg-info
Traceback (most recent call last):
  File "/build/source/setuptools/_vendor/importlib_metadata/compat/py39.py", line 19, in normalized_name
    return dist._normalized_name
AttributeError: 'PathDistribution' object has no attribute '_normalized_name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/rilidy3dwrnryp3fmlmrdvma9y26k5bs-python3.9-pyproject-hooks-1.2.0/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_proces
s.py", line 389, in <module>
    main()
  File "/nix/store/rilidy3dwrnryp3fmlmrdvma9y26k5bs-python3.9-pyproject-hooks-1.2.0/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_proces
s.py", line 373, in main
    json_out["return_val"] = hook(**hook_input["kwargs"])
  File "/nix/store/rilidy3dwrnryp3fmlmrdvma9y26k5bs-python3.9-pyproject-hooks-1.2.0/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_proces
s.py", line 143, in get_requires_for_build_wheel
    return hook(config_settings)
  File "/build/source/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
  File "/build/source/setuptools/build_meta.py", line 302, in _get_build_requires
    self.run_setup()
  File "/build/source/setuptools/build_meta.py", line 318, in run_setup
    exec(code, locals())
  File "<string>", line 94, in <module>
  File "/build/source/setuptools/__init__.py", line 117, in setup
    return distutils.core.setup(**attrs)
  File "/build/source/setuptools/_distutils/core.py", line 183, in setup
    return run_commands(dist)
  File "/build/source/setuptools/_distutils/core.py", line 199, in run_commands
    dist.run_commands()
  File "/build/source/setuptools/_distutils/dist.py", line 954, in run_commands
    self.run_command(cmd)
  File "/build/source/setuptools/dist.py", line 950, in run_command
    super().run_command(command)
  File "/build/source/setuptools/_distutils/dist.py", line 973, in run_command
    cmd_obj.run()
  File "/build/source/setuptools/command/egg_info.py", line 302, in run
    for ep in metadata.entry_points(group='egg_info.writers'):
  File "/build/source/setuptools/_vendor/importlib_metadata/__init__.py", line 1001, in entry_points
    return EntryPoints(eps).select(**params)
  File "/build/source/setuptools/_vendor/importlib_metadata/__init__.py", line 998, in <genexpr>
    eps = itertools.chain.from_iterable(
  File "/build/source/setuptools/_vendor/importlib_metadata/_itertools.py", line 16, in unique_everseen
    k = key(element)
  File "/build/source/setuptools/_vendor/importlib_metadata/compat/py39.py", line 23, in normalized_name
    return Prepared.normalize(getattr(dist, "name", None) or dist.metadata['Name'])
  File "/build/source/setuptools/_vendor/importlib_metadata/__init__.py", line 839, in normalize
    return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
  File "/nix/store/amhav1gycwcg0d9yhsrv9nvwphm3z8rs-python3-3.9.20/lib/python3.9/re.py", line 210, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel

Additional context

flake.lock

{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1730531603,
        "narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

Notify maintainers

Metadata


Add a :+1: reaction to issues you find important.

Antares0982 commented 1 week ago

May be relavant: https://github.com/pypa/setuptools/issues/3452

Antares0982 commented 1 week ago

@mweinelt

Antares0982 commented 1 week ago

It seems a simple patch like this should work:

diff --git a/setuptools/_vendor/importlib_metadata/__init__.py b/setuptools/_vendor/importlib_metadata/__init__.py
index ed4813551..790513de1 100644
--- a/setuptools/_vendor/importlib_metadata/__init__.py
+++ b/setuptools/_vendor/importlib_metadata/__init__.py
@@ -836,7 +836,7 @@ class Prepared:
         """
         PEP 503 normalization plus dashes as underscores.
         """
-        return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
+        return re.sub(r"[-_.]+", "-", str(name)).lower().replace('-', '_')

     @staticmethod
     def legacy_normalize(name):

But the reason why the recent nixos-unstable breaks setuptools is still unknown.

SRachamim commented 1 week ago

How can I bypass this issue meanwhile?

Antares0982 commented 1 week ago

How can I bypass this issue meanwhile?

Use packageOverrides and apply the patch above, see https://github.com/Antares0982/pyyjson/blob/f49da0b55ab85908ea2edd1b6324cce6a323b8e3/dev_tools/shell.nix#L7

Antares0982 commented 6 days ago

354248 added

dotlambda commented 5 days ago

This is the upstream issue: https://github.com/pypa/pyproject-hooks/issues/206 We should instead bump setuptools.