Git Product home page Git Product logo

mach-nix's Introduction

⚠️ This project is unmaintained ⚠️

The plan is to replace it with dream2nix. The dream2nix python support is still WIP and needs your help. Please consider to support dream2nix with contributions or funds in order to speed up the process. Feel free to contact me.

mach-nix - Create highly reproducible python environments

Mach-nix makes it easy to create and share reproducible python environments or packages. Existing tools for python package management often suffer from reproducibility and complexity issues, requiring a multitude of tools and additional virtualization layers to work sufficiently. Mach-nix aims to solve these problems by providing a simple way to use nix, a revolutionary build system which is known to achieve great reproducibility and portability besides many other advantages.

Who is this meant for?

  • Users without nix experience, who want to maintain python environments for their projects which are reliable and easy to reproduce.
  • Users already working with nix who want to reduce the effort needed to create nix expressions for their python projects.

Other benefits of mach-nix

  • Use one tool to install packages from 3 different universes: pypi, conda, nixpkgs.
  • Hardware optimizations, like for example SSE/AVX/FMA for tensorflow, are available without the need to manually mess with their build system. (see nixpkgs provider)
  • Cross platform support (tested only aarch64)
  • Easily include private packages or packages from other sources.
  • Build time parameters and dependencies of complex python packages can be tweaked without needing to setup any build environment. It requires some knowledge about nix, though. For examples, see override system.

Table of Contents

Usage from cmdline

Installation

nix-env -if https://github.com/DavHau/mach-nix/tarball/3.5.0 -A mach-nix

or, if you prefer nix-shell:

  • if Nix flakes is enabled:

    nix shell github:DavHau/mach-nix
  • otherwise:

    nix-shell -p '(callPackage (fetchTarball https://github.com/DavHau/mach-nix/tarball/3.5.0) {}).mach-nix'

Build a virtualenv-style python environment from a requirements.txt

mach-nix env ./env -r requirements.txt

This will generate the python environment into ./env. To activate it, execute:

nix-shell ./env

The ./env directory contains a portable and reproducible definition of your python environment. To reuse this environment on another system, just copy the ./env directory and use nix-shell to activate it.


Generate a nix expression from a requirements.txt

mach-nix gen -r requirements.txt

...to print out the nix expression which defines a python derivation (optionally use -o to define an output file)


Build a derivation or enter a shell from a list of requirements


Usage in Nix Expression

Basic

You can call mach-nix directly from a nix expression

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix";
    ref = "refs/tags/3.5.0";
  }) {};
in
mach-nix.mkPython {
  requirements = ''
    pillow
    numpy
    requests
  '';
}

find more examples under ./examples.md

Advanced

Mach-nix can be fine tuned with additional arguments. Examples can be found in ./examples.md.

Functions for building python environments:

  1. mkPython - builds a python environment for a given requirements.txt.
  2. mkPythonShell - builds a python environment suitable for nix-shell.
  3. mkDockerImage - builds a layered docker image containing a python environment.
  4. mkNixpkgs - returns nixpkgs which conform to the given requirements.
  5. mkOverlay - returns an overlay function to make nixpkgs conform to the given requirements.
  6. mkPythonOverrides - produces pythonOverrides to make python conform to the given requirements.

Functions for building python packages or applications:

  1. buildPythonPackage - build a single python package from a source code while automatically detecting requirements.
  2. buildPythonApplication - same as buildPythonPackage, but package will not be importable by other python packages.

buildPythonPackage and buildPythonApplication accept the same arguments as their equally named partners in nixpkgs, plus the arguments of mkPython. If name/version/requirements arguments are omitted, mach-nix attempts to detect them automatically. See ./examples.md.

Note that some dependency declaration formats are missing. For a roadmap, please refer to issue #132.

mkPython and all other mk... functions take exactly the following arguments:

Required Arguments:

  • requirements (string): Text content of a typical requirements.txt.

Optional Arguments:

  • providers (set): define provider preferences (see examples below)
  • packagesExtra (list) Add extra packages. Can contain tarball-URLs or paths of python source code, packages built via mach-nix.buildPythonPackage, or R Packages.
  • _ (set): use underscore argument to easily modify arbitrary attributes of packages. For example to add build inputs use _.{package}.buildInputs.add = [...]. Or to overwrite patches use _.{package}.patches = [...].
  • overridesPre (list): (advanced) list of pythonOverrides to apply before the mach-nix overrides. Use this to include additional packages which can then be selected inside the requirements
  • overridesPost (list): (advanced) list of pythonOverrides to apply after the mach-nix overrides. Use this to fixup packages.
  • tests (bool): Whether to enable tests (default: false)
  • _providerDefaults (set): builtin provider defaults. Disable them by passing {}

Configure Providers

Providers allow you to configure the origin for your packages on a granular basis.

The following providers are available:

  1. conda: Provides packages from anaconda.org. Those packages can contain binaries. Some benefits of anaconda are:
    • Different build variants for packages
    • Provides all system dependencies for packages
  2. wheel: Provides all linux compatible wheel releases from pypi. If wheels contain binaries, Mach-nix patches them via patchelf to ensure reproducibility. Wheels are very quick to install and work quite reliable.
  3. sdist: Provides all setuptools compatible packages from pypi. It still uses nix for building, which allows it to be tweaked in a flexible way. But in some cases problems can occur, if there is not sufficient information available to determine required system depedencies.
  4. nixpkgs: Provides packages directly from nixpkgs without modifying their sources. Has only a few versions available, Use this provider if you need to tweak individual build parameters, like SSE/AVX/FMA for tensorflow for example.

Mach-nix builds environments by mixing packages from all 3 providers. You decide which providers should be preferred for which packages, or which providers shouldn't be used at all. The default preferred order of providers is conda, wheel, sdist, nixpkgs.

Providers can be disabled/enabled/preferred like in the following examples:

  • A provider specifier like "wheel,sdist,nixpkgs" means, that the resolver will first try to satisfy the requirements with candidates from the wheel provider. If a resolution is impossible or a package doesn't provide a wheel release, it falls back to sdist/nixpkgs for a minimal number of packages. In general it will choose as many packages from wheel as possible, then sdist, then nixpkgs.

  • "nixpkgs,sdist" means, that nixpkgs candidates are preferred, but mach-nix falls back to sdist. wheel is not listed and therefore wheels are disabled.

A full provider config passed to mach-nix looks like this:

{
  # The default for all packages which are not specified explicitly
  _default = "nixpkgs,wheel,sdist";

  # Explicit settings per package
  numpy = "wheel,sdist";
  tensorflow = "wheel";
}

Mach-nix will always satisfy the requirements.txt fully with the configured providers or fail with a ResolutionImpossible error.

If a mach-nix build fails, most of the time it can be resolved by just switching the provider of a package, which is simple and doesn't require writing a lot of nix code. For some more complex scenarios, checkout the ./examples.md.

Why nix?

Usually people rely on multiple layers of different package management tools for building their software environments. These tools are often not well integrated with each other and don't offer strong reproducibility. Example: You are on debian/ubuntu and use APT (layer 1) to install python. Then you use venv (layer 2) to overcome some of your layer 1 limitations (not being able to have multiple versions of the same package installed) and afterwards you are using pip (layer 3) to install python packages. You notice that even after pinning all your requirements, your environment behaves differently on your server or your colleagues machine because their underlying system differs from yours. You start using docker (layer 4) to overcome this problem which adds extra complexity to the whole process and gives you some nasty limitations during development. You need to configure your IDE's docker integration and so on. Despite all the effort you put in, still the problem is not fully solved and from time to time your build pipeline just breaks and you need to fix it manually.

In contrast to that, the nix package manager provides a from ground up different approach to build software systems. Due to its purely functional approach, nix doesn't require additional layers to make your software reliable. Software environments built with nix are known to be reproducible and portable, which makes many processes during development and deployment easier. Mach-nix leverages that potential by abstracting away the complexity involved in building python environments with nix. Under the hood it just generates and evaluates nix expressions for you.

