Merge pull request #9206 from jernejsk/remove-distutilscross

[LE13] Python: Remove usage of distutilscross
This commit is contained in:
Rudi Heitbaum 2024-08-22 08:21:39 +10:00 committed by GitHub
commit d8ce2ffcef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 75 additions and 157 deletions

View File

@ -1384,6 +1384,15 @@ python_fix_abi() {
done
}
# arg1: python command for target
python_target_env() {
_PYTHON_HOST_PLATFORM="linux-${TARGET_ARCH}" \
_PYTHON_PROJECT_BASE="$(get_install_dir Python3)" \
_PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__linux_${TARGET_ARCH}-linux-gnu${TARGET_ABI}" \
PYTHONPATH="$(get_install_dir Python3)/usr/lib/${PKG_PYTHON_VERSION}" \
PYTHONNOUSERSITE=1 $@
}
### KERNEL HELPERS ###
kernel_path() {
get_build_dir linux

View File

@ -7,15 +7,13 @@ PKG_SHA256="b08d8569d6dc8fa91a42ba1e37f620fdcb19d6bf2330e4b7d7301431ddbe124c"
PKG_LICENSE="Unlicense"
PKG_SITE="http://abyz.me.uk/lg/"
PKG_URL="https://github.com/joan2937/lg/archive/v${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain Python3 swig:host distutilscross:host"
PKG_DEPENDS_TARGET="toolchain Python3 swig:host"
PKG_LONGDESC="A library for Linux Single Board Computers (SBC) which allows control of the General Purpose Input Outputs (GPIO)"
PKG_TOOLCHAIN="manual"
pre_configure_target() {
export PYTHONXCPREFIX="${SYSROOT_PREFIX}/usr"
export CFLAGS="${CFLAGS} -I${PKG_BUILD}"
export LDFLAGS="${CFLAGS} -L${PKG_BUILD}"
export LDSHARED="${CC} -shared"
}
make_target() {
@ -23,6 +21,6 @@ make_target() {
(
cd PY_LGPIO
swig -python lgpio.i
python setup.py build
python_target_env python setup.py build
)
}

View File

@ -7,37 +7,26 @@ PKG_SHA256="1f899e43603184fac32f34d72498fc737952dbc9c97a8dd9467fadfdf4600cf9"
PKG_LICENSE="GPL"
PKG_SITE="https://i2c.wiki.kernel.org/index.php/I2C_Tools"
PKG_URL="https://www.kernel.org/pub/software/utils/i2c-tools/${PKG_NAME}-${PKG_VERSION}.tar.xz"
PKG_DEPENDS_TARGET="toolchain Python3 distutilscross:host"
PKG_DEPENDS_TARGET="toolchain Python3"
PKG_LONGDESC="A heterogeneous set of I2C tools for Linux."
PKG_BUILD_FLAGS="-sysroot"
pre_make_target() {
export PYTHONXCPREFIX="${SYSROOT_PREFIX}/usr"
export LDSHARED="${CC} -shared"
}
make_target() {
make CC="${CC}" \
AR="${AR}" \
CFLAGS="${TARGET_CFLAGS}" \
CPPFLAGS="${TARGET_CPPFLAGS} -I${SYSROOT_PREFIX}/usr/include/${PKG_PYTHON_VERSION}" \
PYTHON=${TOOLCHAIN}/bin/python3 \
CPPFLAGS="${TARGET_CPPFLAGS}" \
all
make EXTRA="py-smbus" \
CC="${CC}" \
AR="${AR}" \
CFLAGS="${TARGET_CFLAGS}" \
CPPFLAGS="${TARGET_CPPFLAGS} -I${SYSROOT_PREFIX}/usr/include/${PKG_PYTHON_VERSION}" \
PYTHON=${TOOLCHAIN}/bin/python3 \
all-python
(
cd py-smbus
python_target_env python3 setup.py build
)
}
makeinstall_target() {
make EXTRA="py-smbus" \
DESTDIR=${INSTALL} \
PREFIX="/usr" \
prefix="/usr" \
PYTHON=${TOOLCHAIN}/bin/python3 \
install
(
cd py-smbus
exec_thread_safe python_target_env python3 setup.py install --root=${INSTALL} --prefix=/usr
)
}

View File

@ -0,0 +1,38 @@
From cf3541b8a7ed50782edd05836020d31230fb86c6 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@arm.com>
Date: Wed, 19 Jan 2022 12:08:53 +0100
Subject: py-smbus: Use setuptools instead of distutils
As per [1], distutils is deprecated in Python 3.10 and will be removed
entirely in Python 3.12.
As setuptools is essentially an enhanced version of distutils, it's
trivial to port to that.
[1] https://docs.python.org/3/whatsnew/3.10.html#distutils-deprecated
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Upstream: https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/commit/?id=cf3541b8a7ed50782edd05836020d31230fb86c6
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
---
py-smbus/setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/py-smbus/setup.py b/py-smbus/setup.py
index 28a4500..26db33a 100644
--- a/py-smbus/setup.py
+++ b/py-smbus/setup.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
setup( name="smbus",
version="1.1",
--
cgit

View File

@ -1,12 +0,0 @@
diff -ur a/py-smbus/Module.mk b/py-smbus/Module.mk
--- a/py-smbus/Module.mk 2014-02-20 09:37:15.711233000 +0100
+++ b/py-smbus/Module.mk 2019-12-14 08:20:51.730946457 +0100
@@ -22,7 +22,7 @@
rm -rf py-smbus/build
install-python:
- $(DISTUTILS) install
+ $(DISTUTILS) install --prefix=$(DESTDIR)$(PREFIX)
all: all-python

View File

@ -118,6 +118,13 @@ pre_configure_target() {
export DISABLED_EXTENSIONS="${PKG_PY_DISABLED_MODULES}"
}
post_make_target() {
# fix sysconfig paths for cross compiling
PKG_SYSCONFIG_FILE=$(find ${PKG_BUILD}/.${TARGET_NAME} -not -path '*/__pycache__/*' -name '_sysconfigdata__*.py')
sed -e "s,\([\'|\ ]\)/usr/include,\1${SYSROOT_PREFIX}/usr/include,g" -i ${PKG_SYSCONFIG_FILE}
sed -e "s,\([\'|\ ]\)/usr/lib,\1${SYSROOT_PREFIX}/usr/lib,g" -i ${PKG_SYSCONFIG_FILE}
}
post_makeinstall_target() {
ln -sf ${PKG_PYTHON_VERSION} ${INSTALL}/usr/bin/python

View File

@ -1,18 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="distutilscross"
PKG_VERSION="0.1"
PKG_SHA256="4ed3fb427708c8a3ed5fe9c599532480f581078a1e0aec0e50f40eb58e9f0015"
PKG_LICENSE="GPL"
PKG_SITE="https://pypi.org/project/distutilscross/"
PKG_URL="https://files.pythonhosted.org/packages/source/${PKG_NAME:0:1}/${PKG_NAME}/${PKG_NAME}-${PKG_VERSION}.tar.gz"
PKG_DEPENDS_HOST="Python3:host setuptools:host"
PKG_LONGDESC="distutilscross enhances distutils to support Cross Compile of Python extensions"
PKG_TOOLCHAIN="manual"
makeinstall_host() {
export DONT_BUILD_LEGACY_PYC=1
exec_thread_safe python setup.py install --prefix=${TOOLCHAIN}
}

View File

@ -1,57 +0,0 @@
diff --git a/distutilscross/crosscompile.py b/distutilscross/crosscompile.py
index 31dfd6c..16b683e 100644
--- a/distutilscross/crosscompile.py
+++ b/distutilscross/crosscompile.py
@@ -13,7 +13,7 @@ class build(_build):
self.cross_compile = 0
def finalize_options(self):
- if self.cross_compile and os.environ.has_key('PYTHONXCPREFIX'):
+ if self.cross_compile and 'PYTHONXCPREFIX' in os.environ:
prefix = os.environ['PYTHONXCPREFIX']
sysconfig.get_python_lib = get_python_lib
sysconfig.PREFIX = prefix
@@ -31,8 +31,8 @@ class build(_build):
_get_python_lib = sysconfig.get_python_lib
def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
- if os.environ.has_key('PYTHONXCPREFIX'):
- print "Setting prefix"
+ if 'PYTHONXCPREFIX' in os.environ:
+ print("Setting prefix")
prefix = os.environ['PYTHONXCPREFIX']
return _get_python_lib(plat_specific, standard_lib, prefix)
@@ -50,24 +50,24 @@ def customize_compiler(compiler):
sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SO')
- if os.environ.has_key('CC'):
+ if 'CC' in os.environ:
cc = os.environ['CC']
- if os.environ.has_key('CXX'):
+ if 'CXX' in os.environ:
cxx = os.environ['CXX']
- if os.environ.has_key('LDSHARED'):
+ if 'LDSHARED' in os.environ:
ldshared = os.environ['LDSHARED']
- if os.environ.has_key('CPP'):
+ if 'CPP' in os.environ:
cpp = os.environ['CPP']
else:
cpp = cc + " -E" # not always
- if os.environ.has_key('LDFLAGS'):
+ if 'LDFLAGS' in os.environ:
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
- if os.environ.has_key('OPT'):
+ if 'OPT' in os.environ:
opt = os.environ['OPT']
- if os.environ.has_key('CFLAGS'):
+ if 'CFLAGS' in os.environ:
cflags = opt + ' ' + os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS']
- if os.environ.has_key('CPPFLAGS'):
+ if 'CPPFLAGS' in os.environ:
cpp = cpp + ' ' + os.environ['CPPFLAGS']
cflags = cflags + ' ' + os.environ['CPPFLAGS']
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']

View File

@ -8,21 +8,16 @@ PKG_SHA256="e70284e8605a5b7ccb37e5bfd4634598ca2c43c7f2c353572351ccf72c031004"
PKG_LICENSE="BSD"
PKG_SITE="https://python-pillow.org/"
PKG_URL="https://github.com/python-pillow/${PKG_NAME}/archive/${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain Python3 distutilscross:host zlib freetype libjpeg-turbo tiff"
PKG_DEPENDS_TARGET="toolchain Python3 zlib freetype libjpeg-turbo tiff"
PKG_LONGDESC="The Python Imaging Library adds image processing capabilities to your Python interpreter."
PKG_TOOLCHAIN="manual"
pre_make_target() {
export PYTHONXCPREFIX="${SYSROOT_PREFIX}/usr"
export LDSHARED="${CC} -shared"
}
make_target() {
python3 setup.py build --cross-compile
python_target_env python3 setup.py build_ext --disable-platform-guessing build
}
makeinstall_target() {
python3 setup.py install --root=${INSTALL} --prefix=/usr
exec_thread_safe python_target_env python3 setup.py build_ext --disable-platform-guessing install --root=${INSTALL} --prefix=/usr
}
post_makeinstall_target() {

View File

@ -1,23 +0,0 @@
diff --git a/setup.py b/setup.py
index 8eb0b3c..277e44a 100755
--- a/setup.py
+++ b/setup.py
@@ -341,9 +341,7 @@
return True if value in configuration.get(option, []) else None
def initialize_options(self):
- self.disable_platform_guessing = self.check_configuration(
- "platform-guessing", "disable"
- )
+ self.disable_platform_guessing = True
self.add_imaging_libs = ""
build_ext.initialize_options(self)
for x in self.feature:
@@ -1007,6 +1005,7 @@
try:
setup(
+ version=PILLOW_VERSION,
cmdclass={"build_ext": pil_build_ext},
ext_modules=ext_modules,
zip_safe=not (debug_build() or PLATFORM_MINGW),

View File

@ -7,24 +7,21 @@ PKG_SHA256="35019dff66c25db80d0c739b9c7b59bb0f61551897681c6dbdbdd0f7198f780f"
PKG_LICENSE="BSD"
PKG_SITE="https://pypi.org/project/pycryptodome"
PKG_URL="https://github.com/Legrandin/${PKG_NAME}/archive/v${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain Python3 distutilscross:host"
PKG_DEPENDS_TARGET="toolchain Python3"
PKG_LONGDESC="PyCryptodome is a self-contained Python package of low-level cryptographic primitives."
PKG_TOOLCHAIN="manual"
pre_configure_target() {
cd ${PKG_BUILD}
rm -rf .${TARGET_NAME}
export PYTHONXCPREFIX="${SYSROOT_PREFIX}/usr"
export LDSHARED="${CC} -shared"
}
make_target() {
python3 setup.py build --cross-compile
python_target_env python3 setup.py build
}
makeinstall_target() {
python3 setup.py install --root=${INSTALL} --prefix=/usr
exec_thread_safe python_target_env python3 setup.py install --root=${INSTALL} --prefix=/usr
# Remove SelfTest bloat
find ${INSTALL} -type d -name SelfTest -exec rm -fr "{}" \; 2>/dev/null || true

View File

@ -8,21 +8,16 @@ PKG_SHA256="8e086896c36210ab6050f2f9f095a5f1e03c83fa0e7f296d6cba425411364680"
PKG_LICENSE="OSS"
PKG_SITE="http://pypi.org/project/simplejson"
PKG_URL="https://files.pythonhosted.org/packages/source/${PKG_NAME:0:1}/${PKG_NAME}/${PKG_NAME}-${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain Python3 distutilscross:host"
PKG_DEPENDS_TARGET="toolchain Python3"
PKG_LONGDESC="A simple, fast, complete, correct and extensible JSON encoder and decoder for Python 2.5+."
PKG_TOOLCHAIN="manual"
pre_make_target() {
export PYTHONXCPREFIX="${SYSROOT_PREFIX}/usr"
export LDSHARED="${CC} -shared"
}
make_target() {
python3 setup.py build --cross-compile
python_target_env python3 setup.py build
}
makeinstall_target() {
python3 setup.py install --root=${INSTALL} --prefix=/usr
exec_thread_safe python_target_env python3 setup.py install --root=${INSTALL} --prefix=/usr
}
post_makeinstall_target() {