Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor crossenv spksrc.wheel.mk and build libtorrent #5180

Merged
merged 27 commits into from Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
edfa1c9
Demo: Try to build libtorrent and deluge using crossenv
th0ma7 Mar 27, 2022
39964c7
rencode: test build
th0ma7 Mar 27, 2022
deac09d
Almost having libtorrent to get to build from crossenv... almost
th0ma7 Mar 27, 2022
6342103
Saving current state - success at building using crossenv!!!
th0ma7 Mar 28, 2022
85c3f02
wheel.mk: Finish playing with includes
th0ma7 Mar 28, 2022
794087d
python310: Finish cleaning-up for libtorrent example
th0ma7 Mar 28, 2022
c5d5fa5
eorder and 1st attempt at fixing 32-bit for libtorrent
th0ma7 Mar 29, 2022
57a4cab
wheel.mk: Add single quote to each --global-option=''
th0ma7 Mar 29, 2022
4121903
python310: Add double-quote to global-option passed
th0ma7 Mar 29, 2022
5c54d58
wheel.mk: Do not add single-quote as it creates an error
th0ma7 Mar 29, 2022
7a85e83
wheel.mk: Fix crossenv pip when PATH variable varies
th0ma7 Mar 29, 2022
9a67d19
boost: Aling with @hgy59 proposed changes PR #5187
th0ma7 Mar 31, 2022
06c77dc
Is there finally light ahead?
th0ma7 Apr 3, 2022
d98f6cc
wheel.mk: Remove debug and fix global-option parameters
th0ma7 Apr 3, 2022
87ac846
python310: Mark DSM<7 as unsupported for libtorrent (c++14)
th0ma7 Apr 3, 2022
90e9828
python310: Use latest fork for rencode that does build
th0ma7 Apr 3, 2022
03d3d9e
python310: Re-enable libtorrent for github-action build
th0ma7 Apr 3, 2022
c8fab41
libtorrent: Remove BOOST_ROOT as only BOOST_BUILD_PATH is needed
th0ma7 Apr 3, 2022
e9810ea
libtorrent: Address-model is now found with BOOST_BUILD_PATH
th0ma7 Apr 3, 2022
617e77f
deluge: Mark as broken to clean-up github-action resulsts
th0ma7 Apr 3, 2022
2993580
libtorrent: Use RC_2_0 branch instead of master
th0ma7 Apr 3, 2022
bd2e050
boost: ADDITIONAL_*FLAGS nice to have but not mandatory
th0ma7 Apr 3, 2022
cbcc28e
wheel.mk: Move exit 1 back to while loop
th0ma7 Apr 3, 2022
1d62239
python310: Test all wheels
th0ma7 Apr 3, 2022
38364be
python310: Disable all wheels and prepare for merge
th0ma7 Apr 4, 2022
f317fac
python310: Forgot to disable gevent and force pure wheel pkging
th0ma7 Apr 4, 2022
ffff5c4
deluge: Unmark as broken for final merge
th0ma7 Apr 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 47 additions & 20 deletions mk/spksrc.wheel.mk
Expand Up @@ -80,12 +80,11 @@ ifneq ($(strip $(WHEELS)),)
$(foreach e,$(shell cat $(WORK_DIR)/python-cc.mk),$(eval $(e)))
@if [ -s $(WHEELHOUSE)/$(WHEELS_CROSSENV_COMPILE) -o -s $(WHEELHOUSE)/$(WHEELS_LIMITED_API) ]; then \
$(MSG) "Cross-compiling wheels" ; \
localPIP=$(PIP) ; \
crossenvPIP=$(PIP) ; \
if [ -s "$(CROSSENV)" ] ; then \
. $(CROSSENV) ; \
localPIP=$$($(RUN) which pip) ; \
crossenvPIP=$$(. $(CROSSENV) && which pip) ; \
$(MSG) "Python crossenv found: [$(CROSSENV)]" ; \
$(MSG) "pip crossenv found: [$${localPIP}]" ; \
$(MSG) "pip crossenv found: [$${crossenvPIP}]" ; \
else \
$(MSG) "WARNING: Python crossenv NOT found!" ; \
$(MSG) "WARNING: pip crossenv NOT found!" ; \
Expand All @@ -94,26 +93,29 @@ ifneq ($(strip $(WHEELS)),)
wheel=$${requirement#*:} ; \
file=$$(basename $${requirement%%:*}) ; \
[ "$${file}" = "$(WHEELS_LIMITED_API)" ] && abi3="--build-option=--py-limited-api=$(PYTHON_LIMITED_API)" || abi3="" ; \
[ "$$(grep -s egg <<< $${wheel})" ] && name=$${wheel#*egg=} || name=$${wheel%%[<>=]=*} ; \
options=($$(echo $(WHEELS_BUILD_ARGS) | sed -e 's/ \[/\n\[/g' | grep -i $${name} | cut -f2 -d] | xargs)) ; \
[ "$${options}" ] && global_option=$$(printf "\x2D\x2Dglobal-option=%s " "$${options[@]}") || global_option="" ; \
[ "$$(grep -s egg <<< $${wheel})" ] && name=$$(echo $${wheel#*egg=} | cut -f1 -d=) || name=$${wheel%%[<>=]=*} ; \
global_options=$$(echo $(WHEELS_BUILD_ARGS) | sed -e 's/ \[/\n\[/g' | grep -i $${name} | cut -f2 -d] | xargs) ; \
localCFLAGS=($$(echo $(WHEELS_CFLAGS) | sed -e 's/ \[/\n\[/g' | grep -i $${name} | cut -f2 -d] | xargs)) ; \
localLDFLAGS=($$(echo $(WHEELS_LDFLAGS) | sed -e 's/ \[/\n\[/g' | grep -i $${name} | cut -f2 -d] | xargs)) ; \
localCPPFLAGS=($$(echo $(WHEELS_CPPFLAGS) | sed -e 's/ \[/\n\[/g' | grep -i $${name} | cut -f2 -d] | xargs)) ; \
localCXXFLAGS=($$(echo $(WHEELS_CXXFLAGS) | sed -e 's/ \[/\n\[/g' | grep -i $${name} | cut -f2 -d] | xargs)) ; \
$(MSG) [$${name}] $$([ "$${localCFLAGS[@]}" ] && echo "CFLAGS=$${localCFLAGS[@]} ")$$([ "$${localLDFLAGS[@]}" ] && echo "LDFLAGS=$${localLDFLAGS[@]} ")$$([ "$${localCPPFLAGS[@]}" ] && echo "CPPFLAGS=$${localCPPFLAGS[@]} ")$$([ "$${localCXXFLAGS[@]}" ] && echo "CXXFLAGS=$${localCXXFLAGS[@]} ")$$([ "$${abi3}" ] && echo "$${abi3} ")"$${global_option}" ; \
$(RUN) \
_PYTHON_HOST_PLATFORM="$(TC_TARGET)" \
CFLAGS="$(CFLAGS) -I$(STAGING_INSTALL_PREFIX)/$(PYTHON_INC_DIR) $${localCFLAGS[@]}" \
LDFLAGS="$(LDFLAGS) $${localLDFLAGS[@]}" \
CPPFLAGS="$(CPPFLAGS) $${localCPPFLAGS[@]}" \
CXXFLAGS="$(CXXFLAGS) $${localCXXFLAGS[@]}" \
$${localPIP} \
$(PIP_WHEEL_ARGS) \
$${abi3} \
$${global_option} \
--no-build-isolation \
$${wheel} || exit 1 ; \
$(MSG) [$${name}] \
$$([ "$$(echo $${localCFLAGS[@]})" ] && echo "CFLAGS=\"$${localCFLAGS[@]}\" ") \
$$([ "$$(echo $${localCPPFLAGS[@]})" ] && echo "CPPFLAGS=\"$${localCPPFLAGS[@]}\" ") \
$$([ "$$(echo $${localCXXFLAGS[@]})" ] && echo "CXXFLAGS=\"$${localCXXFLAGS[@]}\" ") \
$$([ "$$(echo $${localLDFLAGS[@]})" ] && echo "LDFLAGS=\"$${localLDFLAGS[@]}\" ") \
$$([ "$$(echo $${abi3})" ] && echo "$${abi3} ")" \
$${global_options}" ; \
PIP_CROSSENV=$${crossenvPIP} \
REQUIREMENT=$${wheel} \
ADDITIONAL_CFLAGS="-I$(STAGING_INSTALL_PREFIX)/$(PYTHON_INC_DIR) $${localCFLAGS[@]}" \
ADDITIONAL_CPPFLAGS="-I$(STAGING_INSTALL_PREFIX)/$(PYTHON_INC_DIR) $${localCPPFLAGS[@]}" \
ADDITIONAL_CXXFLAGS="-I$(STAGING_INSTALL_PREFIX)/$(PYTHON_INC_DIR) $${localCXXFLAGS[@]}" \
ADDITIONAL_LDFLAGS="$${localLDFLAGS[@]}" \
ABI3="$${abi3}" \
PIP_GLOBAL_OPTION="$${global_options}" \
$(MAKE) \
cross-compile-wheel-$${name} || exit 1 ; \
done < <(grep -svH -e "^\#" -e "^\$$" $(WHEELHOUSE)/$(WHEELS_CROSSENV_COMPILE) $(WHEELHOUSE)/$(WHEELS_LIMITED_API)) ; \
else \
$(MSG) "[SKIP] Cross-compiling wheels" ; \
Expand All @@ -131,6 +133,31 @@ else
endif
endif


