Subject: [PATCH python 15/20] gnu: poetry: Fix build.

From: John Kehayias <[email-masked]>
Date: Fri, 28 Apr 2023 05:51:33 +0000

* gnu/packages/python-xyz.scm (poetry)[build-system]: Switch to
pyproject-build-system.
[arguments]{phases}: New phase 'loosen-requirements' to fix build and avoid
circular dependency.
{test-flags}: Disable failing tests.
[propagated-inputs]: Remove python-pip.  Add python-dulwich, python-installer,
python-jsonschema, python-platfromdirs, python-pypa-build,
python-pyproject-hooks, python-tomli, and python-trove-classifiers.
[native-inputs]: Add python-deepdiff, python-httpretty, python-pytest,
python-pytest-mock, and python-pytest-xdist.
---
 gnu/packages/python-xyz.scm | 62 ++++++++++++++++++++++++++++++-------
 1 file changed, 50 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 8b61cba8ae..cbe3bb1094 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -18144,37 +18144,75 @@ (define-public poetry
        (sha256
         (base32
          "0g0vczn6qa4b2bdkq4k7fm1g739vyxp2iiblwwsrcmw24jj81m8b"))))
-    (build-system python-build-system)
+    (build-system pyproject-build-system)
     (arguments
-     `(#:tests? #f                      ;PyPI does not have tests
-       ;; #:phases
-       ;; (modify-phases %standard-phases
-       ;;   (add-before 'build 'patch-setup-py
-       ;;     (lambda _
-       ;;       (substitute* "setup.py"
-       ;;         ;; Relax some of the requirements.
-       ;;         (("(keyring>=21.2.0),<22.0.0" _ keyring) keyring)
-       ;;         (("(packaging>=20.4),<21.0" _ packaging) packaging)))))
-       ))
+     (list #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'loosen-requirements
+                 (lambda _
+                   (substitute* "pyproject.toml"
+                     ;; Permit newer versions of platformdirs.
+                     (("platformdirs =.*") "platformdirs = \"^3.0.0\"\n")
+                     ;; Our python-trove-classifiers reports the wrong version.
+                     (("trove-classifiers =.*") "trove-classifiers = \"*\"\n")
+                     ;; Avoid circular dependency by not including the export
+                     ;; plugin requirement.  See
+                     ;; <https://github.com/python-poetry/poetry/pull/5980>
+                     ;; and
+                     ;; <https://github.com/python-poetry/poetry/issues/6441>
+                     ;; for upstream status in resolving this cycle.
+                     (("poetry-plugin-export.*") "")))))
+           #:test-flags
+           '(let ((disabled-tests
+                   ;; The following tests currently fail, requiring network
+                   ;; connectivity and/or trying to write in the build
+                   ;; environment.
+                   ;; TODO: Some of these might be worked around.
+                   (list "test_shell"
+                         (string-append "test_build_backend_errors_are_"
+                                        "reported_correctly_if_caused_by_subprocess")
+                         "test_prepare_sdist"
+                         (string-append "test_executor_should_write_"
+                                        "pep610_url_references_for_non_wheel_files")
+                         "test_uninstall_git_package_nspkg_pth_cleanup"
+                         "test_builder_setup_generation_runs_with_pip_editable"
+                         "test_prepare_directory"
+                         "test_prepare_directory_with_extensions"
+                         "test_prepare_directory_editable")))
+              (list "-k" (string-append "not "
+                                        (string-join disabled-tests
+                                                     " and not "))))))
     (propagated-inputs
      (list python-cachecontrol
            python-cachy
            python-cleo
            python-crashtest
+           python-dulwich
            python-entrypoints
            python-html5lib
+           python-installer
+           python-jsonschema
            python-keyring
            python-msgpack
            python-packaging
            python-pexpect
-           python-pip
            python-pkginfo
+           python-platformdirs
+           python-pypa-build
            python-poetry-core
+           python-pyproject-hooks
            python-requests
            python-requests-toolbelt
            python-shellingham
+           python-tomli
            python-tomlkit
+           python-trove-classifiers
            python-virtualenv))
+    (native-inputs (list python-deepdiff
+                         python-httpretty
+                         python-pytest
+                         python-pytest-mock
+                         python-pytest-xdist))
     (home-page "https://python-poetry.org")
     (synopsis "Python dependency management and packaging made easy")
     (description "Poetry is a tool for dependency management and packaging
--
2.39.2