[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Status of cross-building Python extension modules

Hi Dima,

On Thu, Dec 23, 2021 at 02:15:30PM -0800, Dima Kogan wrote:
> What's the status of this currently? I see some stuff on the wiki, but
> it's not obviously up-to-date. I see that libpython3.9-dev is
> Multi-Arch:same. And I was just able to cross-build an extension module
> by installing libpython3.9-dev:foreign.
> But since the package providing /usr/bin/python3 cannot be
> Multi-Arch:same, I could not get the build flags with
>   python3 -msysconfig
> and I had to supply them manually. It looks like the flags I want live
> in
>   /usr/lib/python3.VERSION/_sysconfigdata__ARCH.py

This all looks correct to me. The ARCH part there is a little more
complicated though.

> which is available in Multi-Arch:same, so I COULD set up a build that
> does everything automatically. Does there exist a "right" way to do this
> today?

Indeed, it all is automated already. If you use dh --builsystem pybuild,
it should just work.

> Also I see that python3-all-dev is not Multi-Arch:same, presumably
> because it Depends:python3. So is this supposed to work today? If so,
> what should the Build-Depends look like?

You mostly figured it later:

On Thu, Dec 23, 2021 at 07:22:47PM -0800, Dima Kogan wrote:
> Sorry for the flurry of email. I'm working on a build, and multiple
> questions are coming up. I now have a package cross-building python3
> extensions. I'm doing
>   Build-Depends: libpython3-all-dev, python3:native

Subtly wrong still. You need to figure the right $suffix first. You can
build for the default python ($suffix=""), for all python versions
($suffix="-all") or for a specific python version ($suffix=$version).
Then you go:

    Build-Depends: libpython3$suffix-dev, python3$suffix-dev:any

It seems like you want to build for all python versions here, so you'd
replace python3:native with python3-all-dev:any.

> Two more questions:
> How do I Build-Depends on a c++ compiler? Which package do I ask for?

You don't. It is build-essential. I'd love for C++ to become
non-essential, but we'll have to fix #666743 first. We're looking for
volunteers to test the patches.

> I run the test suite when building natively, so I had lots of
> Build-Depends for that purpose. If cross-building, and thus not running
> tests, those Build-Depends should be ignored. How do I do that?

Skipping tests is orthogonal to cross building. If you cross build from
amd64 to i386, you can run tests. If you enable qemu with binfmt
support, you can run tests. Much of the time we do want to disable tests
during cross builds though. The responsibility for doing so is with the
builder. nocheck is added to both DEB_BUILD_OPTIONS and
DEB_BUILD_PROFILES. Therefore you can annotate such dependencies with


Reply to: