Skip to content

Commit

Permalink
wheel.mk: Pre-process #egg= tags for compatibility with newer pip
Browse files Browse the repository at this point in the history
  • Loading branch information
th0ma7 committed Jan 17, 2025
1 parent 8d52a82 commit ce0afe8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mk/spksrc.wheel-download.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ifeq ($(wildcard $(PIP_CACHE_DIR)),)
@mkdir -p $(PIP_CACHE_DIR)
endif
@$(MSG) Downloading wheel [$(WHEEL_NAME)], version [$(WHEEL_VERSION)] ; \
if [ "$$(grep -s egg <<< $(REQUIREMENT))" ] ; then \
if [ "$$(grep -Eo 'http://|https://' <<< $(REQUIREMENT))" ] ; then \
echo "WARNING: Skipping download URL - Downloaded at build time" ; \
elif [ "$(WHEEL_TYPE)" = "pure" ] && [ ! "$(WHEELS_PURE_PYTHON_PACKAGING_ENABLE)" = "1" ]; then \
echo "WARNING: Skipping download - pure python packaging disabled" ; \
Expand All @@ -63,7 +63,7 @@ endif
query+=" | select((.filename|test(\"-$(WHEEL_VERSION).tar.gz\")) or (.filename|test(\"-$(WHEEL_VERSION).zip\"))) | .url'" ; \
outFile=$$(basename $$(eval $${query} 2>/dev/null) 2</dev/null) ; \
if [ "$${outFile}" = "" ]; then \
echo "ERROR: Invalid package name [$(WHEEL_NAME)]" ; \
echo "ERROR: Unable to find version on pypi.org for [$(WHEEL_NAME)]" ; \
elif [ -s $(PIP_DISTRIB_DIR)/$${outFile} ]; then \
echo "INFO: File already exists [$${outFile}]" ; \
else \
Expand Down
3 changes: 1 addition & 2 deletions mk/spksrc.wheel-install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ wheel_install_target: SHELL:=/bin/bash
wheel_install_target:
@$(MSG) Installing wheel [$(WHEEL_NAME)], version [$(WHEEL_VERSION)], type [$(WHEEL_TYPE)] ; \
case $(WHEEL_TYPE) in \
abi3) $(MSG) Adding $(WHEEL_NAME)==$$(WHEEL_VERSION) to wheelhouse/$(WHEELS_LIMITED_API) ; \
abi3) $(MSG) Adding $(WHEEL_NAME)==$(WHEEL_VERSION) to wheelhouse/$(WHEELS_LIMITED_API) ; \
echo $(WHEEL_NAME)==$(WHEEL_VERSION) | sed -e '/^[[:blank:]]*$$\|^#/d' >> $(WHEELHOUSE)/$(WHEELS_LIMITED_API) ; \
;; \
cross) $(MSG) Adding $(WHEEL_NAME)==$(WHEEL_VERSION) to wheelhouse/$(WHEELS_CROSS_COMPILE) ; \
Expand All @@ -72,7 +72,6 @@ install_python_wheel:
$(MSG) Copying $(WHEELS_DEFAULT) to wheelhouse ; \
cp requirements*.txt $(STAGING_INSTALL_WHEELHOUSE) ; \
cat requirements*.txt >> $(STAGING_INSTALL_WHEELHOUSE)/$(WHEELS_DEFAULT) ; \
sed -i -e '/^#/! s/^.*egg=//g' $(STAGING_INSTALL_WHEELHOUSE)/requirements*.txt ; \
sort -u -o $(STAGING_INSTALL_WHEELHOUSE)/$(WHEELS_DEFAULT) $(STAGING_INSTALL_WHEELHOUSE)/$(WHEELS_DEFAULT) ; \
else \
$(MSG) [SKIP] Copying $(WHEELS_DEFAULT) to wheelhouse ; \
Expand Down
6 changes: 4 additions & 2 deletions mk/spksrc.wheel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ ifneq ($(wildcard $(abspath $(addprefix $(WORK_DIR)/../,$(WHEELS)))),)
requirements-abi3.txt) type=abi3 ;; \
*) type=$(WHEEL_DEFAULT_PREFIX) ;; \
esac ; \
version=$$(echo $${wheel} | grep -oP '(?<=([<>=]=))[^ ]*' || echo "") ; \
if [ "$$(grep -s egg <<< $${wheel})" ]; then \
name=$$(echo $${wheel#*egg=} | cut -f1 -d=) ; \
wheel=$$(echo $${wheel%%#egg=*}) ; \
else \
name=$$(echo $${wheel%%[<>=]=*} | sed -E "s/^(abi3|crossenv|pure)://") ; \
fi ; \
version=$$(echo $${wheel} | grep -oP '(?<=([<>=]=))[^ ]*' || echo "") ; \
if [ ! "$${version}" ]; then \
$(MSG) Fetching latest version available ; \
query="curl -s https://pypi.org/pypi/$${name}/json" ; \
Expand All @@ -116,12 +117,13 @@ ifneq ($(filter-out $(addprefix src/,$(notdir $(wildcard $(abspath $(addprefix $
pure:*) type=pure ;; \
*) type=$(WHEEL_DEFAULT_PREFIX) ;; \
esac ; \
version=$$(echo $${wheel} | grep -oP '(?<=([<>=]=))[^ ]*' || echo "") ; \
if [ "$$(grep -s egg <<< $${requirement})" ]; then \
name=$$(echo $${wheel#*egg=} | cut -f1 -d=) ; \
wheel=$$(echo $${wheel%%#egg=*}) ; \
else \
name=$$(echo $${wheel%%[<>=]=*} | sed -E "s/^(abi3|crossenv|pure)://") ; \
fi ; \
version=$$(echo $${wheel} | grep -oP '(?<=([<>=]=))[^ ]*' || echo "") ; \
if [ ! "$${version}" ]; then \
$(MSG) Fetching latest version available ; \
query="curl -s https://pypi.org/pypi/$${name}/json" ; \
Expand Down

0 comments on commit ce0afe8

Please sign in to comment.