How does mach-nix work?

The general mechanism can be broken down into Dependency resolution and Generating a nix expression:

Dependency resolution

Mach-nix contains a dependency graph of nearly all python packages available on pypi.org. This allows mach-nix to resolve dependencies offline within seconds.

The dependency graph data can be found here: https://github.com/DavHau/pypi-deps-db The dependency graph is updated on a daily basis by this set of tools: https://github.com/DavHau/pypi-crawlers

Despite this graph being updated constantly, mach-nix always pins one specific version of the graph to ensure reproducibility.

As core for the resolving resolvelib is used: https://github.com/sarugaku/resolvelib

Mach-nix supports multiple providers to retrieve python packages from. The user can specify which providers should be preferred. Packages from different providers can be mixed.

File resolution

With pypi-deps-db, we have built a dependency graph, where each package is defined by name and version, for example pillow-9.1.0.

To download a package, we need it's URL and hash. This is where nix-pypi-fetcher-2 comes in. nix-pypi-fetcher-2 is another database, which allows us to resolve packages to their URL and hash.

For details, see implementation.md.

Generating a nix expression

After all python dependencies and their providers have been determined by the dependency resolver, mach-nix will generate a nix expression defining your python environment.

Individual python packages are either built by overriding an existing package definition from nixpkgs, or by creating the package from scratch via nixpkgs' buildPythonPackage. Which strategy is used depends on the provider of a package and if it is already packaged in nixpkgs.

Using nixpkgs as a base has the following benefits:

  1. Non-python Dependencies: Many python packages have non-python dependencies like various C libraries. Mach-nix can resolve those dependencies by taking the build inputs from python package definitions in nixpkgs.
  2. Special features: Some python packages can be built with special features, like for example SSE/AVX/FMA support in tensorflow. The nixpkgs versions of those python packages often include these features.
  3. Nix specific fixes: Some python packages might need some additional modification to work with nix. Those are already done in nixpkgs.

If a package is built by overriding nixpkgs, the following attributes are modified:

  • src: updated to the required version
  • name: modified to match the new version
  • buildInputs: replaced with mach-nix determined python deps
  • propagatedBuildInputs: non-python deps of old definition + mach-nix determined python deps
  • doCheck: set to false by default if not specified by user
  • doInstallCheck: set to false by default if not specified by user

Contributing

Contributions to this project are welcome in the form of GitHub PRs. If you are planning to make any considerable changes, you should first present your plans in a GitHub issue so it can be discussed.

Gitpod ready-to-code

Limitations

  • Currently mach-nix does not provide any functionality which supports you in publishing python projects, like Poetry does for example.

Alternative / Similar Software:

mach-nix's People

Contributors

a-kenji avatar aedsm avatar apeschar avatar asymmetric avatar atry avatar bjornfor avatar das-g avatar davhau avatar dependabot[bot] avatar edjroot avatar exarkun avatar haozeke avatar inlaw avatar lassulus avatar milahu avatar mschwaig avatar nasyxx avatar nat543207 avatar rokroskar avatar sephii avatar siddharthverma314 avatar someoneserge avatar supersandro2000 avatar thiagokokada avatar timsears avatar tomprince avatar tyberiusprime avatar vincentbernat avatar xiorcale avatar yajo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mach-nix's Issues

Add option for blacklisting providers globally

Currently the API doesn't allow for a simple global provider blacklisting. As long as the user wants to keep the _default_providers there will always be possibly unwanted providers configured for some packages

Attribute already defined in mach_nix_file.nix

let
  python = mach-nix.mkPython {
    python = pkgs.python37;

    requirements = ''
      httpx
    '';
  };
in
# ...
while evaluating the attribute 'passAsFile' of the derivation 'python3-3.7.7-env' at /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/pkgs/build-support/trivial-builders.nix:7:7:
while evaluating 'callPackageWith' at /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/lib/customisation.nix:117:35, called from /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/pkgs/development/interpreters/python/default.nix:20:24:
while evaluating 'makeOverridable' at /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/lib/customisation.nix:67:24, called from /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/lib/customisation.nix:121:8:
while evaluating anonymous function at /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/pkgs/top-level/python-packages.nix:9:1, called from /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/lib/customisation.nix:69:16:
while evaluating 'fix'' at /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/lib/fixed-points.nix:25:10, called from /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/pkgs/top-level/python-packages.nix:7546:4:
while evaluating 'extends' at /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/lib/fixed-points.nix:69:24, called from /nix/store/2hslak69g1rmvzna5xcswhhsadjibybz-source/lib/fixed-points.nix:25:21:
while evaluating anonymous function at /nix/store/j82lzp1rgj9jfav9zjb1sgk1gfd8gk99-source/default.nix:5:35, called from /nix/store/j82lzp1rgj9jfav9zjb1sgk1gfd8gk99-source/default.nix:104:55:
while evaluating the attribute 'overrides' at /nix/store/j82lzp1rgj9jfav9zjb1sgk1gfd8gk99-source/default.nix:42:7:
attribute 'h3' at /nix/store/2j0svm25agyz6b6cvs41bw9n2m1y37w1-mach_nix_file/share/mach_nix_file.nix:49:5 already defined at /nix/store/2j0svm25agyz6b6cvs41bw9n2m1y37w1-mach_nix_file/share/mach_nix_file.nix:48:5

Alternative dependency resolver

To resolve python dependencies, which is an NP-hard problem, we currently use resolvelib.
It might not the best possible dependency resolution algorithm for our case.
Resolvelib is mainly developed for pip (will be included into pip soon). For pip, looking up dependencies of a package is expensive because it needs to downloaded the package first.
Therefore i assume that resolvelib is optimized to reduce the number of lookups in the dependency graph and not to return the best possible result.
In our case a dependency lookup is cheap, since we have the whole dependency graph on disk.
We could implement or find another dependency resolution algorithm which fits our needs better.

One argument for keeping resolvelib would be that our resolution behaviour will be very similar to pip. Since one of the important use cases of mach-nix is to quickly be able to load any existing python project out there, having similar behaviour to pip can be an advantage.

How to build when pytest tests break ?

