Subject: Re: [bug#58310] [PATCH 04/14] gnu: Add python-hatchling-bootstrap.

From: Garek Dyszel <[email-masked]>
Date: Fri, 04 Nov 2022 11:15:49 -0400

Hi Lars,

At 20:59 2022-11-03 UTC+0900, Lars-Dominik Braun wrote:
> And hatchling’s dependencies actually belong to hatch,
> not hatchling, so there should be no cycles with python-xyz.scm.

It seems dependencies from python-xyz.scm are still required to enter
the build process for python-hatchling-bootstrap, even if hatchling does
not explicitly require them.

 (1) If we comment out the dependencies from python-xyz.scm, we get this
error:
--8<---------------cut here---------------start------------->8---
starting phase `build'
* Getting dependencies for wheel...

ERROR Missing dependencies:
	pathspec>=0.10.1
	pluggy>=1.0.0
--8<---------------cut here---------------end--------------->8---

(2) If we minimize the dependency list to the following, then
python-hatchling-bootstrap builds correctly:
--8<---------------cut here---------------start------------->8---
(inputs (list python-editables
              python-packaging-bootstrap
	      ;; Below from python-xyz.scm, can be moved to python-build.scm
	      python-pathspec-0.10.1
	      ;; Below from python-xyz.scm, can be moved to python-build.scm
	      python-pluggy-1.0
	      python-tomli))
--8<---------------cut here---------------end--------------->8---
Changing the build system to (pyproject-build-system) produces the same
results.

Since python-pluggy-1.0 and python-pathspec depend only on packages
defined in python-build.scm, I propose moving them to python-build.scm.

What do you think?

Garek

---
Revised python-hatchling-boostrap definition (in case it is of
interest):
--8<---------------cut here---------------start------------->8---
(define-public python-hatchling-bootstrap
  (package
    (name "python-hatchling-bootstrap")
    (version "1.10.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/pypa/hatch")
                    (commit (string-append "hatchling-v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0ahx62w711a2vnb91ahqxrw8yi0gq0kfch3fk6akzngd13376czj"))))
    ;; python-pypa-build needed for bootstrapping.
    ;; Otherwise we get a circular reference:
    ;; python-hatchling trying to build itself, without
    ;; first having hatchling installed.
    (inputs (list python-editables
                  python-packaging-bootstrap
                  ;; Below from python-xyz.scm, can be moved to python-build.scm
                  python-pathspec-0.10.1
                  ;; Below from python-xyz.scm, can be moved to python-build.scm
                  python-pluggy-1.0
                  python-tomli))
    (build-system pyproject-build-system)
    (arguments
     `(;; Tests depend on module python-hatch, which this
       ;; is bootstrapping.
       #:tests? #f
       #:phases
       ;; Test for pyproject-build-system. This pre-build phase fails.
       ;;
       ;; (modify-phases %standard-phases
       ;;   (add-before 'build 'chdir-to-backend
       ;;     (lambda _
       ;;       (chdir "backend"))))
       ;;
       
       ;; Original phases.
       (modify-phases %standard-phases
                  (replace 'build
                    (lambda _
                      (chdir "backend")
                      ;; ZIP does not support timestamps before 1980.
                      (setenv "SOURCE_DATE_EPOCH" "315532800")
                      (invoke "python"
                              "-m"
                              "build"
                              "--wheel"
                              "--no-isolation"
                              ".")))
                  (replace 'install
                    (lambda* (#:key outputs #:allow-other-keys)
                      (let ((whl (car (find-files "dist" "\\.whl$"))))
                        (invoke "pip"
                                "--no-cache-dir"
                                "--no-input"
                                "install"
                                "--no-deps"
                                "--prefix"
                                (assoc-ref %outputs "out")
                                whl)))))))
    (home-page "https://ofek.dev/projects/hatch/")
    (synopsis "Bootstrap binaries to build @code{python-hatch}")
    (description "Bootstrap binaries to build @code{python-hatch}")
    ;; MIT License
    (license license:expat)))
--8<---------------cut here---------------end--------------->8---