Skip to content

Commit

Permalink
Update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Nov 11, 2023
1 parent a98fd60 commit 99dcc74
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
# build outputs
/dist/*
/build/*
/lib/PyYAML.egg-info/*
/.venv/
/wheelhouse/*
/yaml/_yaml.c
MANIFEST
Expand Down
74 changes: 44 additions & 30 deletions Makefile
@@ -1,48 +1,62 @@
SHELL := bash

.PHONY: build dist
PYTHON ?= $(shell command -v python3)
PYTHON ?= $(shell command -v python)

PYTHON=/usr/bin/python3
TEST=
PARAMETERS=
ifndef PYTHON
$(error Can't find 'python3'. Set PYTHON=/path/to/bin/python3)
endif

build:
${PYTHON} setup.py build ${PARAMETERS}
ifeq (,$(shell $(PYTHON) --version | grep -E 'Python 3\.([6789]|1[0-9])\.' || true))
$(error Unsupported python version. Needs 3.6+)
endif

buildext:
${PYTHON} setup.py --with-libyaml build ${PARAMETERS}
VENV ?= .venv

force:
${PYTHON} setup.py build -f ${PARAMETERS}
export PATH := $(VENV)/bin:$(PATH)

forceext:
${PYTHON} setup.py --with-libyaml build -f ${PARAMETERS}
o ?=

install:
${PYTHON} setup.py install ${PARAMETERS}
.DELETE_ON_ERROR:

installext:
${PYTHON} setup.py --with-libyaml install ${PARAMETERS}
default:

test: build
PYYAML_FORCE_LIBYAML=0 ${PYTHON} -I -m pytest
test: venv
PYYAML_FORCE_LIBYAML=0 pytest

testext: buildext
PYYAML_FORCE_LIBYAML=1 ${PYTHON} -I -m pytest
test-ext: venv
PYYAML_FORCE_LIBYAML=1 pytest

testall:
${PYTHON} -m pytest
build: venv
${PYTHON} setup.py build ${o}

dist:
@# No longer uploading a zip file to pypi
@# ${PYTHON} setup.py --with-libyaml sdist --formats=zip,gztar
${PYTHON} setup.py --with-libyaml sdist --formats=gztar
build-ext: venv
${PYTHON} setup.py --with-libyaml build ${o}

install: venv
${PYTHON} setup.py install ${o}

installext: venv
${PYTHON} setup.py --with-libyaml install ${o}

clean:
${PYTHON} setup.py --with-libyaml clean -a
rm -fr \
dist/ \
$(RM) -r \
.pytest_cache/ \
lib/PyYAML.egg-info/ \
lib/yaml/__pycache__/ \
tests/__pycache__/ \
tests/legacy_tests/__pycache__/ \
yaml/_yaml.c
tests/legacy_tests/__pycache__/
$(RM) yaml/_yaml.c \
lib/yaml/_yaml.cpython-*

distclean: clean
$(RM) -r $(VENV)

venv: $(VENV)

$(VENV):
$(PYTHON) -m venv $@
@echo $(PATH)
pip install pytest
pip install -e .

0 comments on commit 99dcc74

Please sign in to comment.