I am trying to build my config (here, see #24) with python via mach-nix, but on a different architecture (aarch64) and now get this errors.

Adding

requirements = ''
        pytest
        ...
'';
pytest = pkgs.python3Packages.pytest.overridePythonAttrs {
      doCheck = false;
      doInstallCheck = false;
    };

does not seem to solve it.

installing python-language-server fails

Error:

Processing ./python_language_server-0.31.9-py3-none-any.whl
Requirement already satisfied: pluggy in /nix/store/rhyn3mabvly61qmqq6rp9jyvajbax1y7-python3.7-pluggy-0.13.1/lib/python3.7/site-packages (from python-language-server==0.31.9) (0.13.1)
Requirement already satisfied: ujson<=1.35; platform_system != "Windows" in /nix/store/mn968r0j4pz4q3hsqd4i2qf8kv02ypmi-python3.7-ujson-1.35/lib/python3.7/site-packages (from python-language-server==0.31.9) (1.35)
ERROR: Could not find a version that satisfies the requirement jedi<0.16,>=0.14.1 (from python-language-server==0.31.9) (from versions: none)
ERROR: No matching distribution found for jedi<0.16,>=0.14.1 (from python-language-server==0.31.9)
builder for '/nix/store/10hmf3sjvf1b1khbc4vi1am04b1hdcp9-python3.7-python-language-server-0.31.9.drv' failed with exit code 1

The python-language-server wheel depends on jedi, but mach-nix doesn't seem to catch that

When installing numpy: ELF load command address/offset not properly aligned

Just trying this out for the first time with numpy as the only requirement and I ran into this error:

Python 3.7.6 (default, Dec 18 2019, 19:23:55)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
Traceback (most recent call last):
  File "/nix/store/dk7c4hd32212x9ssas5ddbd4xrcj55zh-python3-3.7.6-env/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/nix/store/dk7c4hd32212x9ssas5ddbd4xrcj55zh-python3-3.7.6-env/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/nix/store/dk7c4hd32212x9ssas5ddbd4xrcj55zh-python3-3.7.6-env/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libgfortran-2e0d59d6.so.5.0.0: ELF load command address/offset not properly aligned

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/dk7c4hd32212x9ssas5ddbd4xrcj55zh-python3-3.7.6-env/lib/python3.7/site-packages/numpy/__init__.py", line 140, in <module>
    from . import core
  File "/nix/store/dk7c4hd32212x9ssas5ddbd4xrcj55zh-python3-3.7.6-env/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "/nix/store/dk7c4hd32212x9ssas5ddbd4xrcj55zh-python3-3.7.6-env/bin/python3.7"
  * The NumPy version is: "1.19.0"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libgfortran-2e0d59d6.so.5.0.0: ELF load command address/offset not properly aligned

Here's my shell.nix:

with import <nixpkgs> {};

let
  mach-nix = import (
    builtins.fetchGit {
      url = "https://github.com/DavHau/mach-nix/";
      ref = "2.1.0";
    }
  );

  customPython = mach-nix.mkPython {
    python = pkgs.python37;
    requirements = ''
      numpy
    '';
  };
in

pkgs.mkShell {
  buildInputs = [ customPython ];
}

Any tips for investigating this?

improve low level api `machnix.machNix`

Currently requires to pass custom autoPatchelfHook and pythonManylinuxPackages.manylinux1.

Those should be removed and replaced with defaults which can be overridden optionally

disabling checks via overridePythonAttrs doesn't seem to work

As mentioned in #28, overriding doCheck and doInstallCheck by using overridePythonAttrs doesn't work for pytest.
It seems to be working fine with overrideAttrs.

I need to find out what are the exact differences between overridePythonAttrs and overrideAttrsand figure out when to use which one.

pip-tools fails

Trying to spawn a shell with pip-tools in a requirements file fails.

requirements.txt:

pip-tools==5.3.1

shell.nix:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix";
    ref = "refs/tags/2.2.0";
  });
in mach-nix.mkPythonShell {
  requirements = builtins.readFile ./requirements.txt;
}

Output of nix-shell:

$ nix-shell
building '/nix/store/z92n40yigwgmbyf8mfjx6pzpf8mag5c7-mach_nix_file.drv'...

### Resolved Dependencies ###

pip-tools - 5.3.1 - wheel - py2.py3-none-any
├── click - 7.1.2 - wheel - py2.py3-none-any
├── pip - 20.2.1 - wheel - py2.py3-none-any
└── six - 1.15.0 - wheel - py2.py3-none-any

error: --- EvalError ---------------------------------------------------------------- nix-shell
at: (63:34) in file: /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/pkgs/development/python-modules/bootstrapped-pip/default.nix

    62|     description = "Version of pip used for bootstrapping";
    63|     license = stdenv.lib.unique (pip.meta.license ++ setuptools.meta.license ++ wheel.meta.license);
      |                                  ^
    64|     homepage = pip.meta.homepage;

attribute 'license' missing
(use '--show-trace' to show detailed location information)

passing `pkgs` to mach-nix.buildPythonPackages fails

The following expression fails:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.2.1";
  });
in mach-nix.buildPythonPackage rec {
  pname = "deeplabcut";
  version = "v2.2bb7";
  pkgs = (import <unstable> {});
  src = builtins.fetchGit{
    url = "https://github.com/DeepLabCut/DeepLabCut";
    ref = "master";
    rev = "c98f0d308636be5c4feaea4a35e77c2d974aa710";
  };
  requirements = ''
    requests
  '';
}

Error:

error: while evaluating the attribute 'drvPath' at /nix/store/c9dff5q4dvhg55y3wjkdwchb66m3za89-unstable-20.09pre235279.5717d9d2f7c/unstable/lib/customisation.nix:163:7:
while evaluating the attribute 'pkgs' of the derivation 'python3.8-deeplabcut-v2.2bb7' at /nix/store/c9dff5q4dvhg55y3wjkdwchb66m3za89-unstable-20.09pre235279.5717d9d2f7c/unstable/pkgs/development/interpreters/python/mk-python-derivation.nix:108:3:
cannot coerce a set to a string, at /nix/store/c9dff5q4dvhg55y3wjkdwchb66m3za89-unstable-20.09pre235279.5717d9d2f7c/unstable/pkgs/development/interpreters/python/mk-python-derivation.nix:108:3

attribute 'sdist' missing, at ...-nix-pypi-fetcher/...

Mach-nix seems to try to access an sdist release which doesn't exist. Need to debug

problematic derivation:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.1.0";
  });
in
mach-nix.mkPython {
  python = mach-nix.nixpkgs.python37;
  requirements = ''
    pyqt5
  '';
}

error: attribute 'sdist' missing, at /nix/store/js7jvdbqp1i804frs52c7aqsqp0zj7py-nix-pypi-fetcher/default.nix:26:25

(Question) What to do if a packages requirements are not quite known (yet) - to answer myself

Let's say I have a list of requirements in a mach-nix.mkPython block and the build complains along the lines of

ERROR: Could not find a version that satisfies the requirement packaging (from Sphinx==2.3.1) (from versions: none)
ERROR: No matching distribution found for packaging (from Sphinx==2.3.1)
builder for '/nix/store/y8y8x98zyyczp66gcy2pv7ds3bxadl8b-python3.7-sphinx-2.3.1.drv' failed with exit code 1

I already have providers = { sphinx = "nixpkgs"; };.

Specify nixpkgs version / don't use system overlays

Thanks for this package! I'm trying to build a shell with this package, but it's failing as Mach is pinned to an old Nixpkgs and I have an overlay for a more recent python package that isn't in 19.09.

Normally I'd do something like

let
  pinnedPkgs = (import <nixpkgs> {}).fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs";
    # nixos-unstable as of 2017-11-13T08:53:10-00:00
    rev = "20.03-release";
    # sha256 = "12nvngb09cbzmqzf3il0dkl1143yap1x4is8zliziy3i606qfml7";
  };
  pkgs = import pinnedPkgs { overlays = []; };
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "master";
    rev = "42a1daf1979bef3a26a8a4eb19db801284758ba6";
  });
in
mach-nix.mkPython {
  requirements = ''
    pillow
    numpy
    requests
  '';
}

What's the equivalent of this pattern (overlays = [];) for mach? Thanks!

Edit: the error I get is attribute 'stytra' missing, at /home/tyler/.config/nixpkgs/overlays/python.nix:4:14
Edit 2: workaround for now is to first do export NIX_PATH="$NIX_PATH:nixpkgs-overlays=/home/tyler/tmp" where ~/tmp is an empty folder

bug when using package `python-jsonrpc-server` from sdist provider

Error:

Executing pipInstallPhase
/build/python-jsonrpc-server-0.3.4/dist /build/python-jsonrpc-server-0.3.4
Processing ./python_jsonrpc_server-0.2.0-py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement ujson<=1.35; platform_system != "Windows" (from python-jsonrpc-server==0.2.0) (from versions: none)
ERROR: No matching distribution found for ujson<=1.35; platform_system != "Windows" (from python-jsonrpc-server==0.2.0)
builder for '/nix/store/xj8f3wc71imv7z2k80zksl21ps7dxy3i-python3.7-python-jsonrpc-server-0.3.4.drv' failed with exit code 1

Note wrong version number in Processing ./python_jsonrpc_server-0.2.0-py3-none-any.whl

Support multiple requirement.txt files

Some projects have multiple requirements.txt files.

Therefore:

  • The cmdline interface must be extended to allow multiple requirements files
  • The nix interface must be extended to support multiple files or we provide an example on how to concatenate multiple files via nix expression.

Make cmdline generated envs depend on requirements.txt

