From 850eae109ca0fee4f890eb1deec541a51f7c07b8 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Mon, 17 Apr 2023 10:42:47 +0200 Subject: [PATCH 01/12] python310Packages.flit-core: Use boostrapping method The flit-core build is getting more adoption lately, which leads to otherwise unresolvable cyclic dependency chains. --- .../python-modules/flit-core/default.nix | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/flit-core/default.nix b/pkgs/development/python-modules/flit-core/default.nix index d0b83d30ea270..6db011ff7a173 100644 --- a/pkgs/development/python-modules/flit-core/default.nix +++ b/pkgs/development/python-modules/flit-core/default.nix @@ -2,12 +2,17 @@ , buildPythonPackage , callPackage , flit +, python }: -buildPythonPackage rec { +# This package uses a bootstrapping process, to escape cyclic +# dependency chains. See +# https://flit.pypa.io/en/latest/bootstrap.html + +buildPythonPackage { pname = "flit-core"; inherit (flit) version; - format = "pyproject"; + format = "other"; outputs = [ "out" @@ -20,11 +25,27 @@ buildPythonPackage rec { cd flit_core ''; + buildPhase = '' + runHook preBuild + ${python.interpreter} -m flit_core.wheel + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + ${python.interpreter} bootstrap_install.py --installdir $out/${python.sitePackages} dist/*.whl + runHook postInstall + ''; + postInstall = '' mkdir $testsout - cp -R ../tests $testsout/tests + mv ../tests $testsout/tests ''; + pythonImportsCheck = [ + "flit_core" + ]; + # check in passthru.tests.pytest to escape infinite recursion with setuptools-scm doCheck = false; From 61836dc6e23a4be2d648bc118f5a1f0f3a4098bd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 01:29:11 +0200 Subject: [PATCH 02/12] python310Packages.bootstrapped-pip: Provide flit-core to build wheel and make sure that flit has a deterministic output name. --- .../python-modules/bootstrapped-pip/default.nix | 7 ++++--- pkgs/development/python-modules/flit/default.nix | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix index a83cfc02849dd..d2e6e830b2894 100644 --- a/pkgs/development/python-modules/bootstrapped-pip/default.nix +++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix @@ -1,7 +1,7 @@ { lib, stdenv, python, makeWrapper, unzip , pipInstallHook , setuptoolsBuildHook -, wheel, pip, setuptools +, wheel, pip, setuptools, flit }: stdenv.mkDerivation rec { @@ -9,7 +9,7 @@ stdenv.mkDerivation rec { inherit (pip) version; name = "${python.libPrefix}-bootstrapped-${pname}-${version}"; - srcs = [ wheel.src pip.src setuptools.src ]; + srcs = [ wheel.src pip.src setuptools.src flit.src ]; sourceRoot = "."; dontUseSetuptoolsBuild = true; @@ -38,9 +38,10 @@ stdenv.mkDerivation rec { mv pip* pip mv setuptools* setuptools mv wheel* wheel + mv flit* flit # Set up PYTHONPATH. The above folders need to be on PYTHONPATH # $out is where we are installing to and takes precedence - export PYTHONPATH="$out/${python.sitePackages}:$(pwd)/pip/src:$(pwd)/setuptools:$(pwd)/setuptools/pkg_resources:$(pwd)/wheel:$PYTHONPATH" + export PYTHONPATH="$out/${python.sitePackages}:$(pwd)/pip/src:$(pwd)/setuptools:$(pwd)/setuptools/pkg_resources:$(pwd)/wheel:$(pwd)/flit/flit_core:$PYTHONPATH" echo "Building setuptools wheel..." pushd setuptools diff --git a/pkgs/development/python-modules/flit/default.nix b/pkgs/development/python-modules/flit/default.nix index 58e10e22a47c2..81e070202bb2f 100644 --- a/pkgs/development/python-modules/flit/default.nix +++ b/pkgs/development/python-modules/flit/default.nix @@ -25,6 +25,7 @@ buildPythonPackage rec { repo = "flit"; rev = version; hash = "sha256-iXf9K/xI4u+dDV0Zf6S08nbws4NqycrTEW0B8/qCjQc="; + name = "${pname}-${version}-source"; }; nativeBuildInputs = [ From 7203705c234b260fdfcf7f7f87b90fd140a330ff Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 01:45:54 +0200 Subject: [PATCH 03/12] python310Packages.installer: bootstrap package --- .../python-modules/installer/default.nix | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/pkgs/development/python-modules/installer/default.nix b/pkgs/development/python-modules/installer/default.nix index 9d3c8185322a1..ff8d59272f808 100644 --- a/pkgs/development/python-modules/installer/default.nix +++ b/pkgs/development/python-modules/installer/default.nix @@ -1,36 +1,64 @@ { lib , buildPythonPackage -, pythonOlder , fetchFromGitHub -, pytestCheckHook + +# bootstrap , flit-core +, python + +# tests +, installer , mock +, pytestCheckHook }: buildPythonPackage rec { pname = "installer"; version = "0.7.0"; - format = "pyproject"; + format = "other"; src = fetchFromGitHub { owner = "pradyunsg"; - repo = pname; - rev = version; + repo = "installer"; + rev = "refs/tags/${version}"; hash = "sha256-thHghU+1Alpay5r9Dc3v7ATRFfYKV8l9qR0nbGOOX/A="; }; - nativeBuildInputs = [ flit-core ]; + nativeBuildInputs = [ + flit-core + ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + ls -lah + mkdir -p $out/${python.sitePackages} + cp -a src/installer* $out/${python.sitePackages} + ${python.interpreter} -m compileall $out/${python.sitePackages} + runHook postInstall + ''; + + pythonImportsCheck = [ + "installer" + ]; + + doCheck = false; nativeCheckInputs = [ - pytestCheckHook mock + pytestCheckHook ]; + passthru.tests = { + pytest = installer.overridePythonAttrs (oldAttrs: { doCheck = true; }); + }; + meta = with lib; { changelog = "https://github.com/pypa/installer/blob/${src.rev}/docs/changelog.md"; homepage = "https://github.com/pradyunsg/installer"; description = "A low-level library for installing a Python package from a wheel distribution"; license = licenses.mit; - maintainers = with maintainers; [ cpcloud fridh ]; + maintainers = teams.python.members; }; } From 78ee28c7c666049a283d05479c133df53f0b19cd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 01:51:12 +0200 Subject: [PATCH 04/12] python310Packages.tomli: boostrap package --- .../python-modules/tomli/default.nix | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/pkgs/development/python-modules/tomli/default.nix b/pkgs/development/python-modules/tomli/default.nix index 8f96a82ad6b8f..5cbeec7ab6219 100644 --- a/pkgs/development/python-modules/tomli/default.nix +++ b/pkgs/development/python-modules/tomli/default.nix @@ -1,13 +1,18 @@ { lib , buildPythonPackage -, callPackage , fetchFromGitHub + +# bootstrap , flit-core +, installer +, python + +# tests , unittestCheckHook - # important downstream dependencies -, flit + # important downstream dependencies , black +, flit , mypy , setuptools-scm }: @@ -15,20 +20,39 @@ buildPythonPackage rec { pname = "tomli"; version = "2.0.1"; - format = "pyproject"; + format = "other"; src = fetchFromGitHub { owner = "hukkin"; - repo = pname; - rev = version; + repo = "tomli"; + rev = "refs/tags/${version}"; hash = "sha256-v0ZMrHIIaGeORwD4JiBeLthmnKZODK5odZVL0SY4etA="; }; - nativeBuildInputs = [ flit-core ]; + nativeBuildInputs = [ + flit-core + installer + ]; + + buildPhase = '' + runHook preBuild + ${python.interpreter} -m flit_core.wheel + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + ${python.interpreter} -m installer --prefix "$out" dist/*.whl + runHook postInstall + ''; - nativeCheckInputs = [ unittestCheckHook ]; + pythonImportsCheck = [ + "tomli" + ]; - pythonImportsCheck = [ "tomli" ]; + nativeCheckInputs = [ + unittestCheckHook + ]; passthru.tests = { # test downstream dependencies From c973046ca9dbc6a396c681ea74d2303c1fca22a3 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 02:39:35 +0200 Subject: [PATCH 05/12] python310Packages.pyproject-hooks: Bootstrap package --- .../pyproject-hooks/default.nix | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/pyproject-hooks/default.nix b/pkgs/development/python-modules/pyproject-hooks/default.nix index 76bf3902c3d21..e19bca23179c2 100644 --- a/pkgs/development/python-modules/pyproject-hooks/default.nix +++ b/pkgs/development/python-modules/pyproject-hooks/default.nix @@ -1,7 +1,13 @@ { lib , buildPythonPackage , fetchPypi + +# build , flit-core +, installer +, python + +# tests , pytestCheckHook , pythonOlder , setuptools @@ -12,11 +18,11 @@ buildPythonPackage rec { pname = "pyproject-hooks"; version = "1.0.0"; - format = "pyproject"; + format = "other"; disabled = pythonOlder "3.7"; - src = fetchPypi rec { + src = fetchPypi { pname = "pyproject_hooks"; inherit version; hash = "sha256-8nGymLl/WVXVP7ErcsH7GUjCLBprcLMVxUztrKAmTvU="; @@ -24,6 +30,7 @@ buildPythonPackage rec { nativeBuildInputs = [ flit-core + installer ]; propagatedBuildInputs = [ @@ -31,6 +38,20 @@ buildPythonPackage rec { tomli ]; + buildPhase = '' + runHook preBuild + ${python.interpreter} -m flit_core.wheel + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + ${python.interpreter} -m installer --prefix "$out" dist/*.whl + runHook postInstall + ''; + + doCheck = false; + nativeCheckInputs = [ pytestCheckHook setuptools @@ -52,6 +73,6 @@ buildPythonPackage rec { homepage = "https://github.com/pypa/pyproject-hooks"; changelog = "https://github.com/pypa/pyproject-hooks/blob/v${version}/docs/changelog.rst"; license = licenses.mit; - maintainers = with maintainers; [ hexa ]; + maintainers = teams.python.members; }; } From 2759ff22df6b1936d69fae76e445b11bf0c665cd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 02:43:45 +0200 Subject: [PATCH 06/12] python310Packages.wheel: 0.38.4 -> 0.40.0 --- .../python-modules/wheel/default.nix | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/pkgs/development/python-modules/wheel/default.nix b/pkgs/development/python-modules/wheel/default.nix index 3be508a0ec590..40598c99f1fda 100644 --- a/pkgs/development/python-modules/wheel/default.nix +++ b/pkgs/development/python-modules/wheel/default.nix @@ -1,20 +1,25 @@ { lib , buildPythonPackage , fetchFromGitHub -, bootstrapped-pip -, setuptools + +# build +, flit-core +, python + +# install +, installer }: buildPythonPackage rec { pname = "wheel"; - version = "0.38.4"; + version = "0.40.0"; format = "other"; src = fetchFromGitHub { owner = "pypa"; repo = pname; rev = version; - hash = "sha256-yZLU0t/nz6kfnnoLL15bybOxN4+SJUaTJsCpGffl1QU="; + hash = "sha256-WZ0KUy2Y6uWoalwQ1jxipo2XvLHlxMoCqbpNWW6H4PQ="; name = "${pname}-${version}-source"; postFetch = '' cd $out @@ -25,10 +30,22 @@ buildPythonPackage rec { }; nativeBuildInputs = [ - bootstrapped-pip - setuptools + flit-core + installer ]; + buildPhase = '' + runHook preBuild + ${python.interpreter} -m flit_core.wheel + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + ${python.interpreter} -m installer --prefix "$out" dist/*.whl + runHook postInstall + ''; + # No tests in archive doCheck = false; pythonImportsCheck = [ "wheel" ]; @@ -52,6 +69,6 @@ buildPythonPackage rec { and as such there is no stable, public API. ''; license = with licenses; [ mit ]; - maintainers = with maintainers; [ siriobalmelli ]; + maintainers = teams.python.members; }; } From 3fab6e261ab7e18fb3fdc8965cb94ed134438274 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 03:09:03 +0200 Subject: [PATCH 07/12] python310Packages.setuptools: 67.4.0 -> 67.7.2 --- .../python-modules/bootstrapped-pip/default.nix | 10 +++++----- pkgs/development/python-modules/setuptools/default.nix | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix index d2e6e830b2894..f77888e56bae5 100644 --- a/pkgs/development/python-modules/bootstrapped-pip/default.nix +++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix @@ -43,14 +43,14 @@ stdenv.mkDerivation rec { # $out is where we are installing to and takes precedence export PYTHONPATH="$out/${python.sitePackages}:$(pwd)/pip/src:$(pwd)/setuptools:$(pwd)/setuptools/pkg_resources:$(pwd)/wheel:$(pwd)/flit/flit_core:$PYTHONPATH" - echo "Building setuptools wheel..." - pushd setuptools - rm pyproject.toml + echo "Building wheel wheel..." + pushd wheel ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . popd - echo "Building wheel wheel..." - pushd wheel + echo "Building setuptools wheel..." + pushd setuptools + rm pyproject.toml ${python.pythonForBuild.interpreter} -m pip install --no-build-isolation --no-index --prefix=$out --ignore-installed --no-dependencies --no-cache . popd diff --git a/pkgs/development/python-modules/setuptools/default.nix b/pkgs/development/python-modules/setuptools/default.nix index c851cef24b308..b2a9817b4dcbc 100644 --- a/pkgs/development/python-modules/setuptools/default.nix +++ b/pkgs/development/python-modules/setuptools/default.nix @@ -10,7 +10,7 @@ let pname = "setuptools"; - version = "67.4.0"; + version = "67.7.2"; # Create an sdist of setuptools sdist = stdenv.mkDerivation rec { @@ -20,7 +20,7 @@ let owner = "pypa"; repo = pname; rev = "refs/tags/v${version}"; - hash = "sha256-QDHycUFA2VRUE9alan8rF0efZTNV3Jt0CskjkCc+in0="; + hash = "sha256-O67HK7hFp4WCqZh15xRtieEcfAcyeZhBqgI8WnZyuzs="; name = "${pname}-${version}-source"; }; From 0cac949af89da170f1d3a6bd9835387f8f573e85 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 03:17:55 +0200 Subject: [PATCH 08/12] python310Packages.pip: 23.0.1 -> 23.1.2 https://pip.pypa.io/en/stable/news/#v23-1-2 --- pkgs/development/python-modules/pip/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pip/default.nix b/pkgs/development/python-modules/pip/default.nix index ebac5724d66fa..3626f9ac3dc55 100644 --- a/pkgs/development/python-modules/pip/default.nix +++ b/pkgs/development/python-modules/pip/default.nix @@ -14,14 +14,14 @@ buildPythonPackage rec { pname = "pip"; - version = "23.0.1"; + version = "23.1.2"; format = "other"; src = fetchFromGitHub { owner = "pypa"; repo = pname; rev = "refs/tags/${version}"; - hash = "sha256-BSonlwKmegrlrQTTIL0avPi61/TY2M0f7kOZpSzPRQk="; + hash = "sha256-bnvpSV6KSY+c3w7FSgTTgBXjBp2/RYbpCBC8DvzYPwY="; name = "${pname}-${version}-source"; }; @@ -49,5 +49,6 @@ buildPythonPackage rec { homepage = "https://pip.pypa.io/"; changelog = "https://pip.pypa.io/en/stable/news/#v${lib.replaceStrings [ "." ] [ "-" ] version}"; priority = 10; + maintainers = lib.teams.python.members; }; } From d01f3928a9cb36bba9aa1178fe24766d4d22baa5 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 03:10:41 +0200 Subject: [PATCH 09/12] python310Packages.pytest: 7.2.1 -> 7.3.1 https://github.com/pytest-dev/pytest/releases/tag/7.3.1 --- pkgs/development/python-modules/pytest/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pytest/default.nix b/pkgs/development/python-modules/pytest/default.nix index 80ea02356cdb1..f3d94d96434ae 100644 --- a/pkgs/development/python-modules/pytest/default.nix +++ b/pkgs/development/python-modules/pytest/default.nix @@ -21,12 +21,12 @@ buildPythonPackage rec { pname = "pytest"; - version = "7.2.1"; + version = "7.3.1"; format = "pyproject"; src = fetchPypi { inherit pname version; - hash = "sha256-1F4JUvNyckGRi4/Q83b1/2swHMB3fG+aVWk1yS2KfUI="; + hash = "sha256-Q0r6/Xix147Qrd8WCtK3ejDTXUvfivI0/mIZGdntFeM="; }; outputs = [ From e0feae2b8c09e2bbbb1d1c6ceb8e20c98fd0ee4c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 03:19:30 +0200 Subject: [PATCH 10/12] python310Packages.bootstrapped-pip: adopt --- pkgs/development/python-modules/bootstrapped-pip/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix index f77888e56bae5..ea902abcc0f99 100644 --- a/pkgs/development/python-modules/bootstrapped-pip/default.nix +++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix @@ -65,5 +65,6 @@ stdenv.mkDerivation rec { description = "Version of pip used for bootstrapping"; license = lib.unique (pip.meta.license ++ setuptools.meta.license ++ wheel.meta.license); homepage = pip.meta.homepage; + maintainers = lib.teams.python.members; }; } From f3166d213c7390c94aedffb3639463cbd442eacd Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 10 May 2023 03:27:07 +0200 Subject: [PATCH 11/12] python310Packages.click: fix compat with pytest>=7.3.0 --- pkgs/development/python-modules/click/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/development/python-modules/click/default.nix b/pkgs/development/python-modules/click/default.nix index bb86932a709ea..1674a7583c5de 100644 --- a/pkgs/development/python-modules/click/default.nix +++ b/pkgs/development/python-modules/click/default.nix @@ -2,6 +2,7 @@ , buildPythonPackage , pythonOlder , fetchPypi +, fetchpatch , importlib-metadata , pytestCheckHook @@ -23,6 +24,15 @@ buildPythonPackage rec { hash = "sha256-doLcivswKXABZ0V16gDRgU2AjWo2r0Fagr1IHTe6e44="; }; + patches = [ + (fetchpatch { + # pytest 7.3.0 compat + name = "click-pytest-7.3.0-compat.patch"; + url = "https://github.com/pallets/click/commit/0f5fbb7e4d893945b4c07cfe4f81cd82fb2900ed.patch"; + hash = "sha256-Xgkrn81K9Qzz1T3lfGHCm6rIl/omG+DhmCa6jj7cauw="; + }) + ]; + propagatedBuildInputs = lib.optionals (pythonOlder "3.8") [ importlib-metadata ]; From 9075febb3a70c411c4636d85e62577ec130e466e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 17 May 2023 19:33:57 +0200 Subject: [PATCH 12/12] poetry2nix: fix eval --- .../tools/poetry2nix/poetry2nix/overrides/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/overrides/default.nix b/pkgs/development/tools/poetry2nix/poetry2nix/overrides/default.nix index 1863132405711..efe4f79479f78 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/overrides/default.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/overrides/default.nix @@ -2670,7 +2670,7 @@ lib.composeManyExtensions [ python = self.python; } ).wheel.override { - inherit (self) buildPythonPackage bootstrapped-pip setuptools; + inherit (self) buildPythonPackage bootstrapped-pip; }).overrideAttrs (old: { inherit (super.wheel) pname name version src; });