From cf19b5725fc200f8029b0db3832726a7787d6134 Mon Sep 17 00:00:00 2001 From: Nettika Date: Sat, 14 Feb 2026 13:19:40 -0800 Subject: [PATCH] Fix mypy dependencies --- README.md | 2 ++ mypy-0.780.nix | 23 +++++++++++++++++------ mypy-extensions-0.4.4.nix | 23 +++++++++++++++++++++++ oils-for-unix-0.37.0.nix | 11 +++++++---- typed-ast-1.5.5.nix | 27 +++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 mypy-extensions-0.4.4.nix create mode 100644 typed-ast-1.5.5.nix diff --git a/README.md b/README.md index a2a4c37..cf52955 100644 --- a/README.md +++ b/README.md @@ -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 - `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) diff --git a/mypy-0.780.nix b/mypy-0.780.nix index ab8978e..046a2b7 100644 --- a/mypy-0.780.nix +++ b/mypy-0.780.nix @@ -2,17 +2,24 @@ lib, fetchFromGitHub, 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"; - # This is the version oils-for-unix uses for mycpp Python-to-C++ translation version = "0.780"; + pyproject = true; + build-system = [ python3.pkgs.setuptools ]; + src = fetchFromGitHub { owner = "python"; repo = "mypy"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; # Fetch submodules to include typeshed (required for type stubs) fetchSubmodules = true; hash = "sha256-czwCx6ZjCu3CrVmbI6NbstzWM0GvuPTWJiiUhXSznu4="; @@ -27,14 +34,18 @@ python3.pkgs.buildPythonPackage rec { # Skip tests to speed up build doCheck = false; - dependencies = with python3.pkgs; [ + # Skip runtime dependency check since we're using pinned older versions + pythonRuntimeDepsCheck = false; + dontCheckRuntimeDeps = true; + + dependencies = [ mypy-extensions - typing-extensions typed-ast + python3.pkgs.typing-extensions ]; # Ensure we're not pulling in a compiled version pythonImportsCheck = [ "mypy" ]; meta.license = lib.licenses.mit; -} +}) diff --git a/mypy-extensions-0.4.4.nix b/mypy-extensions-0.4.4.nix new file mode 100644 index 0000000..ac7a8bd --- /dev/null +++ b/mypy-extensions-0.4.4.nix @@ -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; +}) diff --git a/oils-for-unix-0.37.0.nix b/oils-for-unix-0.37.0.nix index 36e3dea..a3a82ee 100644 --- a/oils-for-unix-0.37.0.nix +++ b/oils-for-unix-0.37.0.nix @@ -14,13 +14,16 @@ which, time, 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 - # 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: [ mypy-for-mycpp ps.typing-extensions diff --git a/typed-ast-1.5.5.nix b/typed-ast-1.5.5.nix new file mode 100644 index 0000000..d823aa7 --- /dev/null +++ b/typed-ast-1.5.5.nix @@ -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; +})