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

Optional dependencies in setup.py installed when not requested #571

Open
skeet70 opened this issue Aug 8, 2023 · 0 comments
Open

Optional dependencies in setup.py installed when not requested #571

skeet70 opened this issue Aug 8, 2023 · 0 comments

Comments

@skeet70
Copy link

skeet70 commented Aug 8, 2023

I've pasted a minimal reproduction flake.nix below. Running nix develop with this flake installs the optional tf dependencies even though they weren't requested.

This was noticed in our case when a developer on an M1 Mac tried to load the flake and it failed, because tensorflow-text isn't available pre-compiled on Mac.

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    mach-nix.url = "github:DavHau/mach-nix/3.5.0";
  };

  outputs = { self, nixpkgs, flake-utils, mach-nix, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        pytrec-eval = mach-nix.lib.${system}.buildPythonPackage {
          src = pkgs.fetchFromGitHub {
            owner = "cvangysel";
            repo = "pytrec_eval";
            rev = "0d8571efc2dea5a792358410d5affbe0ad383602";
            sha256 = "sha256-t76D3C5QMJgQMhAg8TGxdtjwaLQhlB8SufAdM3pAZg4=";
            fetchSubmodules = true;
          };
          pname = "pytrec_eval";
          version = "0.5";
          requirements = ''
            numpy>=1.15.1
            scipy>=1.1.0
          '';
        };
        pythonEnv = mach-nix.lib.${system}.mkPython
          {
            requirements = ''
              beir
            '';
            packagesExtra = [ pytrec-eval ];
            providers.torch = "nixpkgs";
            overridesPost = [
              (curr: prev: {
                torch = prev.torch.override {
                  cudaSupport = true;
                };
              })
            ];
          };
      in
      {
        devShell = pkgs.mkShell {
          nativeBuildInputs = [ ];
          buildInputs = [
            pythonEnv
          ];
        };
      });
}
pipdeptree
beir==0.2.2
  - elasticsearch [required: Any, installed: 7.17.0]
  - faiss-cpu [required: Any, installed: 1.7.2]
  - pytrec-eval [required: Any, installed: 0.5]
  - sentence-transformers [required: Any, installed: 2.1.0]
  - tensorflow [required: >=2.2.0, installed: 2.7.1]
  - tensorflow-hub [required: Any, installed: 0.12.0]
  - tensorflow-text [required: Any, installed: 2.7.3]
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

1 participant