From 17c15cc3ff1e51f2c3621589e8e6cc9d33826ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= <nix@dotlambda.de> Date: Tue, 20 Dec 2022 08:50:14 -0800 Subject: [PATCH 1/5] poetry: don't use poetry2nix --- pkgs/development/tools/poetry2nix/poetry2nix/default.nix | 3 +-- pkgs/top-level/all-packages.nix | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/default.nix b/pkgs/development/tools/poetry2nix/poetry2nix/default.nix index 4de0b54ac1b9..f52bf6c0c92c 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/default.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/default.nix @@ -1,6 +1,5 @@ { pkgs ? import <nixpkgs> { } , lib ? pkgs.lib -, poetry ? null , poetryLib ? import ./lib.nix { inherit lib pkgs; stdenv = pkgs.stdenv; } }: let @@ -143,7 +142,7 @@ lib.makeScope pkgs.newScope (self: { }; getFunctorFn = fn: if builtins.typeOf fn == "set" then fn.__functor else fn; - poetryPkg = poetry.override { inherit python; }; + poetryPkg = pkgs.callPackage ./pkgs/poetry { inherit python; }; scripts = pyProject.tool.poetry.scripts or { }; hasScripts = scripts != { }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b7cf3dcc6e34..cc471b0bcbf8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16363,9 +16363,8 @@ with pkgs; pew = callPackage ../development/tools/pew {}; - poetry = callPackage ../development/tools/poetry2nix/poetry2nix/pkgs/poetry { - python = python3; - }; + poetry = with python3.pkgs; toPythonApplication poetry; + poetry2nix = callPackage ../development/tools/poetry2nix/poetry2nix { inherit pkgs lib; }; From 8fcba0f7228c0aaddae93b94c08893e0b0e8dcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= <nix@dotlambda.de> Date: Mon, 9 Jan 2023 05:43:47 -0800 Subject: [PATCH 2/5] poetry: remove from pythonPackages It is a CLI tool for Python packaging. Python modules should use poetry-core as a build-time dependency instead. --- .../package-management}/poetry/default.nix | 54 ++++--------------- pkgs/top-level/all-packages.nix | 2 +- pkgs/top-level/python-aliases.nix | 1 + pkgs/top-level/python-packages.nix | 2 - 4 files changed, 12 insertions(+), 47 deletions(-) rename pkgs/{development/python-modules => tools/package-management}/poetry/default.nix (79%) diff --git a/pkgs/development/python-modules/poetry/default.nix b/pkgs/tools/package-management/poetry/default.nix similarity index 79% rename from pkgs/development/python-modules/poetry/default.nix rename to pkgs/tools/package-management/poetry/default.nix index 83c91e847455..decc872c0501 100644 --- a/pkgs/development/python-modules/poetry/default.nix +++ b/pkgs/tools/package-management/poetry/default.nix @@ -1,52 +1,18 @@ { lib -, backports-cached-property -, buildPythonPackage -, cachecontrol -, cachy -, cleo -, crashtest -, deepdiff -, dulwich -, fetchFromGitHub -, filelock -, flatdict -, html5lib -, httpretty -, importlib-metadata -, installShellFiles -, intreehooks -, jsonschema -, keyring -, lockfile -, packaging -, pexpect -, pkginfo -, platformdirs -, poetry-core -, poetry-plugin-export -, pytest-mock -, pytest-xdist -, pytestCheckHook -, pythonAtLeast -, pythonOlder -, requests -, requests-toolbelt -, shellingham , stdenv -, tomli -, tomlkit -, trove-classifiers -, urllib3 -, virtualenv -, xattr +, python3 +, fetchFromGitHub +, installShellFiles }: -buildPythonPackage rec { +let + python = python3; +in python.pkgs.buildPythonApplication rec { pname = "poetry"; version = "1.3.1"; format = "pyproject"; - disabled = pythonOlder "3.7"; + disabled = python.pkgs.pythonOlder "3.7"; src = fetchFromGitHub { owner = "python-poetry"; @@ -59,7 +25,7 @@ buildPythonPackage rec { installShellFiles ]; - propagatedBuildInputs = [ + propagatedBuildInputs = with python.pkgs; [ cachecontrol cleo crashtest @@ -97,7 +63,7 @@ buildPythonPackage rec { --zsh <($out/bin/poetry completions zsh) \ ''; - checkInputs = [ + checkInputs = with python.pkgs; [ cachy deepdiff flatdict @@ -132,7 +98,7 @@ buildPythonPackage rec { "lock" # fs permission errors "test_builder_should_execute_build_scripts" - ] ++ lib.optionals (pythonAtLeast "3.10") [ + ] ++ lib.optionals (python.pythonAtLeast "3.10") [ # RuntimeError: 'auto_spec' might be a typo; use unsafe=True if this is intended "test_info_setup_complex_pep517_error" ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cc471b0bcbf8..3b8b9d7376f3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16363,7 +16363,7 @@ with pkgs; pew = callPackage ../development/tools/pew {}; - poetry = with python3.pkgs; toPythonApplication poetry; + poetry = callPackage ../tools/package-management/poetry { }; poetry2nix = callPackage ../development/tools/poetry2nix/poetry2nix { inherit pkgs lib; diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix index c444f6bb9d64..b7eb2cabec40 100644 --- a/pkgs/top-level/python-aliases.nix +++ b/pkgs/top-level/python-aliases.nix @@ -134,6 +134,7 @@ mapAliases ({ pathpy = path; # added 2022-04-12 pdfminer = pdfminer-six; # added 2022-05-25 pep257 = pydocstyle; # added 2022-04-12 + poetry = throw "poetry was promoted to a top-level attribute, use poetry-core to build Python packages"; # added 2023-01-09 poetry2conda = throw "poetry2conda was promoted to a top-level attribute"; # Added 2022-10-02 poster3 = throw "poster3 is unmaintained and source is no longer available"; # added 2023-05-29 postorius = throw "Please use pkgs.mailmanPackages.postorius"; # added 2022-04-29 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 216383e012b1..df4fe30b2111 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7300,8 +7300,6 @@ self: super: with self; { podcats = callPackage ../development/python-modules/podcats { }; - poetry = callPackage ../development/python-modules/poetry { }; - poetry-core = callPackage ../development/python-modules/poetry-core { }; poetry-dynamic-versioning = callPackage ../development/python-modules/poetry-dynamic-versioning { }; From 634718637cd8fefd0c46de1d6c4b9e094e5d26e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= <nix@dotlambda.de> Date: Mon, 9 Jan 2023 06:45:38 -0800 Subject: [PATCH 3/5] beancount-ing-diba: use poetry-core --- .../office/beancount/beancount-ing-diba.nix | 19 +++++++++++++------ pkgs/top-level/all-packages.nix | 4 +--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pkgs/applications/office/beancount/beancount-ing-diba.nix b/pkgs/applications/office/beancount/beancount-ing-diba.nix index 67c76f738119..e1f3cb55fd8a 100644 --- a/pkgs/applications/office/beancount/beancount-ing-diba.nix +++ b/pkgs/applications/office/beancount/beancount-ing-diba.nix @@ -1,11 +1,10 @@ { lib -, stdenv +, python3 , fetchFromGitHub -, buildPythonApplication -, poetry +, fetchpatch }: -buildPythonApplication rec { +python3.pkgs.buildPythonApplication rec { pname = "beancount-ing-diba"; version = "0.6.0"; @@ -16,10 +15,18 @@ buildPythonApplication rec { sha256 = "sha256-1cdXqdeTz38n0g13EXJ1/IF/gJJCe1uL/Z5NJz4DL+E="; }; + patches = [ + (fetchpatch { + name = "use-poetry-core.patch"; + url = "https://github.com/siddhantgoel/beancount-ing/commit/2d030330eed313a32c3968a2c8ce9400c6d18a41.patch"; + hash = "sha256-6v7eQhgj6d4x9uWSyuO3IxXrSWkJZRS/M4N3j0H3R/U="; + }) + ]; + format = "pyproject"; - nativeBuildInputs = [ - poetry + nativeBuildInputs = with python3.pkgs; [ + poetry-core ]; meta = with lib; { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3b8b9d7376f3..45bfd7eaa83d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -34355,9 +34355,7 @@ with pkgs; bastet = callPackage ../games/bastet { }; - beancount-ing-diba = callPackage ../applications/office/beancount/beancount-ing-diba.nix { - inherit (python3Packages) buildPythonApplication; - }; + beancount-ing-diba = callPackage ../applications/office/beancount/beancount-ing-diba.nix { }; black-hole-solver = callPackage ../games/black-hole-solver { inherit (perlPackages) PathTiny; From 7020893918157a0c67ce3b61967afc3a5205b13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= <nix@dotlambda.de> Date: Wed, 11 Jan 2023 19:20:46 -0800 Subject: [PATCH 4/5] poetry: don't propagate dependencies This was also done for poetry as packaged using poetry2nix. --- pkgs/tools/package-management/poetry/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/tools/package-management/poetry/default.nix b/pkgs/tools/package-management/poetry/default.nix index decc872c0501..25c2521181ce 100644 --- a/pkgs/tools/package-management/poetry/default.nix +++ b/pkgs/tools/package-management/poetry/default.nix @@ -63,6 +63,12 @@ in python.pkgs.buildPythonApplication rec { --zsh <($out/bin/poetry completions zsh) \ ''; + # Propagating dependencies leaks them through $PYTHONPATH which causes issues + # when used in nix-shell. + postFixup = '' + rm $out/nix-support/propagated-build-inputs + ''; + checkInputs = with python.pkgs; [ cachy deepdiff From af0675c578a558e7d443d892807d29d5b63c07cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= <nix@dotlambda.de> Date: Wed, 11 Jan 2023 19:52:24 -0800 Subject: [PATCH 5/5] poetry: 1.3.1 -> 1.3.2 https://github.com/python-poetry/poetry/releases/tag/1.3.2 --- pkgs/tools/package-management/poetry/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/package-management/poetry/default.nix b/pkgs/tools/package-management/poetry/default.nix index 25c2521181ce..f5ee82b786ce 100644 --- a/pkgs/tools/package-management/poetry/default.nix +++ b/pkgs/tools/package-management/poetry/default.nix @@ -9,7 +9,7 @@ let python = python3; in python.pkgs.buildPythonApplication rec { pname = "poetry"; - version = "1.3.1"; + version = "1.3.2"; format = "pyproject"; disabled = python.pkgs.pythonOlder "3.7"; @@ -18,7 +18,7 @@ in python.pkgs.buildPythonApplication rec { owner = "python-poetry"; repo = pname; rev = "refs/tags/${version}"; - hash = "sha256-yiV2Y0vBF0d7BFfT5wonzRUGHVH040PZrlAUpVTFCZc="; + hash = "sha256-12EiEGI9Vkb6EUY/W2KWeLigxWra1Be4ozvi8njBpEU="; }; nativeBuildInputs = [ @@ -119,6 +119,6 @@ in python.pkgs.buildPythonApplication rec { homepage = "https://python-poetry.org/"; description = "Python dependency management and packaging made easy"; license = licenses.mit; - maintainers = with maintainers; [ jakewaksbaum ]; + maintainers = with maintainers; [ jakewaksbaum dotlambda ]; }; }