From 99dcc747380b6f379f78bab05719aceb38c7f0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Sat, 11 Nov 2023 09:46:05 -0800 Subject: [PATCH 1/3] Update Makefile --- .gitignore | 2 +- Makefile | 74 ++++++++++++++++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 194fb321..eb40849a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # build outputs -/dist/* /build/* /lib/PyYAML.egg-info/* +/.venv/ /wheelhouse/* /yaml/_yaml.c MANIFEST diff --git a/Makefile b/Makefile index fc66e0a2..e4ca1ca0 100644 --- a/Makefile +++ b/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 . From 0536509839864b2c86f53817701e2c68490b5913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Sat, 11 Nov 2023 10:01:48 -0800 Subject: [PATCH 2/3] Makefile cleanups --- .gitignore | 2 +- Makefile | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index eb40849a..86fcdd88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # build outputs -/build/* +/build/ /lib/PyYAML.egg-info/* /.venv/ /wheelhouse/* diff --git a/Makefile b/Makefile index e4ca1ca0..c2ab1e8c 100644 --- a/Makefile +++ b/Makefile @@ -22,27 +22,27 @@ o ?= default: test: venv - PYYAML_FORCE_LIBYAML=0 pytest + PYYAML_FORCE_LIBYAML=0 pytest $o test-ext: venv - PYYAML_FORCE_LIBYAML=1 pytest + PYYAML_FORCE_LIBYAML=1 pytest $o build: venv - ${PYTHON} setup.py build ${o} + python setup.py build $o build-ext: venv - ${PYTHON} setup.py --with-libyaml build ${o} + python setup.py --with-libyaml build $o install: venv - ${PYTHON} setup.py install ${o} + python setup.py install $o installext: venv - ${PYTHON} setup.py --with-libyaml install ${o} + python setup.py --with-libyaml install $o clean: - ${PYTHON} setup.py --with-libyaml clean -a $(RM) -r \ .pytest_cache/ \ + build/ \ lib/PyYAML.egg-info/ \ lib/yaml/__pycache__/ \ tests/__pycache__/ \ @@ -57,6 +57,5 @@ venv: $(VENV) $(VENV): $(PYTHON) -m venv $@ - @echo $(PATH) pip install pytest pip install -e . From 0785606a3e8f02c546b27e09d8115fca3e611db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Sat, 11 Nov 2023 11:07:42 -0800 Subject: [PATCH 3/3] Makefile does pip upgrade for making .venv --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index c2ab1e8c..a0842653 100644 --- a/Makefile +++ b/Makefile @@ -57,5 +57,6 @@ venv: $(VENV) $(VENV): $(PYTHON) -m venv $@ + pip install --upgrade pip pip install pytest pip install -e .