Currently environments generated via mach-nix env ./env -r requirements.txt will contain the computed nix expression and do not depend on requirements.txt anymore.

I think it would be a good idea to instead put a nix expression there which depends on the requirements.txt. This will enable the user to update requirements later without having to use the mach-nix cmdline tool again.

./example/simple-usage-shell.nix could be used as base.

When changing default provider getting attribute error

When I use the _default for providers as in

providers = {
  _default = "nixpkgs,wheel,sdist";
};

my build says:

copying 1 paths...
copying path '/nix/store/76dsxlbvwn7hk6xwxf2lm3w43m038bzv-mach_nix_file' from 'ssh://builder'...
error: attribute 'unstable-2019-12-09' missing, at /nix/store/js7jvdbqp1i804frs52c7aqsqp0zj7py-nix-pypi-fetcher/default.nix:13:17

tensorflow-gpu missing libs (cannot be patched via autoPatchelfHook)

I have the following shell: https://gist.github.com/tbenst/0a633bd85129748de1fba7186882df20. And all the dependencies seem to build! I'm having two issues:

  1. when I try import deeplabcut (the package downloaded from github) I see ModuleNotFoundError: No module named 'deeplabcut'

  2. (maybe should be a separate issue) for import tensorflow I see: ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory. I imagine I just need an override to include CUDA (this is tensorflow-gpu). Should this go in overrides_post?

I tried this with no luck, imagine I have something wrong syntactically or conceptually...

  overrides_post = [(python-self: python-super: {
    tensorflow-gpu = python-super.tensorflow-gpu.overrideAttrs (old: rec {
      buildInputs = old.buildInputs ++ [pkgs.cudatoolkit];
    });
  })];

Error building with requirements.txt containing git dependency

Cool project!

I'm trying to use to build my project that has some dependencies that are pull directly from git, similar to described in this blog post.

This is the error I'm getting
Generating python environment... If you run this the first time, the python package index and dependency graph (~200MB) need to be downloaded. Please stay patient!
unpacking 'https://github.com/DavHau/pypi-deps-db/tarball/c75c0817d61e26427fe3f7b2a82730e3f3edd62f'...
warning: dumping very large path (> 256 MiB); this may run out of memory
these derivations will be built:
  /nix/store/5szwmgq119r43aavc8bk80nv41y5byv6-nixpkgs-py-pkgs-json.drv
  /nix/store/xf7cwshg11lgilpvfnvgarrx677rmcw3-builder.pl.drv
  /nix/store/fza0yqj2p9lxnjp0pzfdwlyllxh3872c-python3-3.7.6-env.drv
  /nix/store/p31z3m2gxjd24bvwprn3l602n76k6xdw-mach_nix_file.drv
these paths will be fetched (8.09 MiB download, 50.77 MiB unpacked):
  /nix/store/rndy89km7gi0kybip1mri51243n6rdd2-perl-5.30.1
building '/nix/store/5szwmgq119r43aavc8bk80nv41y5byv6-nixpkgs-py-pkgs-json.drv'...
building '/nix/store/xf7cwshg11lgilpvfnvgarrx677rmcw3-builder.pl.drv'...
copying path '/nix/store/rndy89km7gi0kybip1mri51243n6rdd2-perl-5.30.1' from 'https://cache.nixos.org'...
building '/nix/store/fza0yqj2p9lxnjp0pzfdwlyllxh3872c-python3-3.7.6-env.drv'...
created 257 symlinks in user environment
building '/nix/store/p31z3m2gxjd24bvwprn3l602n76k6xdw-mach_nix_file.drv'...
Traceback (most recent call last):
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 90, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1654, in parseString
    raise exc
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1644, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 3417, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1406, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 3205, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pkg_resources._vendor.pyparsing.ParseException: Expected stringEnd (at char 3), (line:1, col:4)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3101, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 94, in __init__
    requirement_string[e.loc:e.loc + 8]))
pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'+git://g'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/l5y5h21hjj4q94157yr02cpd0xg6ir18-site-packages/mach_nix/generate.py", line 54, in <module>
    main()
  File "/nix/store/l5y5h21hjj4q94157yr02cpd0xg6ir18-site-packages/mach_nix/generate.py", line 48, in main
    expr = generator.generate(reqs)
  File "/nix/store/l5y5h21hjj4q94157yr02cpd0xg6ir18-site-packages/mach_nix/generators/overlay_generator.py", line 38, in generate
    prefer_nixpkgs=self.prefer_nixpkgs
  File "/nix/store/l5y5h21hjj4q94157yr02cpd0xg6ir18-site-packages/mach_nix/resolver/resolvelib_resolver.py", line 64, in resolve
    result = resolvelib.Resolver(Provider(self.nixpkgs, self.deps_provider), reporter).resolve(reqs, max_rounds=1000)
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 413, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 278, in resolve
    for r in requirements:
  File "/nix/store/l5y5h21hjj4q94157yr02cpd0xg6ir18-site-packages/mach_nix/requirements.py", line 47, in filter_reqs_by_eval_marker
    for req in reqs:
  File "/nix/store/l5y5h21hjj4q94157yr02cpd0xg6ir18-site-packages/mach_nix/requirements.py", line 63, in parse_reqs
    reqs = list(pkg_resources.parse_requirements(strs))
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3094, in parse_requirements
    yield Requirement(line)
  File "/nix/store/zy4w84wypjwnin0bj340gkklpsffzx52-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3103, in __init__
    raise RequirementParseError(str(e))
pkg_resources.RequirementParseError: Invalid requirement, parse error at "'+git://g'"
builder for '/nix/store/p31z3m2gxjd24bvwprn3l602n76k6xdw-mach_nix_file.drv' failed with exit code 1
error: build of '/nix/store/p31z3m2gxjd24bvwprn3l602n76k6xdw-mach_nix_file.drv' failed
Traceback (most recent call last):
  File "/nix/store/vmccxiyv3p2qriraq4hsz6rnhbggyjlr-python3.7-mach-nix-2.0.0/bin/.mach-nix-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/vmccxiyv3p2qriraq4hsz6rnhbggyjlr-python3.7-mach-nix-2.0.0/lib/python3.7/site-packages/mach_nix/run.py", line 134, in main
    gen(args)
  File "/nix/store/vmccxiyv3p2qriraq4hsz6rnhbggyjlr-python3.7-mach-nix-2.0.0/lib/python3.7/site-packages/mach_nix/run.py", line 28, in gen
    print(proc.stderr.decode(), file=sys.stderr)
AttributeError: 'NoneType' object has no attribute 'decode'

Is this something that's not supported now? Or do I need to dig into the dependency repository for a potential bug in the package there? There's a possibility my problem is a duplicate of #19 or #23, but I'm not sure.

Add parameter to ignore collisions possible ?

Hi,

this project is amazing, thanks for sharing it.

I wonder if I could add nix packages (pyls-mypy and sorts) when they cause collisions as in

collision between /nix/store/y04m7z8k5p2d725v4csw32md7w64j4h9-python3-3.7.6-env/bin/.chardetect-wrapped' and /nix/store/2ry9dqdgjzy8p699ri0sp1rq86bvmdah-python3-3.7.7-env/bin/.chardetect-wrapped'

I hoped something along the lines (snippet incomplete) of

let
  myMachnix =
    let
      mach-nix = import (builtins.fetchGit {
        url = "https://github.com/DavHau/mach-nix/";
        ref = "2.0.0";
      });
    in
    mach-nix.mkPython {
      disable_checks = true;
      requirements = ''
        notebook
        pandas
        numpy

        dropbox
        lockfile

        curlify
        openpyxl
        xlrd
        tqdm
        requests

        cython >= 0.23.5
        bokeh == 0.12.7
        flexx == 0.4.1
        normality == 0.6.1
        dataset == 0.8.0
        tornado
      '';
    };
  in
  {
    home.packages = with pkgs; [
      ((python3.withPackages (pkgs: with pkgs; [
        # for emacs, also https://nixos.wiki/wiki/Vim#Vim_as_a_Python_IDE
        python-language-server
        # the following plugins are optional, they provide type checking, import sorting and code formatting
        pyls-mypy # sind in nixpkgs, nicht in pypi
        pyls-isort
        pyls-black
      ])).override (args: { ignoreCollisions = true; })) # doesn't ignore collisions with mach-nix env though
      myMachnix
    ];
  }

