Skip to content

Commit

Permalink
use python -m build to create wheels with python-wheel.mk
Browse files Browse the repository at this point in the history
- add build to default crossenv
- fix python-wheel.mk (include spksrc.crossenv.mk)
- use workaround to access crossenv to build wheels with python-wheel.mk
  for unknown reason the CROSSENV variable is empty, use $(CROSSENV_PATH)/bin/activate instead
  • Loading branch information
hgy59 committed Nov 20, 2024
1 parent df5f70e commit e5f4958
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
9 changes: 1 addition & 8 deletions cross/cryptography/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PKG_NAME = cryptography
PKG_VERS = 41.0.3
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://files.pythonhosted.org/packages/source/c/$(PKG_NAME)
PKG_DIST_SITE = https://files.pythonhosted.org/packages/source/c/cryptography
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS = cross/openssl3 cross/cffi
Expand All @@ -11,11 +11,4 @@ HOMEPAGE = https://github.com/pyca/cryptography
COMMENT = Provide cryptographic recipes and primitives to Python developers
LICENSE = BSD/ASL2

###
### This cross/cryptography is needed to generate python-limited abi3 wheels
### Ref: https://github.com/pyca/cryptography/issues/7671
###

WHEELS_BUILD_ARGS = --py-limited-api=$(PYTHON_LIMITED_API)

include ../../mk/spksrc.python-wheel.mk
1 change: 1 addition & 0 deletions mk/crossenv/requirements-default.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pip==24.3.1
pip-tools==7.4.1
setuptools==75.4.0
build==1.2.2
wheel==0.45.0
#
cffi==1.17.1
Expand Down
6 changes: 3 additions & 3 deletions mk/spksrc.python-module.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Python module rules
# Invoke make to (cross-) compile a python module.
# Invoke make to (cross-) compile a python extension module.
# You can do some customization through python-cc.mk

# Python module targets
Expand All @@ -24,11 +24,11 @@ build_crossenv_module:
@$(MSG) WHEEL="$(PKG_NAME)-$(PKG_VERS)" $(MAKE) crossenv-$(ARCH)-$(TCVERSION)
@WHEEL="$(PKG_NAME)-$(PKG_VERS)" $(MAKE) crossenv-$(ARCH)-$(TCVERSION)

### Python module rules
### Python extension module rules
compile_python_module: build_crossenv_module
$(foreach e,$(shell cat $(CROSSENV_MODULE_PATH)/build/python-cc.mk),$(eval $(e)))
$(eval PYTHONPATH = $(PYTHON_SITE_PACKAGES_NATIVE):$(PYTHON_LIB_NATIVE):$(INSTALL_DIR)$(INSTALL_PREFIX)/$(PYTHON_LIB_DIR)/site-packages/)
@$(MSG) "activate crossenv found: $(CROSSENV)"
@$(MSG) "PYTHON MODULE: activate crossenv found: $(CROSSENV)"
@. $(CROSSENV) ; \
$(RUN) PYTHONPATH=$(PYTHONPATH) python setup.py build_ext \
-I $(STAGING_INSTALL_PREFIX)/include \
Expand Down
12 changes: 9 additions & 3 deletions mk/spksrc.python-wheel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ include ../../mk/spksrc.wheel-env.mk

### Python wheel rules
build_python_wheel_target:
@$(MSG) "activate crossenv found: $(CROSSENV)"
@. $(CROSSENV) ; \
$(RUN) _PYTHON_HOST_PLATFORM=$(TC_TARGET) python3 setup.py $(BUILD_ARGS) bdist_wheel $(WHEELS_BUILD_ARGS) -d $(WHEELHOUSE)
@$(MSG) "PYTHON WHEEL: activate crossenv found: $(CROSSENV)"
@$(MSG) "CROSSENV_PATH = $(CROSSENV_PATH)"
@. $(CROSSENV_PATH)/bin/activate ; \
$(RUN) _PYTHON_HOST_PLATFORM=$(TC_TARGET) python3 -m build $(BUILD_ARGS) --wheel $(WHEELS_BUILD_ARGS) --outdir $(WHEELHOUSE)
@$(RUN) echo "$(PKG_NAME)==$(PKG_VERS)" >> $(WHEELHOUSE)/$(WHEELS_CROSS_COMPILE)

post_install_python_wheel_target: $(WHEEL_TARGET) install_python_wheel

all: install

###

# Use crossenv
include ../../mk/spksrc.crossenv.mk
2 changes: 1 addition & 1 deletion mk/spksrc.wheel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ ifneq ($(strip $(WHEELS)),)
[ -d $${crossenv} ] && . $${crossenv}/build/python-cc.mk && break ; \
done ; \
crossenvPIP=$(PIP) ; \
$(MSG) "activate crossenv found: $${CROSSENV}" ; \
$(MSG) "WHEEL: activate crossenv found: $${CROSSENV}" ; \
if [ -s "$${CROSSENV}" ] ; then \
crossenvPIP=$$(. $${CROSSENV} && which pip) ; \
$(MSG) "Python crossenv found: [$${CROSSENV}]" ; \
Expand Down

0 comments on commit e5f4958

Please sign in to comment.