cross-compile-wheel-%: SHELL:=/bin/bash
cross-compile-wheel-%:
@if [ "$(PIP_GLOBAL_OPTION)" ]; then \
pip_global_option=$$(echo $(PIP_GLOBAL_OPTION) | sed 's/=\([^ ]*\)/="\1"/g; s/[^ ]*/--global-option=&/g') ; \
pip_global_option=$${pip_global_option}" --no-use-pep517" ; \
fi ; \
$(MSG) \
_PYTHON_HOST_PLATFORM="$(TC_TARGET)" \
$(PIP_CROSSENV) \
$(PIP_WHEEL_ARGS) \
$${pip_global_option} \
--no-build-isolation \
$(ABI3) \
$(REQUIREMENT) ; \
$(RUN) \
_PYTHON_HOST_PLATFORM="$(TC_TARGET)" \
$(PIP_CROSSENV) \
$(PIP_WHEEL_ARGS) \
$${pip_global_option} \
--no-build-isolation \
$(ABI3) \
$(REQUIREMENT)


post_wheel_target: $(WHEEL_TARGET) install_python_wheel

ifeq ($(wildcard $(WHEEL_COOKIE)),)
Expand Down
52 changes: 36 additions & 16 deletions spk/python310/Makefile
Expand Up @@ -30,19 +30,40 @@ SPK_USR_LOCAL_LINKS = bin:bin/python3.10
WHEELS = src/requirements-crossenv.txt src/requirements-pure.txt src/requirements-abi3.txt