would do. But it seems I had to add the override to myMachnix as well. I just don't know how to do that.

Support nested requirements.txt files

requirement.txt files can be nested by stating:
-r ./rel/path/to/another_requirements.txt inside a requirements.txt.
Currently this is either ignored or raises an error.

The interface of mach-nix would need to be extended/changed to allow passing a path of the requirement.txt instead of the content. Otherwise we cannot resolve the relative paths of nested files.

Dots in the python package name seem to break package resolution.

This passes fine:

let
  machnix = import (
    builtins.fetchGit {
      url = "https://github.com/DavHau/mach-nix/";
      ref = "2.1.0";
    }
  );
in
machnix.mkPython rec {
  requirements = ''
    requests==2.24.0 
  '';
}

While this breaks:

let
  machnix = import (
    builtins.fetchGit {
      url = "https://github.com/DavHau/mach-nix/";
      ref = "2.1.0";
    }
  );
in
machnix.mkPython rec {
  requirements = ''
    discord.py==1.3.4
  '';
}

with this stacktrace:

building '/nix/store/z7cpqqvx49icx1k6fwd50fd60d88c4mq-mach_nix_file.drv'...
Traceback (most recent call last):
  File "/nix/store/r06crfb7v84wazad55pysgn6jckv7288-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 185, in _merge_into_criterion
    crit = self.state.criteria[name]
KeyError: 'discord.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/r06crfb7v84wazad55pysgn6jckv7288-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 280, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "/nix/store/r06crfb7v84wazad55pysgn6jckv7288-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 187, in _merge_into_criterion
    crit = Criterion.from_requirement(self._p, requirement, parent)
  File "/nix/store/r06crfb7v84wazad55pysgn6jckv7288-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 87, in from_requirement
    raise RequirementsConflicted(criterion)
resolvelib.resolvers.RequirementsConflicted: Requirements conflict: Requirement.parse('discord.py==1.3.4')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/8a5g856g76h0c7kkvw23i7706q451l85-j82lzp1rgj9jfav9zjb1sgk1gfd8gk99-source/mach_nix/generate.py", line 54, in <module>
    main()
  File "/nix/store/8a5g856g76h0c7kkvw23i7706q451l85-j82lzp1rgj9jfav9zjb1sgk1gfd8gk99-source/mach_nix/generate.py", line 48, in main
    expr = generator.generate(reqs)
  File "/nix/store/8a5g856g76h0c7kkvw23i7706q451l85-j82lzp1rgj9jfav9zjb1sgk1gfd8gk99-source/mach_nix/generators/overlay_generator.py", line 29, in generate
    pkgs = self.resolver.resolve(reqs)
  File "/nix/store/8a5g856g76h0c7kkvw23i7706q451l85-j82lzp1rgj9jfav9zjb1sgk1gfd8gk99-source/mach_nix/resolver/resolvelib_resolver.py", line 62, in resolve
    result = resolvelib.Resolver(Provider(self.nixpkgs, self.deps_provider), reporter).resolve(reqs, max_rounds=1000)
  File "/nix/store/r06crfb7v84wazad55pysgn6jckv7288-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 413, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/nix/store/r06crfb7v84wazad55pysgn6jckv7288-python3-3.7.6-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 282, in resolve
    raise ResolutionImpossible(e.criterion.information)
resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=Requirement.parse('discord.py==1.3.4'), parent=None)]
builder for '/nix/store/z7cpqqvx49icx1k6fwd50fd60d88c4mq-mach_nix_file.drv' failed with exit code 1

Add support for wheels

Since NixOS 20.03, also wheels with binary packages seem to be well supported by nix. See NixOS/nixpkgs#73866.
Using wheels has the following advantages:

  1. More libraries can be supported
  2. Build times for wheels are much lower than for sdists.

We need to extend pypi-crawlers to also process wheel releases of the types we are interested in.
See DavHau/pypi-crawlers#3 and DavHau/pypi-crawlers#4

For mach-nix we need to:

  • Find a way to include wheels into dependency resolution process.
  • Adapt the user interface.
  • Extend the overlay generator to be able to generate nixpkgs overlays using wheels

PyTorch example fails: "not a supported wheel on this platform."

With a slightly altered version of Recent PyTorch with nixpkgs dependencies, overlays, and custom python (permalinked), where I add numpy="wheel"; and use mach-nix's master (currently da74d4b) I end with the error:

ERROR: torch-1.5.0-cp36-cp36m-manylinux1_x86_64.whl is not a supported wheel on this platform.
builder for '/nix/store/af7a21p3sfzzxzdkbmb4vlnrhwixkscy-python3.6-torch-1.5.0.drv' failed with exit code 1
error: build of '/nix/store/af7a21p3sfzzxzdkbmb4vlnrhwixkscy-python3.6-torch-1.5.0.drv' failed

I thought it might be an out-of-date pip, so I have tried this configuration with python 3.6, 3.7, 3.8 against torch 1.5.0 and 1.5.1. This always results in the same error.

Originally I tried this on Ubuntu + nix (just torch-1.5.0 and pytorch 3.6), but the full array of testing was on NixOS.

Aside: Very cool project!

pytorch fails

I tried,

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "master";
    rev = "42a1daf1979bef3a26a8a4eb19db801284758ba6";
  });
in
mach-nix.mkPythonShell {
  requirements = ''
    torch
  '';
}
but got this error (click to expand)
these derivations will be built:
/nix/store/gag7dhx91bzp6i2rxc0ql1cmd78h8kqn-python3.7-torch-0.1.2.post2.drv
/nix/store/dlm02884w3fss89ppcrbli5vm79d7dn1-python3-3.7.5-env.drv
building '/nix/store/gag7dhx91bzp6i2rxc0ql1cmd78h8kqn-python3.7-torch-0.1.2.post2.drv'...
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing setuptools-build-hook
Using setuptoolsBuildPhase
Using setuptoolsShellHook
Sourcing pip-install-hook
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
unpacking sources
unpacking source archive /nix/store/avcbiihlwlqdqyjqq0bn12nx88qahlx3-torch-0.1.2.post2.tar.gz
source root is torch-0.1.2.post2
setting SOURCE_DATE_EPOCH to timestamp 1561154629 of file torch-0.1.2.post2/setup.cfg
patching sources
configuring
no configure script, doing nothing
building
Executing setuptoolsBuildPhase
running bdist_wheel
running build
running build_deps
Traceback (most recent call last):
File "nix_run_setup", line 8, in <module>
    exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
File "setup.py", line 265, in <module>
    description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
File "/nix/store/p4xpcwj9bxrjz9zsn032yzpnckxpyra7-python3.7-setuptools-41.2.0/lib/python3.7/site-packages/setuptools-41.2.0-py3.7.egg/setuptools/__init__.py", line 145, in setup
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
File "/nix/store/qg1m9rpl2yvfnjw9r7bh7hx7jijk233a-python3.7-wheel-0.33.6/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 192, in run
    self.run_command('build')
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
File "/nix/store/ljbn79cwlwvrlmqil0nk4zvf043ph592-python3-3.7.5/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
File "setup.py", line 51, in run
    from tools.nnwrap import generate_wrappers as generate_nn_wrappers
ModuleNotFoundError: No module named 'tools.nnwrap'
builder for '/nix/store/gag7dhx91bzp6i2rxc0ql1cmd78h8kqn-python3.7-torch-0.1.2.post2.drv' failed with exit code 1
cannot build derivation '/nix/store/dlm02884w3fss89ppcrbli5vm79d7dn1-python3-3.7.5-env.drv': 1 dependencies couldn't be built
error: build of '/nix/store/dlm02884w3fss89ppcrbli5vm79d7dn1-python3-3.7.5-env.drv' failed

