From 34bc09dca920b30054558948863441616cd4b069 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Mon, 4 May 2026 00:26:30 +0300 Subject: [PATCH] resholve: move python2-modules from oil to their folder --- pkgs/development/misc/resholve/default.nix | 3 - pkgs/development/misc/resholve/deps.nix | 78 ----------- pkgs/development/misc/resholve/oildev.nix | 123 ------------------ .../configargparse/default.nix | 28 ++++ .../python2-modules/oildev/default.nix | 115 ++++++++++++++++ .../python2-modules/sedparse/default.nix | 24 ++++ .../resholve/python2-modules/six/default.nix | 24 ++++ .../python2-modules/typing/default.nix | 24 ++++ .../misc/resholve/python2-packages.nix | 18 ++- pkgs/development/misc/resholve/resholve.nix | 19 +-- 10 files changed, 231 insertions(+), 225 deletions(-) delete mode 100644 pkgs/development/misc/resholve/deps.nix delete mode 100644 pkgs/development/misc/resholve/oildev.nix create mode 100644 pkgs/development/misc/resholve/python2-modules/configargparse/default.nix create mode 100644 pkgs/development/misc/resholve/python2-modules/oildev/default.nix create mode 100644 pkgs/development/misc/resholve/python2-modules/sedparse/default.nix create mode 100644 pkgs/development/misc/resholve/python2-modules/six/default.nix create mode 100644 pkgs/development/misc/resholve/python2-modules/typing/default.nix diff --git a/pkgs/development/misc/resholve/default.nix b/pkgs/development/misc/resholve/default.nix index 3e790cb3983b..1582b64fc339 100644 --- a/pkgs/development/misc/resholve/default.nix +++ b/pkgs/development/misc/resholve/default.nix @@ -14,7 +14,6 @@ let }); callPackage = lib.callPackageWith pkgsBuildHost; source = callPackage ./source.nix { }; - deps = callPackage ./deps.nix { }; # not exposed in all-packages resholveBuildTimeOnly = removeKnownVulnerabilities resholve; in @@ -23,8 +22,6 @@ rec { resholve = ( callPackage ./resholve.nix { inherit (source) rSrc version; - inherit (deps.oil) oildev; - inherit (deps) configargparse; inherit resholve-utils; # used only in tests resholve = resholveBuildTimeOnly; diff --git a/pkgs/development/misc/resholve/deps.nix b/pkgs/development/misc/resholve/deps.nix deleted file mode 100644 index 24749d8f6063..000000000000 --- a/pkgs/development/misc/resholve/deps.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ - lib, - callPackage, - fetchFromGitHub, - fetchPypi, - ... -}: -let - python27 = callPackage ./python27.nix { }; -in -/* - Notes on specific dependencies: - - if/when python2.7 is removed from nixpkgs, this may need to figure - out how to build oil's vendored python2 -*/ - -rec { - oil = callPackage ./oildev.nix { - inherit six; - inherit typing; - }; - configargparse = python27.pkgs.buildPythonPackage rec { - pname = "configargparse"; - version = "1.5.3"; - format = "setuptools"; - - src = fetchFromGitHub { - owner = "bw2"; - repo = "ConfigArgParse"; - rev = "v${version}"; - sha256 = "1dsai4bilkp2biy9swfdx2z0k4akw4lpvx12flmk00r80hzgbglz"; - }; - - doCheck = false; - - pythonImportsCheck = [ "configargparse" ]; - - meta = { - description = "Drop-in replacement for argparse"; - homepage = "https://github.com/bw2/ConfigArgParse"; - license = lib.licenses.mit; - }; - }; - six = python27.pkgs.buildPythonPackage rec { - pname = "six"; - version = "1.16.0"; - - src = fetchPypi { - inherit pname version; - sha256 = "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"; - }; - - doCheck = false; - - meta = { - description = "Python 2 and 3 compatibility library"; - homepage = "https://pypi.org/project/six/"; - license = lib.licenses.mit; - }; - }; - typing = python27.pkgs.buildPythonPackage rec { - pname = "typing"; - version = "3.10.0.0"; - - src = fetchPypi { - inherit pname version; - sha256 = "13b4ad211f54ddbf93e5901a9967b1e07720c1d1b78d596ac6a439641aa1b130"; - }; - - doCheck = false; - - meta = { - description = "Backport of typing module to Python versions older than 3.5"; - homepage = "https://docs.python.org/3/library/typing.html"; - license = lib.licenses.psfl; - }; - }; -} diff --git a/pkgs/development/misc/resholve/oildev.nix b/pkgs/development/misc/resholve/oildev.nix deleted file mode 100644 index 9fe3b8ffeff2..000000000000 --- a/pkgs/development/misc/resholve/oildev.nix +++ /dev/null @@ -1,123 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchFromGitHub, - makeWrapper, - re2c, - # oil deps - glibcLocales, - file, - six, - typing, -}: -let - python27 = callPackage ./python27.nix { }; -in - -{ - /* - Upstream isn't interested in packaging this as a library - (or accepting all of the patches we need to do so). - This creates one without disturbing upstream too much. - */ - oildev = python27.pkgs.buildPythonPackage rec { - pname = "oildev-unstable"; - version = "2024-02-26"; - format = "setuptools"; - - src = fetchFromGitHub { - owner = "oilshell"; - repo = "oil"; - # rev == present HEAD of release/0.20.0 - rev = "f730c79e2dcde4bc08e85a718951cfa42102bd01"; - hash = "sha256-HBj3Izh1gD63EzbgZ/9If5vihR5L2HhnyCyMah6rMg4="; - - /* - It's not critical to drop most of these; the primary target is - the vendored fork of Python-2.7.13, which is ~ 55M and over 3200 - files, dozens of which get interpreter script patches in fixup. - - Note: -f is necessary to keep it from being a pain to update - hash on rev updates. Command will fail w/o and not print hash. - */ - postFetch = '' - rm -rf $out/{Python-2.7.13,metrics,py-yajl,rfc,gold,web,testdata,services,demo} - ''; - }; - - # patch to support a python package, pass tests on macOS, drop deps, etc. - patchSrc = fetchFromGitHub { - owner = "abathur"; - repo = "nix-py-dev-oil"; - rev = "v0.20.0.0"; - hash = "sha256-qoA54rnzAdnFZ3k4kRzQWEdgtEjraCT5+NFw8AWnRDk="; - }; - - patches = [ - "${patchSrc}/0001-add_setup_py.patch" - "${patchSrc}/0002-add_MANIFEST_in.patch" - "${patchSrc}/0006-disable_failing_libc_tests.patch" - "${patchSrc}/0007-namespace_via_init.patch" - "${patchSrc}/0009-avoid_nix_arch64_darwin_toolchain_bug.patch" - "${patchSrc}/0010-disable-line-input.patch" - "${patchSrc}/0011-disable-fanos.patch" - "${patchSrc}/0012-disable-doc-cmark.patch" - "${patchSrc}/0013-fix-pyverify.patch" - "${patchSrc}/0015-fix-compiled-extension-import-paths.patch" - ]; - - configureFlags = [ - "--without-readline" - ]; - - nativeBuildInputs = [ - re2c - file - makeWrapper - ]; - - propagatedBuildInputs = [ - six - typing - ]; - - doCheck = true; - - preBuild = '' - build/py.sh all - ''; - - postPatch = '' - patchShebangs asdl build core doctools frontend pyext oil_lang ysh - rm cpp/stdlib.h # keep modules from finding the wrong stdlib? - # work around hard parse failure documented in oilshell/oil#1468 - substituteInPlace osh/cmd_parse.py --replace 'elif self.c_id == Id.Op_LParen' 'elif False' - ''; - - # See earlier note on glibcLocales TODO: verify needed? - LOCALE_ARCHIVE = lib.optionalString ( - stdenv.buildPlatform.libc == "glibc" - ) "${glibcLocales}/lib/locale/locale-archive"; - - # not exhaustive; sample what resholve uses as a sanity check - pythonImportsCheck = [ - "oil" - "oil.asdl" - "oil.core" - "oil.frontend" - "oil._devbuild" - "oil._devbuild.gen.id_kind_asdl" - "oil._devbuild.gen.syntax_asdl" - "oil.osh" - "oil.tools.ysh_ify" - ]; - - meta = { - license = with lib.licenses; [ - psfl # Includes a portion of the python interpreter and standard library - asl20 # Licence for Oil itself - ]; - }; - }; -} diff --git a/pkgs/development/misc/resholve/python2-modules/configargparse/default.nix b/pkgs/development/misc/resholve/python2-modules/configargparse/default.nix new file mode 100644 index 000000000000..b05dee7079c2 --- /dev/null +++ b/pkgs/development/misc/resholve/python2-modules/configargparse/default.nix @@ -0,0 +1,28 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, +}: + +buildPythonPackage rec { + pname = "configargparse"; + version = "1.5.3"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "bw2"; + repo = "ConfigArgParse"; + rev = "v${version}"; + sha256 = "1dsai4bilkp2biy9swfdx2z0k4akw4lpvx12flmk00r80hzgbglz"; + }; + + doCheck = false; + + pythonImportsCheck = [ "configargparse" ]; + + meta = { + description = "Drop-in replacement for argparse"; + homepage = "https://github.com/bw2/ConfigArgParse"; + license = lib.licenses.mit; + }; +} diff --git a/pkgs/development/misc/resholve/python2-modules/oildev/default.nix b/pkgs/development/misc/resholve/python2-modules/oildev/default.nix new file mode 100644 index 000000000000..e8cf4e5df6f2 --- /dev/null +++ b/pkgs/development/misc/resholve/python2-modules/oildev/default.nix @@ -0,0 +1,115 @@ +{ + lib, + stdenv, + buildPythonPackage, + fetchFromGitHub, + makeWrapper, + re2c, + glibcLocales, + file, + six, + typing, +}: + +# Upstream isn't interested in packaging this as a library +# (or accepting all of the patches we need to do so). +# This creates one without disturbing upstream too much. +buildPythonPackage rec { + pname = "oildev-unstable"; + version = "2024-02-26"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "oilshell"; + repo = "oil"; + # rev == present HEAD of release/0.20.0 + rev = "f730c79e2dcde4bc08e85a718951cfa42102bd01"; + hash = "sha256-HBj3Izh1gD63EzbgZ/9If5vihR5L2HhnyCyMah6rMg4="; + + /* + It's not critical to drop most of these; the primary target is + the vendored fork of Python-2.7.13, which is ~ 55M and over 3200 + files, dozens of which get interpreter script patches in fixup. + + Note: -f is necessary to keep it from being a pain to update + hash on rev updates. Command will fail w/o and not print hash. + */ + postFetch = '' + rm -rf $out/{Python-2.7.13,metrics,py-yajl,rfc,gold,web,testdata,services,demo} + ''; + }; + + # patch to support a python package, pass tests on macOS, drop deps, etc. + patchSrc = fetchFromGitHub { + owner = "abathur"; + repo = "nix-py-dev-oil"; + rev = "v0.20.0.0"; + hash = "sha256-qoA54rnzAdnFZ3k4kRzQWEdgtEjraCT5+NFw8AWnRDk="; + }; + + patches = [ + "${patchSrc}/0001-add_setup_py.patch" + "${patchSrc}/0002-add_MANIFEST_in.patch" + "${patchSrc}/0006-disable_failing_libc_tests.patch" + "${patchSrc}/0007-namespace_via_init.patch" + "${patchSrc}/0009-avoid_nix_arch64_darwin_toolchain_bug.patch" + "${patchSrc}/0010-disable-line-input.patch" + "${patchSrc}/0011-disable-fanos.patch" + "${patchSrc}/0012-disable-doc-cmark.patch" + "${patchSrc}/0013-fix-pyverify.patch" + "${patchSrc}/0015-fix-compiled-extension-import-paths.patch" + ]; + + configureFlags = [ + "--without-readline" + ]; + + nativeBuildInputs = [ + re2c + file + makeWrapper + ]; + + propagatedBuildInputs = [ + six + typing + ]; + + doCheck = true; + + preBuild = '' + build/py.sh all + ''; + + postPatch = '' + patchShebangs asdl build core doctools frontend pyext oil_lang ysh + rm cpp/stdlib.h # keep modules from finding the wrong stdlib? + # work around hard parse failure documented in oilshell/oil#1468 + substituteInPlace osh/cmd_parse.py --replace 'elif self.c_id == Id.Op_LParen' 'elif False' + ''; + + # See earlier note on glibcLocales TODO: verify needed? + LOCALE_ARCHIVE = lib.optionalString ( + stdenv.buildPlatform.libc == "glibc" + ) "${glibcLocales}/lib/locale/locale-archive"; + + # not exhaustive; sample what resholve uses as a sanity check + pythonImportsCheck = [ + "oil" + "oil.asdl" + "oil.core" + "oil.frontend" + "oil._devbuild" + "oil._devbuild.gen.id_kind_asdl" + "oil._devbuild.gen.syntax_asdl" + "oil.osh" + "oil.tools.ysh_ify" + ]; + + meta = { + license = with lib.licenses; [ + psfl # Includes a portion of the python interpreter and standard library + asl20 # Licence for Oil itself + ]; + }; +} diff --git a/pkgs/development/misc/resholve/python2-modules/sedparse/default.nix b/pkgs/development/misc/resholve/python2-modules/sedparse/default.nix new file mode 100644 index 000000000000..3426d25d23a0 --- /dev/null +++ b/pkgs/development/misc/resholve/python2-modules/sedparse/default.nix @@ -0,0 +1,24 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, +}: + +buildPythonPackage { + pname = "sedparse"; + version = "0.1.2"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "aureliojargas"; + repo = "sedparse"; + rev = "0.1.2"; + hash = "sha256-Q17A/oJ3GZbdSK55hPaMdw85g43WhTW9tuAuJtDfHHU="; + }; + + meta = { + description = "Python port of GNU sed's parser"; + homepage = "https://github.com/aureliojargas/sedparse"; + license = lib.licenses.gpl3Plus; + }; +} diff --git a/pkgs/development/misc/resholve/python2-modules/six/default.nix b/pkgs/development/misc/resholve/python2-modules/six/default.nix new file mode 100644 index 000000000000..951c42c107d1 --- /dev/null +++ b/pkgs/development/misc/resholve/python2-modules/six/default.nix @@ -0,0 +1,24 @@ +{ + lib, + buildPythonPackage, + fetchPypi, +}: + +buildPythonPackage rec { + pname = "six"; + version = "1.16.0"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + sha256 = "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"; + }; + + doCheck = false; + + meta = { + description = "Python 2 and 3 compatibility library"; + homepage = "https://pypi.org/project/six/"; + license = lib.licenses.mit; + }; +} diff --git a/pkgs/development/misc/resholve/python2-modules/typing/default.nix b/pkgs/development/misc/resholve/python2-modules/typing/default.nix new file mode 100644 index 000000000000..d26e5e2da706 --- /dev/null +++ b/pkgs/development/misc/resholve/python2-modules/typing/default.nix @@ -0,0 +1,24 @@ +{ + lib, + buildPythonPackage, + fetchPypi, +}: + +buildPythonPackage rec { + pname = "typing"; + version = "3.10.0.0"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + sha256 = "13b4ad211f54ddbf93e5901a9967b1e07720c1d1b78d596ac6a439641aa1b130"; + }; + + doCheck = false; + + meta = { + description = "Backport of typing module to Python versions older than 3.5"; + homepage = "https://docs.python.org/3/library/typing.html"; + license = lib.licenses.psfl; + }; +} diff --git a/pkgs/development/misc/resholve/python2-packages.nix b/pkgs/development/misc/resholve/python2-packages.nix index 733e6cadd7c3..45e066d3311c 100644 --- a/pkgs/development/misc/resholve/python2-packages.nix +++ b/pkgs/development/misc/resholve/python2-packages.nix @@ -1,6 +1,7 @@ -# Extension with Python 2 packages that is overlaid on top -# of the Python 3 packages set. This way, Python 2+3 compatible -# packages can still be used. +# Python 2 overlay applied to resholve's local python27 package set. +# Provides the bootstrap toolchain (bootstrapped-pip/pip/setuptools/wheel) +# plus resholve's own python2 build dependencies, kept here so all of +# resholve's python2 surface lives in one place. self: super: @@ -14,4 +15,15 @@ with super; setuptools = callPackage ./python2-modules/setuptools { }; wheel = callPackage ./python2-modules/wheel { }; + + # resholve build deps + configargparse = callPackage ./python2-modules/configargparse { }; + + six = callPackage ./python2-modules/six { }; + + typing = callPackage ./python2-modules/typing { }; + + oildev = callPackage ./python2-modules/oildev { }; + + sedparse = callPackage ./python2-modules/sedparse { }; } diff --git a/pkgs/development/misc/resholve/resholve.nix b/pkgs/development/misc/resholve/resholve.nix index 823216ba800a..67200729d4ef 100644 --- a/pkgs/development/misc/resholve/resholve.nix +++ b/pkgs/development/misc/resholve/resholve.nix @@ -1,12 +1,9 @@ { lib, callPackage, - fetchFromGitHub, installShellFiles, rSrc, version, - oildev, - configargparse, gawk, binlore, resholve, @@ -15,20 +12,6 @@ let python27 = callPackage ./python27.nix { }; in -let - sedparse = python27.pkgs.buildPythonPackage { - pname = "sedparse"; - version = "0.1.2"; - format = "setuptools"; - src = fetchFromGitHub { - owner = "aureliojargas"; - repo = "sedparse"; - rev = "0.1.2"; - hash = "sha256-Q17A/oJ3GZbdSK55hPaMdw85g43WhTW9tuAuJtDfHHU="; - }; - }; - -in python27.pkgs.buildPythonApplication { pname = "resholve"; inherit version; @@ -36,7 +19,7 @@ python27.pkgs.buildPythonApplication { nativeBuildInputs = [ installShellFiles ]; - propagatedBuildInputs = [ + propagatedBuildInputs = with python27.pkgs; [ oildev configargparse sedparse