Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Makefile #764

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# build outputs
/dist/*
/build/*
/build/
/lib/PyYAML.egg-info/*
/.venv/
/wheelhouse/*
/yaml/_yaml.c
MANIFEST
Expand Down
76 changes: 45 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 $o

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

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/ \
build/ \
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 $@
pip install --upgrade pip
pip install pytest
pip install -e .