Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 7a25d1d

Browse files
author
Matthias Koeppe
committed
WIP: Install pip packages with sage-spkg
1 parent d850e60 commit 7a25d1d

File tree

3 files changed

+27
-38
lines changed

3 files changed

+27
-38
lines changed

build/bin/sage-dist-helpers

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,18 @@ sdh_prefix_args () {
239239

240240
sdh_pip_install() {
241241
echo "Installing $PKG_NAME"
242+
<<<<<<< HEAD
243+
=======
244+
if [ -n "$SAGE_DESTDIR" ]; then
245+
local sudo=""
246+
else
247+
local sudo="$SAGE_SUDO"
248+
fi
249+
if [ "$*" = "." ]; then
250+
$sudo sage-pip-uninstall "$@" || \
251+
sdh_die "Error uninstalling a previous version of $PKG_NAME"
252+
fi
253+
>>>>>>> 9750195b6f (WIP: Install pip packages with sage-spkg)
242254
mkdir -p dist
243255
rm -f dist/*.whl
244256
install_options=""
@@ -303,14 +315,12 @@ sdh_store_wheel() {
303315
if [ "$*" != "." ]; then
304316
sdh_die "Error: sdh_store_wheel requires . as only argument"
305317
fi
306-
wheel=""
307-
for w in dist/*.whl; do
308-
if [ -n "$wheel" ]; then
309-
sdh_die "Error: more than one wheel found after building"
310-
fi
311-
if [ -f "$w" ]; then
312-
wheel="$w"
313-
fi
318+
for wheel in dist/*.whl; do
319+
$sudo sage-pip-install $root "$wheel" || \
320+
sdh_die "Error installing $wheel"
321+
mkdir -p "${SAGE_DESTDIR}${SAGE_SPKG_WHEELS}" && \
322+
$sudo mv "$wheel" "${SAGE_DESTDIR}${SAGE_SPKG_WHEELS}/" || \
323+
sdh_die "Error storing $wheel"
314324
done
315325
if [ -z "$wheel" ]; then
316326
sdh_die "Error: no wheel found after building"

build/bin/sage-spkg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,16 @@ if [ -f spkg-build ]; then
647647
error_msg "Error installing package $PKG_NAME" "make"
648648
exit 1
649649
fi
650-
else
650+
elif [ -f spkg-install ]; then
651651
# Package only has spkg-install
652652
time ./spkg-install
653653
if [ $? -ne 0 ]; then
654654
error_msg "Error installing package $PKG_NAME" "make"
655655
exit 1
656656
fi
657+
elif [ -f requirements.txt ]; then
658+
. sage-dist-helpers
659+
sdh_pip_install -r requirements.txt
657660
fi
658661

659662
# To work around #26996: Remove the symlink set, or we get "cp: cannot overwrite directory"

build/make/Makefile.in

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -537,40 +537,16 @@ $(foreach pkgname, $(NORMAL_PACKAGES),\
537537
endif
538538

539539
# ================================ pip packages ===============================
540-
# Generate build rules for 'pip' packages; this template is used to generate
541-
# two rules in the form:
542-
#
543-
# <pkgname>: <dependencies>
544-
# $(AM_V_at)sage-logger -p 'sage --pip install ...' '$(SAGE_LOGS)/<pkgname>.log'
545-
#
546-
# <pkgname>-clean:
547-
# -sage --pip uninstall -y ...
548-
549-
# Positional arguments:
550-
# $(1): package name
551-
# $(2): package dependencies
552-
define PIP_PACKAGE_templ
553-
$(1)-build-deps: $(2)
554-
555-
$(1): $(2)
556-
+$(MAKE_REC) $(1)-no-deps
557-
558-
$(1)-no-deps:
559-
$(AM_V_at)sage-logger -p 'sage --pip install -r "$$(SAGE_ROOT)/build/pkgs/$(1)/requirements.txt"' '$$(SAGE_LOGS)/$(1).log'
560-
561-
$(1)-clean:
562-
-sage --pip uninstall --isolated --yes --no-input -r '$$(SAGE_ROOT)/build/pkgs/$(1)/requirements.txt'
563-
564-
.PHONY: $(1) $(1)-clean $(1)-build-deps $(1)-no-deps
565-
endef
566-
567540
$(foreach pkgname,$(PIP_PACKAGES),\
568-
$(eval $(call PIP_PACKAGE_templ,$(pkgname),$(call pkg_deps,$(pkgname)))))
541+
$(eval $(call NORMAL_PACKAGE_templ,$(pkgname),$(vers_$(pkgname)),$(call pkg_deps,$(pkgname)))))
542+
$(foreach pkgname, $(PIP_PACKAGES),\
543+
$(eval $(call NORMAL_PACKAGE_clean_templ,$(pkgname),$(vers_$(pkgname)),\
544+
$(call pkg_deps,$(pkgname)))))
569545

570546
ifdef DEBUG_RULES
571547
$(info # Rules for pip packages)
572548
$(foreach pkgname,$(PIP_PACKAGES),\
573-
$(info $(call PIP_PACKAGE_templ,$(pkgname),$(call pkg_deps,$(pkgname)))))
549+
$(info $(call NORMAL_PACKAGE_templ,$(pkgname),$(vers_$(pkgname)),$(call pkg_deps,$(pkgname)))))
574550
endif
575551

576552
# ============================= script packages ==============================

0 commit comments

Comments
 (0)