unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Python package that uses setuptools_scm is builded with version 0.0.0
@ 2024-06-01 19:49 Polyedre
  2024-06-03  1:09 ` Alexis Simon
  0 siblings, 1 reply; 3+ messages in thread
From: Polyedre @ 2024-06-01 19:49 UTC (permalink / raw)
  To: help-guix

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python package that uses setuptools_scm is builded with version 0.0.0
  2024-06-01 19:49 Python package that uses setuptools_scm is builded with version 0.0.0 Polyedre
@ 2024-06-03  1:09 ` Alexis Simon
  2024-10-19 13:12   ` Maxim Cournoyer
  0 siblings, 1 reply; 3+ messages in thread
From: Alexis Simon @ 2024-06-03  1:09 UTC (permalink / raw)
  To: Polyedre, help-guix

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
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python package that uses setuptools_scm is builded with version 0.0.0
  2024-06-03  1:09 ` Alexis Simon
@ 2024-10-19 13:12   ` Maxim Cournoyer
  0 siblings, 0 replies; 3+ messages in thread
From: Maxim Cournoyer @ 2024-10-19 13:12 UTC (permalink / raw)
  To: Alexis Simon; +Cc: Polyedre, help-guix

Hi,

Alexis Simon <alexis.simon@runbox.com> writes:

> 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.

It is if you build from a PyPI archive, which has some metadata
available.  If you build from a git checkout, it expects to compute/find
the version from git, and won't be able to do so in Guix (.git is
stripped for reproducibility).  In this case, you must set
SETUPTOOLS_SCM_PRETEND_VERSION, e.g. as done in python-scanpy:

--8<---------------cut here---------------start------------->8---
           (add-after 'unpack 'pretend-version
             (lambda _
               (setenv "SETUPTOOLS_SCM_PRETEND_VERSION" #$version)))
--8<---------------cut here---------------end--------------->8---

See also the relevant issue/feature request https://issues.guix.gnu.org/54899 I had
reported a long time ago.

Hope that helps,

-- 
Thanks,
Maxim


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-19 13:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-01 19:49 Python package that uses setuptools_scm is builded with version 0.0.0 Polyedre
2024-06-03  1:09 ` Alexis Simon
2024-10-19 13:12   ` Maxim Cournoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).