Python: Add integration test verifying NIX_PYTHONPATH with Mypy

This commit is contained in:
adisbladis 2020-03-14 16:16:20 +00:00
parent 05571d3059
commit 753122388d
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7
7 changed files with 66 additions and 1 deletions

View File

@ -2,6 +2,7 @@
, runCommand , runCommand
, substituteAll , substituteAll
, lib , lib
, callPackage
}: }:
let let
@ -50,6 +51,14 @@ let
# }; # };
}; };
# All PyPy package builds are broken at the moment
integrationTests = lib.optionalAttrs (python.isPy3k && (!python.isPyPy)) rec {
# Before the addition of NIX_PYTHONPREFIX mypy was broken with typed packages
nix-pythonprefix-mypy = callPackage ./tests/test_nix_pythonprefix {
interpreter = python;
};
};
testfun = name: attrs: runCommand "${python.name}-tests-${name}" ({ testfun = name: attrs: runCommand "${python.name}-tests-${name}" ({
inherit (python) pythonVersion; inherit (python) pythonVersion;
} // attrs) '' } // attrs) ''
@ -61,4 +70,4 @@ let
touch $out/success touch $out/success
''; '';
in lib.mapAttrs testfun envs in lib.mapAttrs testfun envs // integrationTests

View File

@ -0,0 +1,25 @@
{ interpreter, writeText, runCommandNoCC }:
let
python = let
packageOverrides = self: super: {
typeddep = super.callPackage ./typeddep {};
};
in interpreter.override {inherit packageOverrides; self = python;};
pythonEnv = python.withPackages(ps: [
ps.typeddep
ps.mypy
]);
pythonScript = writeText "myscript.py" ''
from typeddep import util
s: str = util.echo("hello")
print(s)
'';
in runCommandNoCC "${interpreter.name}-site-prefix-mypy-test" {} ''
${pythonEnv}/bin/mypy ${pythonScript}
touch $out
''

View File

@ -0,0 +1,11 @@
{ buildPythonPackage }:
buildPythonPackage {
pname = "typeddep";
version = "1.3.3.7";
src = ./.;
}

View File

@ -0,0 +1,18 @@
from setuptools import setup
setup(**{
'name': 'typeddep',
'version': '1.3.3.7',
'description': 'Minimal repro to test mypy and site prefixes with Nix',
'long_description': None,
'author': 'adisbladis',
'author_email': 'adisbladis@gmail.com',
'maintainer': None,
'maintainer_email': None,
'url': None,
'packages': ['typeddep'],
'package_data': {'': ['*']},
'install_requires': [],
'entry_points': {},
'python_requires': '>=3.7,<4.0',
})

View File

@ -0,0 +1,2 @@
def echo(s: str) -> str:
return s