|
| 1 | +R := https://github.com/makeplus/makes |
| 2 | +C := b0edc13d2045c1a06a92752ea4bfb48cbb59cc4b |
| 3 | +M := $(or $(MAKES_REPO_DIR),.cache/makes) |
| 4 | +$(shell [ -d '$M' ] || git clone -q $R '$M') |
| 5 | +$(shell cd '$M' && [ "$$(git rev-parse HEAD)" = '$C' ] || \ |
| 6 | + { git fetch -q origin && git checkout -q '$C'; }) |
1 | 7 |
|
2 | | -.PHONY: build dist |
| 8 | +include $M/init.mk |
| 9 | + |
| 10 | +export UV_CACHE_DIR = $(LOCAL-CACHE)/uv |
| 11 | +PYTHON-VENV-SETUP = uv pip install Cython pytest setuptools wheel |
| 12 | +include $M/python.mk |
| 13 | +include $M/clean.mk |
| 14 | +include $M/shell.mk |
| 15 | + |
| 16 | +PYTHON-DEPS = $(PYTHON) $(PYTHON-VENV) |
| 17 | +PYTEST-PYTHON = \ |
| 18 | +import sys; \ |
| 19 | +sys.path.insert(0, 'build/lib'); \ |
| 20 | +import pytest; \ |
| 21 | +raise SystemExit(pytest.main()) |
| 22 | + |
| 23 | +PYTEST-LIBYAML = \ |
| 24 | +import pathlib, sys; \ |
| 25 | +sys.path.insert(0, next(str(p) for p in pathlib.Path('build').glob('lib.*'))); \ |
| 26 | +import pytest; \ |
| 27 | +raise SystemExit(pytest.main()) |
3 | 28 |
|
4 | | -PYTHON=/usr/bin/python3 |
5 | 29 | TEST= |
6 | 30 | PARAMETERS= |
7 | 31 |
|
8 | | -build: |
9 | | - ${PYTHON} setup.py build ${PARAMETERS} |
| 32 | +LIBYAML-REPO ?= https://github.com/yaml/libyaml |
| 33 | +LIBYAML-REF ?= 0.2.5 |
| 34 | +LIBYAML-DIR := $(LOCAL-CACHE)/libyaml-$(LIBYAML-REF) |
| 35 | +LIBYAML-BUILD := $(LIBYAML-DIR)/src/.libs/libyaml.$(SO) |
| 36 | +LIBYAML-INCLUDE := $(LIBYAML-DIR)/include |
| 37 | +LIBYAML-LIB := $(LIBYAML-DIR)/src/.libs |
| 38 | +LIBYAML-ENV := \ |
| 39 | + CFLAGS="-I$(LIBYAML-INCLUDE) $${CFLAGS:-}" \ |
| 40 | + LDFLAGS="-L$(LIBYAML-LIB) $${LDFLAGS:-}" \ |
| 41 | + LD_LIBRARY_PATH="$(LIBYAML-LIB):$${LD_LIBRARY_PATH:-}" |
| 42 | + |
| 43 | +MAKES-CLEAN := \ |
| 44 | + lib/PyYAML.egg-info/ \ |
| 45 | + lib/yaml/__pycache__/ \ |
| 46 | + tests/__pycache__/ \ |
| 47 | + tests/legacy_tests/__pycache__/ \ |
| 48 | + .pytest_cache/ \ |
| 49 | + yaml/_yaml.c \ |
| 50 | + build/ \ |
| 51 | + dist \ |
| 52 | + |
10 | 53 |
|
11 | | -buildext: |
12 | | - ${PYTHON} setup.py --with-libyaml build ${PARAMETERS} |
| 54 | +build: $(PYTHON-DEPS) |
| 55 | + python setup.py build $(PARAMETERS) |
13 | 56 |
|
14 | | -force: |
15 | | - ${PYTHON} setup.py build -f ${PARAMETERS} |
| 57 | +build-python: $(PYTHON-DEPS) |
| 58 | + PYYAML_FORCE_LIBYAML=0 python setup.py --without-libyaml build $(PARAMETERS) |
16 | 59 |
|
17 | | -forceext: |
18 | | - ${PYTHON} setup.py --with-libyaml build -f ${PARAMETERS} |
| 60 | +buildext: $(PYTHON-DEPS) $(LIBYAML-BUILD) |
| 61 | + $(LIBYAML-ENV) python setup.py --with-libyaml build $(PARAMETERS) |
19 | 62 |
|
20 | | -install: |
21 | | - ${PYTHON} setup.py install ${PARAMETERS} |
| 63 | +force: $(PYTHON-DEPS) |
| 64 | + python setup.py build -f $(PARAMETERS) |
22 | 65 |
|
23 | | -installext: |
24 | | - ${PYTHON} setup.py --with-libyaml install ${PARAMETERS} |
| 66 | +forceext: $(PYTHON-DEPS) $(LIBYAML-BUILD) |
| 67 | + $(LIBYAML-ENV) python setup.py --with-libyaml build -f $(PARAMETERS) |
25 | 68 |
|
26 | | -test: build |
27 | | - PYYAML_FORCE_LIBYAML=0 ${PYTHON} -I -m pytest |
| 69 | +install: $(PYTHON-DEPS) |
| 70 | + python setup.py install $(PARAMETERS) |
28 | 71 |
|
29 | | -testext: buildext |
30 | | - PYYAML_FORCE_LIBYAML=1 ${PYTHON} -I -m pytest |
| 72 | +installext: $(PYTHON-DEPS) $(LIBYAML-BUILD) |
| 73 | + $(LIBYAML-ENV) python setup.py --with-libyaml install $(PARAMETERS) |
31 | 74 |
|
32 | | -testall: |
33 | | - ${PYTHON} -m pytest |
| 75 | +test: test-python test-libyaml |
34 | 76 |
|
35 | | -dist: |
| 77 | +test-python: build-python |
| 78 | + PYYAML_FORCE_LIBYAML=0 python -I -c "$(PYTEST-PYTHON)" |
| 79 | + |
| 80 | +test-libyaml: buildext |
| 81 | + $(LIBYAML-ENV) PYYAML_FORCE_LIBYAML=1 python -I -c "$(PYTEST-LIBYAML)" |
| 82 | + |
| 83 | +$(LIBYAML-BUILD): |
| 84 | + rm -fr $(LIBYAML-DIR) |
| 85 | + git clone --branch $(LIBYAML-REF) $(LIBYAML-REPO) $(LIBYAML-DIR) |
| 86 | + cd $(LIBYAML-DIR) && git reset --hard $(LIBYAML-REF) |
| 87 | + cd $(LIBYAML-DIR) && ./bootstrap |
| 88 | + cd $(LIBYAML-DIR) && ./configure --disable-dependency-tracking --with-pic --enable-shared=yes |
| 89 | + $(MAKE) -C $(LIBYAML-DIR) |
| 90 | + |
| 91 | +dist: $(PYTHON-DEPS) |
36 | 92 | @# No longer uploading a zip file to pypi |
37 | | - @# ${PYTHON} setup.py --with-libyaml sdist --formats=zip,gztar |
38 | | - ${PYTHON} setup.py --with-libyaml sdist --formats=gztar |
39 | | - |
40 | | -clean: |
41 | | - ${PYTHON} setup.py --with-libyaml clean -a |
42 | | - rm -fr \ |
43 | | - dist/ \ |
44 | | - lib/PyYAML.egg-info/ \ |
45 | | - lib/yaml/__pycache__/ \ |
46 | | - tests/__pycache__/ \ |
47 | | - tests/legacy_tests/__pycache__/ \ |
48 | | - yaml/_yaml.c |
| 93 | + @# python setup.py --with-libyaml sdist --formats=zip,gztar |
| 94 | + python setup.py --with-libyaml sdist --formats=gztar |
| 95 | + |
| 96 | +.PHONY: build dist |
0 commit comments