# Force building pure-python wheels
# WHEELS_PURE_PYTHON_PACKAGING_ENABLE = 1
WHEELS_PURE_PYTHON_PACKAGING_ENABLE = 1

##
## All configurations below are optional and
## are provided to demonstrate how to build
## various wheels. Uncoment to enable.
##

include ../../mk/spksrc.archs.mk

# [gevent]
# DEPENDS += cross/libev cross/c-ares
# ENV += GEVENTSETUP_EMBED_CARES=FALSE
# ENV += GEVENTSETUP_EMBED_LIBEV=FALSE

# [libtorrent]
# # cross/boost: archs lacking C++11 compiler (88f6281, hi3535 and ppc archs except QorIQ)
# UNSUPPORTED_ARCHS += $(ARM5_ARCHS) $(ARMv7L_ARCHS) $(OLD_PPC_ARCHS)
# # libtorrent > 2.x are DSM 7 only due to c++14 minimal requirement
# REQUIRED_DSM = 7.0
# # comcerto2k has older toolchain than other DSM 7 archs
# UNSUPPORTED_ARCHS += comcerto2k
# DEPENDS += cross/boost cross/geoip cross/libiconv
# BOOST_LIBRARIES += system python chrono random
# ENV += BOOST_LIBRARIES="$(BOOST_LIBRARIES)"
# ENV += BOOST_BUILD_PATH=$(WORK_DIR)/boost_1_78_0
# ENV += PATH=$(WORK_DIR)/boost_1_78_0:$(PATH)
# # Fails to build on evansport-7.0 but enabling
# # -fPIC allows it to go much further
# # https://github.com/arvidn/libtorrent/issues/6792
# WHEELS_BUILD_ARGS += [libtorrent]
# WHEELS_BUILD_ARGS += build_ext
# WHEELS_BUILD_ARGS += --b2-args=libtorrent-python-pic=on

