DavHau / mach-nix

Create highly reproducible python environments
MIT License
862 stars 106 forks source link

Cryptography 3.4.8 and higher do not resolve #360

Open akotulski opened 2 years ago

akotulski commented 2 years ago

I am unable to install new cryptography packages even though I used the newest pypi database as of today. I believe it may be related to https://github.com/DavHau/pypi-deps-db/issues/2

Repro: default.nix file

{ pkgs ? import <nixpkgs> {} }:
let 
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/3.3.0";
  }) {
    python = "python39";
    pypiDataRev = "bd04b6774";
    pypiDataSha256 = "1f9dj5kmxpky1gq8aiqsp8mh1cqphvyn55ib6xvnf4sxa5yp15q3";
  };
  pythonEnv = mach-nix.mkPython {
    requirements = "cryptography==3.4.8";
  };
in pkgs.mkShell {
  packages = [ pythonEnv ];
}

Error message (via nix-shell):

Some requirements could not be resolved.
Top level requirements:
  cryptography==3.4.8
Providers:
  {'_default': 'wheel,sdist,nixpkgs',
   'gdal': 'nixpkgs',
   'pip': 'nixpkgs,sdist',
   'setupmeta': 'wheel',
   'setuptools': 'nixpkgs',
   'wheel': 'nixpkgs,sdist'}
Mach-nix version: 3.3.0
Python: 3.9.4
Cause: Requirements conflict: Requirement.parse('cryptography==3.4.8')
The requirements which caused the error:
  cryptography==3.4.8
rht commented 2 years ago

I tried with cryptography>=3.4.8 just now, and was able to install it just fine.

rht commented 2 years ago

It installed cryptography 36.0, which is the version provided by Nixpkgs, but it still failed to install 37.0. This is the error message:

Some requirements could not be resolved.
Top level requirements: 
  #poetry  cryptography>=37.0
Providers:
  {'_default': ['wheel', 'sdist', 'nixpkgs'],
   'gdal': ['nixpkgs'],
   'pip': ['nixpkgs', 'sdist'],
   'setupmeta': ['wheel'],
   'setuptools': ['nixpkgs'],
   'wheel': ['nixpkgs', 'sdist']}
Mach-nix version: 3.4.0
Python: 3.9.9
Cause: Requirements conflict: cryptography (<SpecifierSet('>=37.0')>,)
The requirements which caused the error:
  cryptography (<SpecifierSet('>=37.0')>,)

The given requirements might contain package versions which are not yet part of the dependency DB
currently used. The DB can be updated by specifying 'pypiDataRev' when importing mach-nix.
andersk commented 2 years ago

The error recorded in pypi-deps-db is

  "cryptography": {
    "3.4": {
      "27": "ImportError: No module named setuptools_rust",
      "36": "ModuleNotFoundError: No module named 'setuptools_rust'",
      "37": "36",
      "38": "36",
      "39": "36",
      "310": "36"
    },
    "3.4.1": "3.4",
    "3.4.2": "3.4",
    "3.4.3": "3.4",
    "3.4.4": "3.4",
    "3.4.5": "3.4",
    "3.4.6": "3.4",
    "3.4.7": "3.4",
    "3.4.8": "3.4",
    "35.0.0": {
      "27": "SyntaxError: invalid syntax",
      "36": "ModuleNotFoundError: No module named 'setuptools_rust'",
      "37": "36",
      "38": "36",
      "39": "36",
      "310": "36"
    },
    "36.0.0": "35.0.0",
    "36.0.1": "35.0.0",
    "36.0.2": "35.0.0",
    "37.0.0": "35.0.0",
    "37.0.1": "35.0.0",
    "37.0.2": "35.0.0"
  },
solomon-b commented 2 years ago

I'm encountering the same issue. I can install 3.3.2, 36.0.2, but nothing in between or greater then 36.

Here is a flake to demonstrate:

{
  description = "Mach Nix Test";

  inputs = {
    nixpkgs.url = github:NixOS/nixpkgs/nixos-22.05;

    flake-utils = {
      url = github:numtide/flake-utils;
      inputs.nixpkgs.follows = "nixpkgs";
    };

    pypi-deps-db = {
      url = github:DavHau/pypi-deps-db;
      inputs.mach-nix.follows = "mach-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    }; 

    mach-nix = {
      url = github:DavHau/mach-nix;
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-utils.follows = "flake-utils";
      inputs.pypi-deps-db.follows = "pypi-deps-db";
    };
  };

  outputs = { self, nixpkgs, flake-utils, mach-nix, pypi-deps-db }:
    let
      ghcVersion = "8107";
      compiler = "ghc${ghcVersion}";
      defaultSystems = [
        "aarch64-linux"
        "aarch64-darwin"
        "i686-linux"
        "x86_64-darwin"
        "x86_64-linux"
      ];
    in
    flake-utils.lib.eachSystem defaultSystems (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config = { allowUnfree = true; };
        };
      in
      rec {
        devShell =
          let
            pytestEnv = mach-nix.lib."${system}".mkPython {
              requirements =
                ''
                cryptography==37.0.2
                '';
            };
          in
            pkgs.mkShell {
              buildInputs = [pytestEnv];
            };
      });
}

EDIT: I am able to build 3.4.8 if i use nixpkgs 21.11