Enhance nixpkgs version handling

Rethink the way how custom nixpkgs can be passed to mach-nix. Maybe it is better to extend ./default.nix to allow arguments like:

{pkgs, ...}:
...

Also document how to access the mach-nix default nixpkgs in case no custom pkgs are passed.
Currently this can be done by accessing mach-nix.nixpkgs

Duplicated packages in resolved tree

The following nix expression succeeds but leads to a dependency tree with duplicated nodes:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.2.1";
  });
in mach-nix.mkPython {
  requirements = ''
     arcgis==1.8.2
  '';
}

A much simpler example which triggers the same problem:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.2.2";
  });
in mach-nix.mkPython rec {
  requirements = ''
    cryptography==3.0
  '';
}

Resolver allows conflicting specs

The following expression should already raise an error during dependency resolution. Instead it resolves without issue and raises an error during installation:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/2.2.1";
  });
in mach-nix.buildPythonPackage rec {
  pname = "deeplabcut";
  version = "v2.2bb7";
  src = builtins.fetchGit{
    url = "https://github.com/DeepLabCut/DeepLabCut";
    ref = "master";
    rev = "c98f0d308636be5c4feaea4a35e77c2d974aa710";
  };
  requirements = ''
    llvmlite==0.34.0rc1
    numba==0.50.1
  '';
}

Error on installation:
ERROR: Could not find a version that satisfies the requirement llvmlite<0.34,>=0.33.0.dev0 (from numba==0.50.1) (from versions: none)

resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=Requirement.parse('dask==2.22.0'), parent=None)

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/2.2.1";
  });
in mach-nix.buildPythonPackage rec {
  pname = "deeplabcut";
  version = "v2.2bb7";
  pkgs = (import <unstable> {});
  src = builtins.fetchGit{
    url = "https://github.com/DeepLabCut/DeepLabCut";
    ref = "master";
    rev = "c98f0d308636be5c4feaea4a35e77c2d974aa710";
  };
  requirements = ''
    affine==2.3.0
appdirs==1.4.4
#appnope==0.1.0; python_version >= "3.3" and sys_platform == "darwin" or platform_system == "Darwin"
arcgis==1.8.2
area==1.1.1
argon2-cffi==20.1.0
#atomicwrites==1.4.0; sys_platform == "win32"
attrs==19.3.0
autoflake==1.3.1
backcall==0.2.0
beautifulsoup4==4.9.1
black==19.10b0
bleach==3.1.5
bokeh==2.1.1
certifi==2020.6.20
cffi==1.14.1
chardet==3.0.4
click==7.1.2
click-plugins==1.1.1
cligj==0.5.0
#colorama==0.4.3; python_version >= "3.3" and sys_platform == "win32" or sys_platform == "win32"
colorcet==2.0.2
cryptography==3.0
cycler==0.10.0
dask==2.22.0
datashader==0.10.0
datashape==0.5.2
decorator==4.4.2
defusedxml==0.6.0
descartes==1.1.0
entrypoints==0.3
feather-format==0.4.1
fiona==1.8.13.post1
flake8==3.8.3
flufl.enum==4.1.1
geoalchemy2==0.8.4
geofeather==0.3.0
geographiclib==1.50
geojson==2.5.0
geojsonio==0.0.3
geolinks==0.2.0
geopandas==0.8.1
geopy==2.0.0
github3.py==1.3.0
googledrivedownloader==0.4
greedy==0.1.1
idna==2.10
imageio==2.9.0
importlib-metadata==1.7.0
ipykernel==5.3.4
ipython==7.17.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.17.2
jeepney==0.4.3
jinja2==2.11.2
joblib==0.16.0
json5==0.9.5
jsonschema==3.2.0
jupyter-client==6.1.6
jupyter-core==4.6.3
jupyterlab==2.2.4
jupyterlab-server==1.2.0
jwcrypto==0.7
keyring==21.3.0
kiwisolver==1.2.0
lerc==0.1.0
libpysal==4.3.0
lidar==0.5.0
llvmlite==0.34.0rc1
lxml==4.5.2
markupsafe==1.1.1
matplotlib==3.3.0
mccabe==0.6.1
mercantile==1.1.5
missingno==0.4.2
mistune==0.8.4
momepy==0.3.0
more-itertools==8.4.0
multipledispatch==0.6.0
munch==2.5.0
mypy==0.782
mypy-extensions==0.4.3
nbconvert==5.6.1
nbformat==5.0.7
networkx==2.4
notebook==6.1.1
ntlm-auth==1.5.0
numba==0.50.1
numpy==1.19.1
oauthlib==3.1.0
osm-diff-tool==1.1.0
osmapi==1.2.2
osmnet==0.1.6
osmpythontools==0.2.8
overpass==0.7
overpy2==0.4.2
owslib==0.20.0
packaging==20.4
pandas==1.1.0
pandocfilters==1.4.2
param==1.9.3
parso==0.7.1
pathlib==1.0.1
pathspec==0.8.0
pexpect==4.8.0
pickleshare==0.7.5
pillow==7.2.0
pluggy==0.13.1
pooch==1.1.1
prometheus-client==0.8.0
prompt-toolkit==3.0.5
ptyprocess==0.6.0
py==1.9.0
pyarrow==1.0.0
pycodestyle==2.6.0
#pycparser==2.20; platform_system == "Windows" and python_version != "3.3" or platform_system == "Windows" and python_version != "3.3" and sys_platform == "linux"
pycsw==2.4.2
pyct==0.4.6
pydal==20200714.1
pyflakes==2.2.0
pygeos==0.7.1
pygis==0.1.3
pygments==2.6.1
#pykerberos==1.2.1; platform_system == "Windows" and sys_platform != "win32"
pyparsing==2.4.7
pyproj==2.6.1.post1
pyrsistent==0.16.0
pyshp==2.1.0
pysimplegui==4.28.0
pytest==5.4.3
python-dateutil==2.8.1
pytz==2020.1
pywavelets==1.1.1
#pywin32==228; sys_platform == "win32" or platform_system == "Windows"
#pywin32-ctypes==0.2.0; sys_platform == "win32"
#pywinpty==0.5.7; os_name == "nt"
pywps==4.2.7
pyyaml==5.3.1
pyzmq==19.0.2
rasterio==1.1.5
rasterstats==0.15.0
regex==2020.7.14
requests==2.24.0
#requests-kerberos==0.12.0; platform_system == "Windows"
requests-ntlm==1.1.0
requests-oauthlib==1.3.0
requests-toolbelt==0.9.1
richdem==0.3.4
rio-cogeo==1.1.10
rsgis==0.0.3
scikit-image==0.17.2
scikit-learn==0.23.2
scipy==1.5.2
seaborn==0.10.1
secretstorage==3.1.2
send2trash==1.5.0
shapely==1.7.0
simplejson==3.17.2
six==1.15.0
snuggs==1.4.7
soupsieve==1.9.6
spatial==0.2.0
sqlalchemy==1.3.18
supermercado==0.1.1
terminado==0.8.3
testpath==0.4.4
threadpoolctl==2.1.0
tifffile==2020.7.24
toml==0.10.1
toolz==0.10.0
tornado==6.0.4
tqdm==4.48.2
traitlets==4.3.3
typed-ast==1.4.1
typing-extensions==3.7.4.2
ujson==3.1.0
uritemplate==3.0.1
urllib3==1.25.10
verde==1.5.0
wcwidth==0.2.5
webencodings==0.5.1
werkzeug==1.0.1
widgetsnbextension==3.5.1
#winkerberos==0.7.0; platform_system == "Windows" and sys_platform == "win32" or platform_system == "Windows"
xarray==0.16.0
xarray-spatial==0.0.8
xmltodict==0.12.0
zipp==3.1.0
  '';
}

