Re: pybuild and setuptools_scm

2024-07-12 Thread Stefano Rivera
Hi Paul (2024.07.12_10:59:43_+)
> > > The weird thing is that I can run "python3 -m build", even with the
> > > options that pybuild introduces, outside the gbp buildpackage environment,
> > > and it seems that the package data is obtained using setuptools_scm. But
> > > as part of the gbp invocation, the package data is limited to that
> > > mentioned in the deficient pyproject.toml file.
> > 
> > Is your packaging in git? It'll be finding the list of files tracked by
> > git, from git.
> 
> The packaging is in git, yes. I suppose what I don't understand is the role 
> of 
> setuptools_scm in building a package for installation (or the construction of 
> a binary package).

It has 2 roles, both are optional the package may use them or not:
1. Determine the version from VCS tags
2. Determine the list of files that should be shipped in the package.

> A source package will aim to incorporate all of the tracked files, but
> a built/binary package may not.

Yeah, roughly. Binary packages get "data" files included. These are
typically non-Python files inside a Python module.

Source packages get other sources, too.

Stefano

-- 
Stefano Rivera
  http://tumbleweed.org.za/
  +1 415 683 3272



Re: pybuild and setuptools_scm

2024-07-12 Thread Stefano Rivera
Hi Thomas (2024.07.12_12:53:54_+)
> The way to deal with it, is simply something like this:
> 
> export SETUPTOOLS_SCM_PRETEND_VERSION=$(shell dpkg-parsechangelog -SVersion
> | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~git.*//' -e 's/~/.0/' -e
> 's/+dfsg1//' -e 's/+ds1//' | head -n 1)
> 
> and then setuptools-scm knows what version to use without using the Git
> history.
> 
> Probably pybuild does that automatically under the hood (I tend to not use
> pybuild, and so I do the above ...).

It does.

Stefano

-- 
Stefano Rivera
  http://tumbleweed.org.za/
  +1 415 683 3272



Re: pybuild and setuptools_scm

2024-07-12 Thread Dmitry Shachnev
Hi Paul!

On Fri, Jul 12, 2024 at 12:59:43PM +0200, Paul Boddie wrote:
> The packaging is in git, yes. I suppose what I don't understand is the role 
> of 
> setuptools_scm in building a package for installation (or the construction of 
> a binary package). A source package will aim to incorporate all of the 
> tracked 
> files, but a built/binary package may not.

setuptools_scm ships an entry point in [setuptools.file_finders] group,
so when you are building a package from a git checkout, it automatically
includes all files which are tracked in git.

In one of my packages, I had a similar situation that some files were missing
when not building from git. At first I wanted to fix it by adding the missing
files to MANIFEST.in [1]. But then upstream suggested a different approach,
using setuptools_scm's support for git archives [2]. So we went this way [3].
Maybe you can use any of these two approaches in your package, too.

[1]: https://github.com/Python-SIP/sip/pull/28
[2]: https://setuptools-scm.readthedocs.io/en/latest/usage/#git-archives
[3]: https://github.com/Python-SIP/sip/pull/30

--
Dmitry Shachnev


signature.asc
Description: PGP signature


Re: pybuild and setuptools_scm

2024-07-12 Thread Thomas Goirand

On 7/12/24 12:59, Paul Boddie wrote:

I suppose what I don't understand is the role of
setuptools_scm in building a package for installation (or the construction of
a binary package).
It has no role in it. For us (package maintainers), it's just an 
annoyance that we need to deal with. For Python upstream, it's useful...


The way to deal with it, is simply something like this:

export SETUPTOOLS_SCM_PRETEND_VERSION=$(shell dpkg-parsechangelog 
-SVersion | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~git.*//' 
-e 's/~/.0/' -e 's/+dfsg1//' -e 's/+ds1//' | head -n 1)


and then setuptools-scm knows what version to use without using the Git 
history.


Probably pybuild does that automatically under the hood (I tend to not 
use pybuild, and so I do the above ...).


Cheers,

Thomas Goirand (zigo)



Re: pybuild and setuptools_scm

2024-07-12 Thread Paul Boddie
On Friday, 12 July 2024 07:17:27 CEST Stefano Rivera wrote:
> Hi Paul (2024.07.12_00:05:03_+)
> 
> > The weird thing is that I can run "python3 -m build", even with the
> > options that pybuild introduces, outside the gbp buildpackage environment,
> > and it seems that the package data is obtained using setuptools_scm. But
> > as part of the gbp invocation, the package data is limited to that
> > mentioned in the deficient pyproject.toml file.
> 
> Is your packaging in git? It'll be finding the list of files tracked by
> git, from git.

The packaging is in git, yes. I suppose what I don't understand is the role of 
setuptools_scm in building a package for installation (or the construction of 
a binary package). A source package will aim to incorporate all of the tracked 
files, but a built/binary package may not.

Paul




Re: pybuild and setuptools_scm

2024-07-12 Thread Mathias Behrle
* Stefano Rivera: " Re: pybuild and setuptools_scm" (Thu, 11 Jul 2024 23:01:14
  +):

Hi Stefano,

> > I have been struggling to get some software packaged that relies on 
> > setuptools_scm. It seems to effectively ignore the package data section in
> > a pyproject.toml file and to include a broader collection of files when
> > being   
> 
> Which source package is this?
> Where did the source come from? Git or PyPI tarball?
> 
> setuptools_scm gets stuff from SCM and uses it for metadata. During the
> package build, the SCM isn't available (no .git directory in the source
> package). So, it falls back to alternate modes:
> 1. The version gets put in an environment variable by pybuild.
> 2. The list of known files comes from the SOURCES.txt in egg-info. If
>you are using the upstream git for your source, you may be missing
>this. Try switching to a PyPI sdist.

I had a similar problem when setuptools_scm kicked in during the build process
and produced versions different from the orig tarball. Packaging is in git and
tarballs are imported from PyPI.

I disabled the automatic versioning with

https://salsa.debian.org/tryton-team/python-csb43/-/commit/e8788e09818948231a48cc1472a5f5b65fcc

Could you confirm this is the right approach or is there a more elegant way?

Thanks,
Mathias



-- 

Mathias Behrle
PGP/GnuPG key availabable from any keyserver, ID: 0xD6D09BE48405BBF6
AC29 7E5C 46B9 D0B6 1C71  7681 D6D0 9BE4 8405 BBF6