# [lxml]
# DEPENDS += cross/libxml2
# DEPENDS += cross/libxslt
Expand All @@ -53,11 +74,21 @@ WHEELS = src/requirements-crossenv.txt src/requirements-pure.txt src/requirement
# ENV += MYSQLCLIENT_LDFLAGS="$(LDFLAGS)"

# [numpy]
# Last known working version: 1.21.5
# gcc-4.6.4 failed with exit status 1
# https://github.com/numpy/numpy/issues/20664
# # Last known working version: 1.21.5
# # gcc-4.6.4 failed with exit status 1
# # https://github.com/numpy/numpy/issues/20664
# UNSUPPORTED_ARCHS = $(ARMv5_ARCHS)
# >> See more option under include below <<

# [numpy]
# # Fix wheel building with older compilers
# ifeq ($(call version_lt, $(TC_GCC), 5.0),1)
# WHEELS_CPPFLAGS = [numpy] -std=c++0x
# # workaround for compiler bug:
# # https://github.com/numpy/numpy/issues/13622
# ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS)),$(ARCH))
# WHEELS_CFLAGS = [numpy] -O0
# endif
# endif

# [Pillow]
# DEPENDS += cross/freetype cross/libjpeg cross/zlib
Expand Down Expand Up @@ -85,17 +116,6 @@ WHEELS = src/requirements-crossenv.txt src/requirements-pure.txt src/requirement

include ../../mk/spksrc.spk.mk

# [numpy]
# Fix wheel building with older compilers
# ifeq ($(call version_lt, $(TC_GCC), 5.0),1)
# WHEELS_CPPFLAGS = [numpy] -std=c++0x
# workaround for compiler bug:
# https://github.com/numpy/numpy/issues/13622
# ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS)),$(ARCH))
# WHEELS_CFLAGS = [numpy] -O0
# endif
# endif

.PHONY: python310_extra_install
python310_extra_install:
rm -f $(STAGING_DIR)/$(PYTHON_LIB_DIR)/config/libpython*.a
Expand Down
14 changes: 14 additions & 0 deletions spk/python310/src/requirements-crossenv.txt
Expand Up @@ -32,6 +32,15 @@
# GEVENTSETUP_EMBED_LIBEV=FALSE
# gevent==21.12.0

# [libtorrent]
# Depends: boost, geoip, libiconv
# Require environment variables
# BOOST_LIBRARIES
# BOOST_ROOT
# libtorrent==2.0.5
# git+https://github.com/arvidn/libtorrent.git@master#egg=libtorrent==2.0.5 (use RC_2_0)
# git+https://github.com/arvidn/libtorrent.git@RC_2_0#egg=libtorrent==2.0.5

# [lxml]
# Depends: libxml2, libxslt
# lxml==4.8.0
Expand Down Expand Up @@ -81,6 +90,11 @@
# Depends: libyaml
# PyYAML==6.0

# [rencode]
# Updated fork of the project
# rencode==1.0.6 <<-- unsupported
# git+https://github.com/totaam/rencode.git@f6254ab26161f90b9c5e97915b9193fee805fc1f#egg=rencode==1.0.7

# [ujson]
# - Require setuptools-scm in cross/python310 crossenv
# ujson==5.1.0
Expand Down
9 changes: 9 additions & 0 deletions spk/python310/src/requirements-pure.txt
Expand Up @@ -20,3 +20,12 @@ distlib==0.3.4
filelock==3.6.0
platformdirs==2.5.1
six==1.16.0

##
## All configurations below are optional and
## are provided to demonstrate how to build
## various wheels. Uncoment to enable.
##

# [deluge]
# deluge==2.0.5