Skip to content

Conversation

jefferyto
Copy link
Member

Maintainer: me
Compile tested: most/all architectures, 2023-07-09 snapshot sdks
Run tested: armsr-armv7/armsr-armv8/malta-be/x86-generic/x86-64 (qemu), 2023-07-09 snapshot

Description:
The main purpose of these changes are to restore the platform triplet to paths. The direct benefit of this would be to have setuptools-rust build successfully (and so enable building of Python packages with Rust extensions), as PyO3 expects to find the platform triplet in the _sysconfigdata file name. This should also enable maturin-based packages (see #20410) though I have not verified this / know enough about maturin to say.

I have not been able to reproduce the issues I found in #12754 regarding the platform triplet and host/target module loading; I'm not sure if this is result of changes in Python itself (there has been work done recently to improve cross-compilation), changes in our Python package build process (i.e. moving away from pip), or something else.

I'm not sure if these changes affect installing host Python packages using the previous/deprecated method (with host pip requirements files); I plan on submitting changes to downstream projects to move them toward the current process (including adding host packages here if necessary).

Please see the individual commit messages for details.

@BKPepe BKPepe requested a review from commodo July 13, 2023 07:55
exit 1
fi

while IFS='|' read cmd path file_mode dir_mode; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phew...
quite the rewrite :)

@commodo
Copy link
Contributor

commodo commented Jul 14, 2023

so, the platform triplet patches worry me a bit;

they seem like we're starting our own Python fork downstream;
i would NAK them, but ultimately you are the official Python maintainer

i would suggest pushing these patches upstream, and then let them trickle down back

if you go AWOL again for too long, and someone else needs to pick Python up again (whether it's me or someone else), the patches will be ¯\_(ツ)_/¯
if that happens, i would not mind dropping them (during an upgrade of Python) and keeping the "old" (current) way

Copy link
Contributor

@commodo commodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to upstream the new patches

@commodo
Copy link
Contributor

commodo commented Jul 14, 2023

the rest of the changes are fine from my side

@jefferyto
Copy link
Member Author

jefferyto commented Jul 15, 2023

I would prefer to upstream the patches as well but python/cpython#96001 has been stuck in draft status for months. I'll try pinging them again.

Without the patches, the triplet will have -gnu instead of -musl; this is because configure is run with arguments like --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-pc-linux-gnu (set by default by OpenWrt buildroot). So some patch or change would still be necessary on our side.

Edit: I forgot to mention, because of how configure uses __mips_hard_float as the test for mips, for most of our mips targets (which are soft float) they would get an empty platform triplet without these changes.

I also intentionally split my changes into separate patches to make them as understandable as possible. If someone else wants to remove them without a good explanation or demonstrating they understand what they are doing, then I would question the value of their contribution.

@jefferyto
Copy link
Member Author

BTW the various -musl values (muslsf, musln32, etc.) come from https://github.com/richfelker/musl-cross-make#supported-targets. That project (musl-cross-make) is linked to from the musl home page: https://musl.libc.org/

I will update commit message for "python3: Fix/expand platform triplet detection" with a reference to that list of targets.

@jefferyto
Copy link
Member Author

Changes to filespec script:

  • Fix typos in file_dir_chmod
  • Add -r option to read
  • Use here document (<<) instead of here string (<<<), removing the only Bashism in the script
  • Change shebang to /bin/sh

@jefferyto jefferyto marked this pull request as draft July 25, 2023 05:46
There is no need to use Py3Package for python3 as it does not package
any Python files; it is an empty package with dependencies to install
the full Python installation.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* Fix default Python package description not included in individual
  package descriptions

* Update default Python package description text (from General Python
  FAQ, "What is Python?")

* Add package descriptions for Python module packages

* Reduce duplication in package titles

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* Support wildcards in install (`+`) paths

* Add fourth parameter to set directory permissions

  If file permissions are given (third parameter), these will now apply
  to files only.

* Add non-recursive set permissions command (`==`)

* Be more strict about filespec format

  Blank lines and lines starting with `#` will be ignored. Other errors
  (unknown command, missing path parameter, etc.) will cause the script
  to exit.

* Be more strict about ensuring paths exist for all commands

* Avoid spawning subshells

This also removes outdated filespec paths in the python3 package; these
paths delete files that are no longer present.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Currently, configure does not find the correct platform triplet for musl
as the default build/host values passed by OpenWrt buildroot does not
contain the text "linux-musl".

This backports
python/cpython@c163d7f
to add detection for mips soft float and musl.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This removes 014-remove-platform-so-suffix.patch and
016-adjust-config-paths.patch, restoring the platform triplet to paths
for:

* C extensions (*.cpython-311-*.so)

* Build config data directory (/usr/lib/python3.11/config-3.11-*/)

* sysconfig data file (/usr/lib/python3.11/_sysconfigdata_*.py)

Setting `_PYTHON_SYSCONFIGDATA_NAME` during package builds ensures that
sysconfig data for target Python is loaded, in particular so that C
extensions built will have the correct extension / platform triplet.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
@jefferyto jefferyto force-pushed the python-platform-triplet branch from 56d8042 to 0fe1011 Compare August 24, 2023 19:27
@jefferyto
Copy link
Member Author

Updates:

  • Changed "python3: Fix/expand platform triplet detection" to backport python/cpython@c163d7f
  • Rebased on master

@jefferyto jefferyto marked this pull request as ready for review August 24, 2023 19:29
@jefferyto
Copy link
Member Author

If there are no more comments, I will merge this in a week 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants