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

Commit

Permalink
WIP: Install pip packages with sage-spkg
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jul 21, 2022
1 parent d850e60 commit 7a25d1d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 38 deletions.
26 changes: 18 additions & 8 deletions build/bin/sage-dist-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ sdh_prefix_args () {

sdh_pip_install() {
echo "Installing $PKG_NAME"
<<<<<<< HEAD
=======
if [ -n "$SAGE_DESTDIR" ]; then
local sudo=""
else
local sudo="$SAGE_SUDO"
fi
if [ "$*" = "." ]; then
$sudo sage-pip-uninstall "$@" || \
sdh_die "Error uninstalling a previous version of $PKG_NAME"
fi
>>>>>>> 9750195b6f (WIP: Install pip packages with sage-spkg)
mkdir -p dist
rm -f dist/*.whl
install_options=""
Expand Down Expand Up @@ -303,14 +315,12 @@ sdh_store_wheel() {
if [ "$*" != "." ]; then
sdh_die "Error: sdh_store_wheel requires . as only argument"
fi
wheel=""
for w in dist/*.whl; do
if [ -n "$wheel" ]; then
sdh_die "Error: more than one wheel found after building"
fi
if [ -f "$w" ]; then
wheel="$w"
fi
for wheel in dist/*.whl; do
$sudo sage-pip-install $root "$wheel" || \
sdh_die "Error installing $wheel"
mkdir -p "${SAGE_DESTDIR}${SAGE_SPKG_WHEELS}" && \
$sudo mv "$wheel" "${SAGE_DESTDIR}${SAGE_SPKG_WHEELS}/" || \
sdh_die "Error storing $wheel"
done
if [ -z "$wheel" ]; then
sdh_die "Error: no wheel found after building"
Expand Down
5 changes: 4 additions & 1 deletion build/bin/sage-spkg
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,16 @@ if [ -f spkg-build ]; then
error_msg "Error installing package $PKG_NAME" "make"
exit 1
fi
else
elif [ -f spkg-install ]; then
# Package only has spkg-install
time ./spkg-install
if [ $? -ne 0 ]; then
error_msg "Error installing package $PKG_NAME" "make"
exit 1
fi
elif [ -f requirements.txt ]; then
. sage-dist-helpers
sdh_pip_install -r requirements.txt
fi

# To work around #26996: Remove the symlink set, or we get "cp: cannot overwrite directory"
Expand Down
34 changes: 5 additions & 29 deletions build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -537,40 +537,16 @@ $(foreach pkgname, $(NORMAL_PACKAGES),\
endif

# ================================ pip packages ===============================
# Generate build rules for 'pip' packages; this template is used to generate
# two rules in the form:
#
# <pkgname>: <dependencies>
# $(AM_V_at)sage-logger -p 'sage --pip install ...' '$(SAGE_LOGS)/<pkgname>.log'
#
# <pkgname>-clean:
# -sage --pip uninstall -y ...

# Positional arguments:
# $(1): package name
# $(2): package dependencies
define PIP_PACKAGE_templ
$(1)-build-deps: $(2)

$(1): $(2)
+$(MAKE_REC) $(1)-no-deps

$(1)-no-deps:
$(AM_V_at)sage-logger -p 'sage --pip install -r "$$(SAGE_ROOT)/build/pkgs/$(1)/requirements.txt"' '$$(SAGE_LOGS)/$(1).log'

$(1)-clean:
-sage --pip uninstall --isolated --yes --no-input -r '$$(SAGE_ROOT)/build/pkgs/$(1)/requirements.txt'

.PHONY: $(1) $(1)-clean $(1)-build-deps $(1)-no-deps
endef

$(foreach pkgname,$(PIP_PACKAGES),\
$(eval $(call PIP_PACKAGE_templ,$(pkgname),$(call pkg_deps,$(pkgname)))))
$(eval $(call NORMAL_PACKAGE_templ,$(pkgname),$(vers_$(pkgname)),$(call pkg_deps,$(pkgname)))))
$(foreach pkgname, $(PIP_PACKAGES),\
$(eval $(call NORMAL_PACKAGE_clean_templ,$(pkgname),$(vers_$(pkgname)),\
$(call pkg_deps,$(pkgname)))))

ifdef DEBUG_RULES
$(info # Rules for pip packages)
$(foreach pkgname,$(PIP_PACKAGES),\
$(info $(call PIP_PACKAGE_templ,$(pkgname),$(call pkg_deps,$(pkgname)))))
$(info $(call NORMAL_PACKAGE_templ,$(pkgname),$(vers_$(pkgname)),$(call pkg_deps,$(pkgname)))))
endif

# ============================= script packages ==============================
Expand Down

0 comments on commit 7a25d1d

Please sign in to comment.