Skip to content

python3: Use default _PYTHON_HOST_PLATFORM#12754

Merged
neheb merged 1 commit intoopenwrt:masterfrom
jefferyto:python-host-platform
Jul 8, 2020
Merged

python3: Use default _PYTHON_HOST_PLATFORM#12754
neheb merged 1 commit intoopenwrt:masterfrom
jefferyto:python-host-platform

Conversation

@jefferyto
Copy link
Member

Maintainer: me, @commodo
Compile tested: armvirt-64, 2020-07-05 snapshot sdk
Run tested: armvirt-64 (qemu), 2020-07-05 snapshot

Description:
This lets the Python build process set _PYTHON_HOST_PLATFORM instead of forcing an explicit value.

Also:

  • Save the target _PYTHON_HOST_PLATFORM value during Build/InstallDev for use when building target Python packages (in python3-package.mk).

  • Use the (mostly) default PYTHON_FOR_BUILD value, instead patch configure to remove the platform triplet from the sysconfigdata file name.

  • Remove the CROSS_COMPILE=yes make variable (there is no indication that this variable is necessary).

  • Force host pip to build packages from source instead of downloading binary wheels.

    Previously, host pip can download universal (platform-independent) wheels but not platform-specific wheels, because of the custom _PYTHON_HOST_PLATFORM value. (Packages that do not have universal wheels would be compiled from source.)

    With a correct _PYTHON_HOST_PLATFORM, host pip can install platform-specific wheels as well. However, the pre-built shared object (.so) files in these wheels will have the host's platform triplet in their file names. When target Python packages are built (using the target's _PYTHON_HOST_PLATFORM), Python will not use these shared object files.

    By forcing host pip to build packages from source, the built shared object files will not have the platform triplet in their file names. (Host Python has been patched to remove the platform triplet from file names.) This allows these packages to be used when building target Python packages.

    (The net effect of this complete change is that platform-dependent packages will continue to be compiled from source, while platform-independent packages will now also be compiled from source.)

Signed-off-by: Jeffery To jeffery.to@gmail.com

This lets the Python build process set _PYTHON_HOST_PLATFORM instead of
forcing an explicit value.

Also:

* Save the target _PYTHON_HOST_PLATFORM value during Build/InstallDev
  for use when building target Python packages (in python3-package.mk).

* Use the (mostly) default PYTHON_FOR_BUILD value, instead patch
  configure to remove the platform triplet from the sysconfigdata file
  name.

* Remove the "CROSS_COMPILE=yes" make variable (there is no indication
  that this variable is necessary).

* Force host pip to build packages from source instead of downloading
  binary wheels.

  Previously, host pip can download universal (platform-independent)
  wheels but not platform-specific wheels, because of the custom
  _PYTHON_HOST_PLATFORM value. (Packages that do not have universal
  wheels would be compiled from source.)

  With a correct _PYTHON_HOST_PLATFORM, host pip can install
  platform-specific wheels as well. However, the pre-built shared object
  (.so) files in these wheels will have the host's platform triplet in
  their file names. When target Python packages are built (using the
  target's _PYTHON_HOST_PLATFORM), Python will not use these shared
  object files.

  By forcing host pip to build packages from source, the built shared
  object files will not have the platform triplet in their file names.
  (Host Python has been patched to remove the platform triplet from file
  names.) This allows these packages to be used when building target
  Python packages.

  (The net effect of this complete change is that platform-dependent
  packages will continue to be compiled from source, while
  platform-independent packages will now also be compiled from source.)

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
@jefferyto
Copy link
Member Author

This is #12755 but for master, because:

I should note that removing PYTHON_FOR_BUILD is not strictly necessary, but looking at where it was originally added (2244ad9) it seems the original intent is to remove the platform triplet from the sysconfigdata file name, and patching it out is easier than keeping PYTHON_FOR_BUILD and also "fixing" _PYTHON_HOST_PLATFORM within it.

@jefferyto
Copy link
Member Author

Also, an unrelated note: I noticed there are lots of build-specific file paths in _sysconfigdata.py. We may need to look at it in the future to improve reproducibility of the Python package itself.

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.

3 participants