Fix mypy dependencies

This commit is contained in:
Nettika 2026-02-14 13:19:40 -08:00
parent 5f14fab320
commit cf19b5725f
No known key found for this signature in database
GPG key ID: C357EE70D5027BCC
5 changed files with 76 additions and 10 deletions

View file

@ -10,3 +10,5 @@ The build uses Python 2 for legacy build scripts. Python 2, marked insecure in n
- `oils-for-unix-0.37.0.nix` - from-source Oils - `oils-for-unix-0.37.0.nix` - from-source Oils
- `mypy-0.780.nix` - mypy 0.780 (last version to support --py2) built without mypyc - `mypy-0.780.nix` - mypy 0.780 (last version to support --py2) built without mypyc
- `mypy-extensions-0.4.4.nix` - mypy-extensions pinned to <0.5.0 for mypy 0.780 compatibility
- `typed-ast-1.5.5.nix` - typed-ast for Python 2 AST parsing (removed from nixpkgs)

View file

@ -2,17 +2,24 @@
lib, lib,
fetchFromGitHub, fetchFromGitHub,
python3, python3,
# Injected dependencies
mypy-extensions,
typed-ast,
}: }:
python3.pkgs.buildPythonPackage rec { # mypy 0.780 is the last version with --py2 support
# Built without mypyc so mycpp can extend its classes
python3.pkgs.buildPythonPackage (finalAttrs: {
pname = "mypy"; pname = "mypy";
# This is the version oils-for-unix uses for mycpp Python-to-C++ translation
version = "0.780"; version = "0.780";
pyproject = true;
build-system = [ python3.pkgs.setuptools ];
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "python"; owner = "python";
repo = "mypy"; repo = "mypy";
rev = "v${version}"; rev = "v${finalAttrs.version}";
# Fetch submodules to include typeshed (required for type stubs) # Fetch submodules to include typeshed (required for type stubs)
fetchSubmodules = true; fetchSubmodules = true;
hash = "sha256-czwCx6ZjCu3CrVmbI6NbstzWM0GvuPTWJiiUhXSznu4="; hash = "sha256-czwCx6ZjCu3CrVmbI6NbstzWM0GvuPTWJiiUhXSznu4=";
@ -27,14 +34,18 @@ python3.pkgs.buildPythonPackage rec {
# Skip tests to speed up build # Skip tests to speed up build
doCheck = false; doCheck = false;
dependencies = with python3.pkgs; [ # Skip runtime dependency check since we're using pinned older versions
pythonRuntimeDepsCheck = false;
dontCheckRuntimeDeps = true;
dependencies = [
mypy-extensions mypy-extensions
typing-extensions
typed-ast typed-ast
python3.pkgs.typing-extensions
]; ];
# Ensure we're not pulling in a compiled version # Ensure we're not pulling in a compiled version
pythonImportsCheck = [ "mypy" ]; pythonImportsCheck = [ "mypy" ];
meta.license = lib.licenses.mit; meta.license = lib.licenses.mit;
} })

23
mypy-extensions-0.4.4.nix Normal file
View file

@ -0,0 +1,23 @@
{
lib,
fetchFromGitHub,
python3,
}:
# mypy 0.780 requires mypy-extensions <0.5.0
python3.pkgs.buildPythonPackage (finalAttrs: {
pname = "mypy-extensions";
version = "0.4.4";
pyproject = true;
build-system = [ python3.pkgs.setuptools ];
src = fetchFromGitHub {
owner = "python";
repo = "mypy_extensions";
rev = finalAttrs.version;
hash = "sha256-eZdEJJA6HOf1iQLV9H9qqETEByCgIH6oy+wwffGJVuQ=";
};
pythonImportsCheck = [ "mypy_extensions" ];
meta.license = lib.licenses.mit;
})

View file

@ -14,13 +14,16 @@
which, which,
time, time,
readline, readline,
# Python dependencies for mycpp
mypy-extensions ? callPackage ./mypy-extensions-0.4.4.nix { python3 = python310; },
typed-ast ? callPackage ./typed-ast-1.5.5.nix { python3 = python310; },
mypy-for-mycpp ? callPackage ./mypy-0.780.nix {
python3 = python310;
inherit mypy-extensions typed-ast;
},
}: }:
let let
# mypy 0.780 is the last version with --py2 support
# built without mypyc so mycpp can extend its classes
mypy-for-mycpp = callPackage ./mypy-0.780.nix { python3 = python310; };
python = python310.withPackages (ps: [ python = python310.withPackages (ps: [
mypy-for-mycpp mypy-for-mycpp
ps.typing-extensions ps.typing-extensions

27
typed-ast-1.5.5.nix Normal file
View file

@ -0,0 +1,27 @@
{
lib,
fetchFromGitHub,
python3,
}:
# typed-ast was removed from nixpkgs but is needed for mypy 0.780
python3.pkgs.buildPythonPackage (finalAttrs: {
pname = "typed-ast";
version = "1.5.5";
pyproject = true;
build-system = [ python3.pkgs.setuptools ];
src = fetchFromGitHub {
owner = "python";
repo = "typed_ast";
rev = finalAttrs.version;
hash = "sha256-A/FA6ngu8/bbpKW9coJ7unm9GQezGuDhgBWjOhAxm2o=";
};
# GCC 15 uses C23 by default where false/true/bool are keywords
# Force C11 to build this legacy package
env.NIX_CFLAGS_COMPILE = "-std=c11";
pythonImportsCheck = [ "typed_ast" ];
meta.license = lib.licenses.asl20;
})