From 23dbdf541a8f51be0fcd40c7839c2ed29eb88519 Mon Sep 17 00:00:00 2001 From: anacso17 Date: Wed, 19 Jan 2022 19:59:32 -0300 Subject: [PATCH] ENH: use pip in Makefile targets and adapt to conda env --- siriuspy/Makefile | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/siriuspy/Makefile b/siriuspy/Makefile index b898a63f5..8c6a4ff0d 100644 --- a/siriuspy/Makefile +++ b/siriuspy/Makefile @@ -1,37 +1,29 @@ -DISTPATH=$(shell python-sirius -c "import site; print(site.getsitepackages())" | cut -f2 -d"'") PACKAGE:=$(shell basename $(shell pwd)) -ISINST=$(shell sudo pip-sirius show $(PACKAGE) | wc -l ) -EGGLINK=$(DISTPATH)/$(PACKAGE).egg-link -TMPFOLDER=/tmp/install-$(PACKAGE) +PREFIX= +PIP=pip +ifeq ($(CONDA_PREFIX),) + PREFIX=sudo -H + PIP=pip-sirius +endif clean: git clean -fdX -develop: uninstall - pip-sirius install --no-deps -e ./ +install: clean uninstall + $(PREFIX) $(PIP) install --no-deps ./ -install: uninstall -ifneq (, $(wildcard $(TMPFOLDER))) - rm -rf /tmp/install-$(PACKAGE) -endif - cp -rRL ../$(PACKAGE) /tmp/install-$(PACKAGE) - cd /tmp/install-$(PACKAGE)/; sudo -H pip-sirius install --no-deps ./ - rm -rf /tmp/install-$(PACKAGE) +uninstall: + $(PREFIX) $(PIP) uninstall -y $(PACKAGE) + +develop-install: clean develop-uninstall + $(PIP) install --no-deps -e ./ # known issue: It will fail to uninstall scripts # if they were installed in develop mode -uninstall: clean -ifneq (,$(wildcard $(EGGLINK))) - rm -r $(EGGLINK) -endif -ifneq ($(ISINST),0) - pip-sirius uninstall -y $(PACKAGE) - sed -i '/$(PACKAGE)/d' $(DISTPATH)/easy-install.pth -else - echo 'already uninstalled $(PACKAGE)' -endif +develop-uninstall: + $(PIP) uninstall -y $(PACKAGE) -test: +test: pytest tests/ dist: clean ## Build setuptools dist