fetchPypi doesn't fetch the right url to load a .whl file to build a package

170 Views Asked by At

I ve followed these instructions (paragraph : build from source):

{
  description = "virtual environment with python and streamlit";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        python=pkgs.python311;

    xTuring = pkgs.python3Packages.buildPythonPackage rec {
      pname = "xTuring";
      version = "v0.1.6";
      format = "wheel";

    src = pkgs.python3Packages.fetchPypi rec {
        inherit pname version format;
        sha256 = "a9e78c46b807f3a14f567e151feaed993085dad601a5b5826db258afd8699914"; 
        dist = python;
        python = "py3";
        #abi = "none";
        #platform = "any";
      };

      #propagatedBuildInputs = with python; [ setproctitle ];
    };

        
        f = ps: with ps;[
          ipython
          matplotlib
          pandas

        ];        
        pip_python_packages= python.withPackages(f);

        myDevTools = [
          pip_python_packages
          pkgs.streamlit
          xTuring
        ];
      in rec {
        devShells.default = pkgs.mkShell {
          buildInputs = myDevTools;
        };
      });
}

error message:

trying https://files.pythonhosted.org/packages/py3/x/xTuring/xTuring-v0.1.6-py3-none-any.whl blabla fails

It is normal the package page says that the url should be https://files.pythonhosted.org/packages/7e/c5/f38749c4f5121fdd79e669f0e39d8c5f03949cbcc57ff4ffc8f4d56a0dcc/xturing-0.1.6-py3-none-any.whl
instead of

https://files.pythonhosted.org/packages/py3/x/xTuring/xTuring-v0.1.6-py3-none-any.whl

I've followed the instructions why fetchPypi doesn't fetch the right URL

1

There are 1 best solutions below

0
On

The issue arises from the fact that (1) the package name should be xturing rather than xTuring (capitalization), and (2) the version should be 0.1.6 instead of v0.1.6. As shown in the PyPi URL:

https://files.pythonhosted.org/packages/7e/c5.../xturing-0.1.6-py3-none-any.whl

There are no capital letters in the file name, nor is there a "v" preceding the version number.

Hence you should correct your source fetching parameters to

pname = "xturing";
version = "0.1.6";
format = "wheel";
src = pkgs.python3Packages.fetchPypi rec {
  inherit pname version format;
  sha256 = pkgs.lib.fakeSha256;
  dist = python;
  python = "py3";
};