error:

building '/nix/store/5ssy5glf78kh973w5bz5ps82q2kri50n-mach_nix_file.drv'...
Traceback (most recent call last):
Traceback (most recent call last):
  File "/nix/store/5l1ps1iaml9aivqsd2796cryadpy74py-ch8zsbs2vlfqdr6rpz85y455sfmz6vyf-source/mach_nix/generate.py", line 63, in main
    expr = generator.generate(reqs)
  File "/nix/store/5l1ps1iaml9aivqsd2796cryadpy74py-ch8zsbs2vlfqdr6rpz85y455sfmz6vyf-source/mach_nix/generators/overides_generator.py", line 34, in generate
    pkgs = self.resolver.resolve(reqs)
  File "/nix/store/5l1ps1iaml9aivqsd2796cryadpy74py-ch8zsbs2vlfqdr6rpz85y455sfmz6vyf-source/mach_nix/resolver/resolvelib_resolver.py", line 63, in resolve
    result = resolvelib.Resolver(Provider(self.nixpkgs, self.deps_provider), reporter).resolve(reqs, max_rounds=1000)
  File "/nix/store/njdwizism6z27b18dcngxlm4pw9aa07f-python3-3.7.8-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 413, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/nix/store/njdwizism6z27b18dcngxlm4pw9aa07f-python3-3.7.8-env/lib/python3.7/site-packages/resolvelib/resolvers.py", line 319, in resolve
    raise ResolutionImpossible(causes)
resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=Requirement.parse('dask==2.22.0'), parent=None), RequirementInformation(requirement=Requirement.parse('dask[complete]>=0.18.0'), parent=Candidate(name='datashader', ver=<Version('0.10.0')>, extras=()))]


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "/nix/store/5l1ps1iaml9aivqsd2796cryadpy74py-ch8zsbs2vlfqdr6rpz85y455sfmz6vyf-source/mach_nix/generate.py", line 94, in <module>
    main()
  File "/nix/store/5l1ps1iaml9aivqsd2796cryadpy74py-ch8zsbs2vlfqdr6rpz85y455sfmz6vyf-source/mach_nix/generate.py", line 65, in main
    handle_resolution_impossible(e, requirements, providers_json, py_ver_str)
  File "/nix/store/5l1ps1iaml9aivqsd2796cryadpy74py-ch8zsbs2vlfqdr6rpz85y455sfmz6vyf-source/mach_nix/generate.py", line 79, in handle_resolution_impossible
    f" - parent: {ri.parent.name}{ri.parent.extras if ri.parent.extras else None}:{ri.parent.version}"
AttributeError: 'Candidate' object has no attribute 'version'
AttributeError: 'Candidate' object has no attribute 'version'
builder for '/nix/store/5ssy5glf78kh973w5bz5ps82q2kri50n-mach_nix_file.drv' failed with exit code 1
while evaluating the attribute 'passAsFile' of the derivation 'python3-3.8.5-env' at /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/pkgs/build-support/trivial-builders.nix:7:7:
while evaluating 'callPackageWith' at /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/customisation.nix:117:35, called from /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/pkgs/development/interpreters/python/default.nix:20:24:
while evaluating 'makeOverridable' at /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/customisation.nix:67:24, called from /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/customisation.nix:121:8:
while evaluating anonymous function at /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/pkgs/top-level/python-packages.nix:9:1, called from /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/customisation.nix:69:16:
while evaluating 'fix'' at /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/fixed-points.nix:25:10, called from /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/pkgs/top-level/python-packages.nix:7738:4:
while evaluating 'extends' at /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/fixed-points.nix:69:24, called from /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/fixed-points.nix:25:21:
while evaluating 'composeExtensions' at /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/fixed-points.nix:75:17, called from /nix/store/pz3w468p7ig3zj8fy5xsbrjn95dwiiwj-nixpkgs/lib/fixed-points.nix:69:67:
while evaluating the attribute 'overrides' at /nix/store/ch8zsbs2vlfqdr6rpz85y455sfmz6vyf-source/default.nix:37:7:

error: --- Error --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix-shell
build of '/nix/store/5ssy5glf78kh973w5bz5ps82q2kri50n-mach_nix_file.drv' failed

resolvelib.resolvers.ResolutionImpossible: dask, pyct, rasterio

Hello

i try to use mach-nix 2.2.0

before I used poetry to resulve the pkgs and export the resolution to a file (which I try to feed in mach-nix)

but I get:

resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=Requirement.parse('dask==2.22.0'), parent=None), RequirementInformation(requirement=Requirement.parse('dask[complete]>=0.18.0'), parent=Candidate(name='datashader', ver=<Version('0.10.0')>, extras=()))]
builder for '/nix/store/d5dnw42d7jfhdqmzh35cybak8w91jpkh-mach_nix_file.drv' failed with exit code 1
error: --- Error --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix-build
build of '/nix/store/d5dnw42d7jfhdqmzh35cybak8w91jpkh-mach_nix_file.drv' failed

resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=Requirement.parse('pyct==0.4.6'), parent=None), RequirementInformation(requirement=Requirement.parse('pyct[cmd]'), parent=Candidate(name='datashader', ver=<Version('0.10.0')>, extras=()))]

resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=Requirement.parse('rasterio==1.1.5'), parent=None), RequirementInformation(requirement=Requirement.parse('rasterio[s3]>=1.0.28'), parent=Candidate(name='rio-cogeo', ver=<Version('1.1.10')>, extras=()))]

and via nix-shell shll.nix execution:
KeyError: 'numba' resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=Requirement.parse('numba==0.50.1'), parent=None)]

KeyError: 'arcgis'


if I skip those I get

RecursionError: maximum recursion depth exceeded while getting the str of an object


via nix-shell
and mach-nix


let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.2.0";
  });
in mach-nix.mkPython {
  requirements = ''
     # your requirements here
     dask==2.22.0
     pyct==0.4.6
     rasterio==1.1.5
     numba==0.50.1
     arcgis==1.8.2
  '';
}

support (or ignore?) other requirements.txt parameters

I saw you released a new version so I decided to give mach-nix a quick try, but I noticed some errors on a few flags used in our requirements.

  1. We have a private index added by something like --extra-index-url <private index url> near the top of our requirements. The primary error looks like:

    Traceback (most recent call last):
      File "/nix/store/sl2pdxfyr6053a1p0af3lxscca3r101w-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3101, in __init__
        super(Requirement, self).__init__(requirement_string)
      File "/nix/store/sl2pdxfyr6053a1p0af3lxscca3r101w-python3-3.7.6-env/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 94, in __init__
    requirement_string[e.loc:e.loc + 8]))
    pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'--extra-'"
    
  2. We use the --no-binary flag for psycopg2 to workaround some SSL issue. I have this on the same line as the psycopg2 entry for documentation, but I guess given its syntax that it could appear on a line by itself: psycopg2==2.7.5 --no-binary psycopg2. This yields an InvalidRequirement error at the same location.

mach-nix fails to find scipy dependency

Hello, thank you for your project, it looks super promising.

Just got this:

The Package 'scipy' cannot be found in the dependency DB used by mach-nix.
Please check the following:
  1. Does the package actually exist on pypi? Please check https://pypi.org/project/scipy/
  2. Does the package's initial release date predate the mach-nix release date?
     If so, either upgrade mach-nix itself or manually specify 'pypi_deps_db_commit' and
     'pypi_deps_db_sha256 for a newer commit of https://github.com/DavHau/pypi-deps-db/commits/master
If none of that works, there was probably a problem while extracting dependency information by the crawler maintaining the database.
Please open an issue here: https://github.com/DavHau/pypi-crawlers/issues/new

By trying mach-nix on github.com/mangaki/zero dependencies.
I'm pretty sure that scipy exists on PyPI and was released before mach-nix :P ; but I don't know what's going on.

Add test pipeline for mach-nix

Add some integration tests to mach-nix.
For example have some requirements.txt files which are used to test if builds are successful.

