forked from nix-community/pypi2nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
101 lines (94 loc) · 2.79 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{ pkgs ? import <nixpkgs> { }, }:
let
pythonPackages = import ./requirements.nix { inherit pkgs; };
version = "dev";
sourceFilter = with pkgs.lib;
with builtins;
path: type:
let
name = baseNameOf (toString path);
ignoreDirectories = directories:
!(any (directory: directory == name && type == "directory")
directories);
ignoreFileTypes = types:
!(any (type: hasSuffix ("." + type) name && type == "regular") types);
in ignoreDirectories [
"parsemon2.egg-info"
"__pycache__"
"build"
"dist"
".mypy_cache"
] && ignoreFileTypes [ "pyc" ];
source = pkgs.lib.cleanSourceWith {
src = ./.;
filter = sourceFilter;
};
pypi2nixFunction = { mkDerivation, lib, nixfmt, attrs, black, click, flake8
, flake8-unused-arguments, isort, jinja2, mypy, nix-prefetch-github
, packaging, parsley, pdbpp, pytest, pytest-cov, setuptools, setuptools-scm
, toml, twine, git, jsonschema, bumpv, }:
mkDerivation {
name = "pypi2nix-${version}";
src = source;
checkInputs = [
black
flake8
flake8-unused-arguments
mypy
isort
pytest
pytest-cov
twine
pdbpp
nixfmt
bumpv
];
buildInputs = [ ];
nativeBuildInputs = [ git ];
propagatedBuildInputs = [
attrs
click
jinja2
nix-prefetch-github
packaging
parsley
setuptools
toml
jsonschema
];
dontUseSetuptoolsShellHook = true;
checkPhase = ''
nixfmt --check default.nix
echo "Running black ..."
black --check --diff -v setup.py src/ unittests/ mypy/ integrationtests/ scripts/
echo "Running flake8 ..."
flake8 -v setup.py src/ integrationtests/ unittests/ scripts/
mypy --config-file setup.cfg src/
mypy \
--config-file setup.cfg \
unittests/ \
conftest.py \
integrationtests/ \
--allow-untyped-defs \
--ignore-missing-imports
echo "Running pytest ..."
PYTHONPATH=$PWD/src:$PYTHONPATH pytest -v unittests/ -m 'not nix'
'';
shellHook = ''
export PATH=$PWD/scripts:$PATH
export PYTHONPATH=$PWD/src:$PYTHONPATH
'';
meta = {
homepage = "https://github.com/nix-community/pypi2nix";
description =
"A tool that generates nix expressions for your python packages, so you don't have to.";
maintainers = with lib.maintainers; [ seppeljordan ];
};
};
callPackage = pkgs.lib.callPackageWith ({
mkDerivation = pythonPackages.mkDerivation;
lib = pkgs.lib;
nixfmt = pkgs.nixfmt;
git = pkgs.git;
} // pythonPackages.packages);
in callPackage pypi2nixFunction { }