Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated nixpkgs. Added custom mypy build. #1636

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
packages = {
tket = pkgs.tket;
pytket = pkgs.pytket;
mypy = pkgs.mypy';
};
devShells = {
default = pkgs.mkShell { buildInputs = [ pkgs.tket pkgs.pytket ]; };
Expand Down
139 changes: 139 additions & 0 deletions nix-support/mypy.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
jake-arkinstall marked this conversation as resolved.
Show resolved Hide resolved
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
gitUpdater,
pythonAtLeast,
pythonOlder,

# build-system
setuptools,
types-psutil,
types-setuptools,
wheel,

# propagates
mypy-extensions,
tomli,
typing-extensions,

# optionals
lxml,
psutil,

# tests
attrs,
filelock,
pytest-xdist,
pytestCheckHook,
nixosTests,
}:

buildPythonPackage rec {
pname = "mypy";
version = "1.13.0";
pyproject = true;

disabled = pythonOlder "3.8";

src = fetchFromGitHub {
owner = "python";
repo = "mypy";
rev = "refs/tags/v${version}";
hash = sha256:P2Ozmj7/7QBmjlveHLsNdYgUAerg0qOoa8pO0iQc5os=;
};
passthru.updateScript = gitUpdater {
rev-prefix = "v";
};

build-system = [
mypy-extensions
setuptools
types-psutil
types-setuptools
typing-extensions
wheel
] ++ lib.optionals (pythonOlder "3.11") [ tomli ];

dependencies = [
mypy-extensions
typing-extensions
] ++ lib.optionals (pythonOlder "3.11") [ tomli ];

optional-dependencies = {
dmypy = [ psutil ];
reports = [ lxml ];
};

# Compile mypy with mypyc, which makes mypy about 4 times faster. The compiled
# version is also the default in the wheels on Pypi that include binaries.
# is64bit: unfortunately the build would exhaust all possible memory on i686-linux.
env.MYPY_USE_MYPYC = stdenv.buildPlatform.is64bit;

# when testing reduce optimisation level to reduce build time by 20%
env.MYPYC_OPT_LEVEL = 1;

pythonImportsCheck =
[
"mypy"
"mypy.api"
"mypy.fastparse"
"mypy.types"
"mypyc"
"mypyc.analysis"
]
++ lib.optionals (!stdenv.hostPlatform.isi686) [
# ImportError: cannot import name 'map_instance_to_supertype' from partially initialized module 'mypy.maptype' (most likely due to a circular import)
"mypy.report"
];

nativeCheckInputs = [
attrs
filelock
pytest-xdist
pytestCheckHook
setuptools
tomli
] ++ lib.flatten (lib.attrValues optional-dependencies);

disabledTests =
[
# fails with typing-extensions>=4.10
# https://github.com/python/mypy/issues/17005
"test_runtime_typing_objects"
]
++ lib.optionals (pythonAtLeast "3.12") [
# requires distutils
"test_c_unit_test"
];

disabledTestPaths =
[
# fails to find tyoing_extensions
"mypy/test/testcmdline.py"
"mypy/test/testdaemon.py"
# fails to find setuptools
"mypyc/test/test_commandline.py"
# fails to find hatchling
"mypy/test/testpep561.py"
]
++ lib.optionals stdenv.hostPlatform.isi686 [
# https://github.com/python/mypy/issues/15221
"mypyc/test/test_run.py"
];

passthru.tests = {
# Failing typing checks on the test-driver result in channel blockers.
inherit (nixosTests) nixos-test-driver;
};

meta = with lib; {
description = "Optional static typing for Python";
homepage = "https://www.mypy-lang.org";
changelog = "https://github.com/python/mypy/blob/${src.rev}/CHANGELOG.md";
license = licenses.mit;
mainProgram = "mypy";
maintainers = with maintainers; [ lnl7 ];
};
}
2 changes: 1 addition & 1 deletion nix-support/pytket.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ in {
} $out/lib/python${super.python3.pythonVersion}/site-packages/pytket/circuit/display/static;
'';
checkInputs = with super.python3.pkgs; [
mypy
self.mypy'
pytest
pytest-cov
pytest-benchmark
Expand Down
1 change: 1 addition & 0 deletions nix-support/third-party-python-packages.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
self: super: {
mypy' = super.python3Packages.callPackage ./mypy.nix {};
pybind11_json = super.stdenv.mkDerivation {
name = "pybind11_json";
src = super.fetchFromGitHub {
Expand Down
Loading