Skip to content

Commit

Permalink
Changed Makefile to restart itself if not in venv (when needed).
Browse files Browse the repository at this point in the history
Simplifies building.
  • Loading branch information
efocht committed Nov 16, 2023
1 parent 7a1551c commit a93a9e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
47 changes: 33 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#
# install cython in a virtualenv named cython
# workon cython
# ...
#
# Most targets are expected to be built inside a virtualenv,
# its building as well as restarting make in it is automated.

veosinfo/_veosinfo.so: veosinfo/_veosinfo.pyx
python setup.py build_ext -i --use-cython
ifeq ($(VIRTUAL_ENV),)

test:
PATHONPATH=. python test_veosinfo.py
# If virtual environment is not active, restart within virtual environment
SELF := $(MAKE) -f $(lastword $(MAKEFILE_LIST))
MAKE := $(shell echo $$MAKE)

clean:
rm -f veosinfo/*.so veosinfo/_veosinfo.c veosinfo/*.pyc
in_venv: | venv
@echo "Virtual environment not active. Restarting within virtual environment..."
@echo "MAKECMDGOALS = $(MAKECMDGOALS)"
. venv/bin/activate && $(SELF) $(MAKEFLAGS) $(MAKECMDGOALS)

install: veosinfo/_veosinfo.so
python setup.py install
sdist rpm srpm upload: in_venv

else

veosinfo/_veosinfo.so: in_venv veosinfo/_veosinfo.pyx
python setup.py build_ext -i --use-cython

.PHONY: sdist upload
sdist:
python setup.py sdist --use-cython

Expand All @@ -31,5 +35,20 @@ rpm: veosinfo/_veosinfo.so
srpm: veosinfo/_veosinfo.so
python setup.py bdist_rpm --source-only

.PHONY: test clean install sdist rpm
endif

.PHONY: test clean install
test:
PYTHONPATH=. python test_veosinfo.py

clean:
rm -f veosinfo/*.so veosinfo/_veosinfo.c veosinfo/*.pyc

install: veosinfo/_veosinfo.so
python setup.py install

venv:
python3 -m venv venv && \
. venv/bin/activate && \
pip install -U pip && \
pip install -r requirements.txt
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cython
twine
wheel

0 comments on commit a93a9e1

Please sign in to comment.