broken wheel packages

When retrieving packages like numpy and pillow from wheel, they seem to break.

Reproduce:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.1.0";
  });
in mach-nix.mkPython {

  requirements = ''
    # bunch of other requirements
    tensorflow-gpu
    ai-benchmark
  '';

  # no need to specify provider settings since wheel is the default anyways

  # Fix the tensorflow wheel
  overrides_post = [( pythonSelf: pythonSuper: {
    tensorflow-gpu = pythonSuper.tensorflow-gpu.overridePythonAttrs ( oldAttrs: {
      postInstall = ''
        rm $out/bin/tensorboard
      '';
    });
  })];
}

And run the following script in this environment:

#!/usr/bin/env python3

from ai_benchmark import AIBenchmark
benchmark = AIBenchmark()
results = benchmark.run()

Error:

Traceback (most recent call last):
  File "/nix/store/hlnvk6pm39gaprw43hzkz9m3wp3s8f53-python3-3.7.6-env/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/nix/store/hlnvk6pm39gaprw43hzkz9m3wp3s8f53-python3-3.7.6-env/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/nix/store/hlnvk6pm39gaprw43hzkz9m3wp3s8f53-python3-3.7.6-env/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libgfortran-2e0d59d6.so.5.0.0: ELF load command address/offset not properly aligned

Cannot install psycopg2-binary

requirements.txt:

psycopg2-binary==2.8.5

shell.nix:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix";
    ref = "refs/tags/2.2.0";
  });
  pkgs = import <nixpkgs> {};
in with pkgs; mach-nix.mkPythonShell {
  requirements = builtins.readFile ./base.txt;
  providers = {
    pip = "nixpkgs";
  };
}

Output:

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:

    python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.

For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).

error: --- Error --- nix-daemon
builder for '/nix/store/290gcccc7h9vilfp47vm9717jsf4xq5r-python3.8-psycopg2-binary-2.8.5.drv' failed with exit code 1; last 10 log lines:
      python setup.py build_ext --pg-config /path/to/pg_config build ...
  
  or with the pg_config option in 'setup.cfg'.
  
  If you prefer to avoid building psycopg2 from source, please install the PyPI
  'psycopg2-binary' package instead.
  
  For further information please check the 'doc/src/install.rst' file (also at
  <https://www.psycopg.org/docs/install.html>).
error: --- Error -------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix-shell
error: --- Error --- nix-daemon
1 dependencies of derivation '/nix/store/aw5dnpnibcsc9d4c8znh1p4j8gv2wxsv-python3-3.8.5-env.drv' failed to build

I thought I could add postgresql.dev or something like that to buildInputs, but mkPythonShell doesn't take a buildInputs parameter. I'm also surprised it's not able to use the wheel.

Adjust wheel sources?

It would be nice to be able to build the torch wheel with GPU support. Ideally, there is a way for this to work in NixOS with the new top-level variables for HPC that has been implemented (mklSupport, cudaSupport) although I am a bit fuzzy on these. However, I think this should be filed as a separate ticket by someone more knowledgable than myself.

The easy way to get cuda support for a torch wheel is probably just by downloading the official wheels from pytorch.org: https://download.pytorch.org/whl/torch_stable.html. I think mach-nix is provisioning its own snapshots of pypi, but would it be possible to adjust wheel sources with one-off links? Ideally in a format which can be managed by niv

local dependencies?

Wondering how to do the equivalent of python setup.py for a local project. many thanks for this package!

Get rid of python (nix-only code base)

Transform mach-nix into a nix-only project and get rid of all python code.

Currently this project is a weird mix of nix and python. For example: Nix provides python with a json dump of information coming from nixpkgs, which is used by python to eventually generate a nix expression again which is evaluated by nix.

I think the difficult thing would be, to implement a dependency resolution algorithm similar to resolvelib in nix. Not sure how feasible it is to do this in nix. My skills in functional programming are not yet good enough to do that. In case there is anybody capable of doing this, your opinion is much appreciated!

_default = "nixpkgs,wheel,sdist" - provider - nixpkgs fails - wheels works

you wrote that nixpkgs is preferable .. but to me it appears that wheels could work ("better")?

works:

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/2.2.1";
    #ref = "2.2.1";
  });
  overlays = []; # some very useful overlays
  pkgs = import <nixpkgs> { config = { allowUnfree = true; }; inherit overlays; };
in mach-nix.mkPython  rec { 

  # Include my own overlay.

  # Select custom python version (Must be taken from pkgs with the overlay applied)
  python = pkgs.python37;


  providers = {
    # disallow wheels by default
    #_default = "nixpkgs,wheel,sdist";
    _default = "wheel,nixpkgs,sdist";

    # allow wheels only for torch
    # torch = "wheel";
    #setuptools_scm = "wheel,sdist";
  };


  requirements = ''
     # your requirements here
     dask==2.22.0
     pyct==0.4.6
     rasterio==1.1.5
     numba==0.50.1
     arcgis==1.8.2
     datashape==0.5.2
  '';
}

does not work if i try nixpkgs (with or without overlay for setuptools):

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "refs/tags/2.2.1";
    #ref = "2.2.1";
  });
  overlays = []; # some very useful overlays
  pkgs = import <nixpkgs> { config = { allowUnfree = true; }; inherit overlays; };
in mach-nix.mkPython  rec { 

  # Include my own overlay.

  # Select custom python version (Must be taken from pkgs with the overlay applied)
  python = pkgs.python37;


  providers = {
    # disallow wheels by default
    _default = "nixpkgs,wheel,sdist";
    #_default = "wheel,nixpkgs,sdist";

    # allow wheels only for torch
    # torch = "wheel";
    setuptools = "wheel,sdist";
  };


  requirements = ''
     # your requirements here
     dask==2.22.0
     pyct==0.4.6
     rasterio==1.1.5
     numba==0.50.1
     arcgis==1.8.2
     datashape==0.5.2
  '';
}

error:

while evaluating the attribute 'passAsFile' of the derivation 'python3-3.7.6-env' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'requiredPythonModules' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:64:27, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/development/interpreters/python/wrapper.nix:15:13:
while evaluating 'unique' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:643:12, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:66:6:
while evaluating 'requiredPythonModules' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:64:27, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:82:33:
while evaluating 'unique' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:643:12, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:66:6:
while evaluating 'requiredPythonModules' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:64:27, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:82:33:
while evaluating 'unique' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:643:12, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:66:6:
while evaluating 'requiredPythonModules' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:64:27, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:82:33:
while evaluating 'unique' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:643:12, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:66:6:
while evaluating 'requiredPythonModules' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:64:27, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:82:33:
while evaluating 'unique' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:643:12, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:66:6:
while evaluating 'requiredPythonModules' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:64:27, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:82:33:
while evaluating 'unique' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:643:12, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/top-level/python-packages.nix:66:6:
while evaluating 'unique' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:643:12, called from /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:649:17:
while evaluating anonymous function at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/lists.nix:152:16, called from undefined position:
while evaluating the attribute 'out.outPath' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/customisation.nix:151:13:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.7-parso-0.5.2' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:105:3:
while evaluating the attribute 'out.outPath' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/lib/customisation.nix:151:13:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.7-setuptools-49.2.1' at /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:105:3:

error: --- EvalError ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix-shell
in file: /nix/store/dzk0krx7hylcm14wcbhpmqw7pi0z6ll3-nixpkgs-20.03.2652.076c67fdea6/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix (105:3)

tensorflow from nixpkgs fails with mach-nix 2.1.0

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix/";
    ref = "2.1.0";
  });
in mach-nix.mkPython {

  requirements = ''
    tensorflow
  '';

  providers = {
    tensorflow = "nixpkgs";
  };
}

attribute 'sdist' missing, at /nix/store/js7jvdbqp1i804frs52c7aqsqp0zj7py-nix-pypi-fetcher/default.nix:26:25

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.