Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to override setuptools <70? #1729

Open
heimalne opened this issue Jul 12, 2024 · 6 comments
Open

How to override setuptools <70? #1729

heimalne opened this issue Jul 12, 2024 · 6 comments

Comments

@heimalne
Copy link

I have an older torch==1.10.1 package that needs an older setuptools<=70 version due to breaking changes.

With setuptools==70.0.0 i get the following error message, which isn't NixOS or Mac related (See AUTOMATIC1111/stable-diffusion-webui#15863 (comment)):

File ".../lib/python3.9/site-packages/torch/torch_version.py", line 3, in <module>
from pkg_resources import packaging  # type: ignore[attr-defined]
<class 'ModuleNotFoundError'> No module named 'pkg_resources'

Describe the issue

However, pinning an older setuptools = { version = "<70" } in pyproject.toml and poetry.lock doesn't download that version. Apparently, either nixpkgs or poetry2nix overrides and sneaks in a newer 70.0.0.post0, which then later leads to an error with nix build:

Executing pythonRuntimeDepsCheck
Checking runtime dependencies for mypackage.whl
  - setuptools<70 not satisfied by version 70.0.0.post0

How would you debug this and override the setuptools version that lands into the poetry2nix venv?

Overriding the Nixpkgs python packages doesn't seem to work and overriding poetry2nix package set doesn't as well:

let
  myPython = let
      packageOverrides = final: prev: {
        setuptools = prev.setuptools.overridePythonAttrs(old: rec {
                pname = "setuptools";
                version = "0.69.5";
                doCheck = false;
                src = final.fetchPypi {
                  inherit pname version;
                  sha256 = "0yk6xl885b91dmlhlsap7x78hk2rdr879fln9anbq6k4ca42djb6";
                };
        });
      };
  in python.override {inherit packageOverrides; self = python;};
in poetry2nix.mkPoetryApplication {
    projectDir = ./.;
    python = myPython;   <-----------------------------------------------------
    overrides = poetry2nix.overrides.withDefaults (final: prev: {
      setuptools = prev.setuptools.overridePythonAttrs(old: rec { <------------------------------------
        pname = "setuptools";
        version = "69.5.1";
        # copied from https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/setuptools/default.nix
        src = fetchFromGitHub {
            owner = "pypa";
            repo = "setuptools";
            rev = "refs/tags/v${version}";
            hash = "sha256-LXF3R9zfWylvihP2M8N94/IlgifwxUwKJFhtvcXEPB0=";
        };
      });
   };
}

Additional context

pyproject.toml:

torch = { version = "1.10.1" }
setuptools = { version = "<70" }
@heimalne
Copy link
Author

Maybe related to #1616 discussing how to separate build (i think poetry-core needs setuptools 70) from runtime dependencies.

@TyberiusPrime
Copy link
Contributor

I'm pretty sure the setuptools being used comes from nixpkgs.

@davidschrooten
Copy link

davidschrooten commented Jul 24, 2024

Same issue here as well, trying to downgrade setuptools < 70.0.0:

 Attempting uninstall: setuptools
    Found existing installation: setuptools 70.0.0.post0
    Not uninstalling setuptools at /nix/store/niacps3c0qx734l2sw9fgxl5gjm365xs-python3.11-setuptools-70.0.0/lib/python3.11/site-packages, outside environment /home/david/Dev/python/ann-experiments/venv
    Can't uninstall 'setuptools'. No files were found to uninstall.

But it gets blocked by nix...

@TyberiusPrime
Copy link
Contributor

Quite often the setup tools incompatibility is minor and a quick patch to the package wanting a setup tools < 70 is all that is needed. Sometimes it's an entirely imaginary upper bound, and all you need is to patch it. (Not saying that's the case for torch though)

This is somewhat common in the python ecosystem, where the upper bounds need to be defined on release and can't be updated later on

@davidschrooten
Copy link

Quite often the setup tools incompatibility is minor and a quick patch to the package wanting a setup tools < 70 is all that is needed. Sometimes it's an entirely imaginary upper bound, and all you need is to patch it. (Not saying that's the case for torch though)

This is somewhat common in the python ecosystem, where the upper bounds need to be defined on release and can't be updated later on

It’s requesting an import that isn’t there in setuptools 70.x. There is no version constraint.

@Kaddu720
Copy link

Was anyone able to solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants