Hi Polyedre,

I think having python-setuptools-scm in your native-inputs should be enough for building with the right version number.
At least it was enough for me when I encountered this issue before.

Best,
Alexis

On 01/06/2024 12:49, Polyedre wrote:
Hello,

While trying to package maestral[1] for guix, I came across the python
package 'survey'[2]. With the following package description, this
package builds but the version of the resulting python package is 0.0.0.

```scheme
(define-public python-survey
   (package
     (name "python-survey")
     (version "5.3.0")
     (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "survey" version))
        (sha256
         (base32 "1q2b07rq66njyg70fsd0gn6710z1sz9phpy3rd7p7dqxn6rfvi4c"))))
     (build-system pyproject-build-system)
     ;; (propagated-inputs (list python-setuptools-scm))
     (arguments
      `(#:phases (modify-phases %standard-phases
                   (delete 'check))))
     (home-page "https://github.com/Exahilosys/survey";)
     (synopsis "A simple library for creating beautiful interactive prompts.")
     (description
      "This package provides a simple library for creating beautiful interactive
prompts.")
     (license license:expat)))
```

It seems that this package uses setuptools_scm. According to its
documentation, the latter detects the version of the package currently
building directly from "`git` or `hg`" (I guess with the tags?).

As a consequence, this package builds with the version 0.0.0:

```
$ guix shell -f test.scm python -- pip3 freeze
survey==0.0.0
````

It seems that the environment variables SETUPTOOLS_SCM_PRETEND_VERSION
and SETUPTOOLS_SCM_PRETEND_VERSION_FOR_<package>[3] can be used to override
this behavior.

What would be the best way to add an environment variable to te build
process? Just exporting the variable to my shell before calling `guix
build` does not work.

Regards,
Polyedre

[1] https://pypi.org/project/maestral/
[2] https://pypi.org/project/survey/
[3] https://setuptools-scm.readthedocs.io/en/latest/usage/#with-dockerpodman


Reply via email to