Skip to content

Commit 8b919ef

Browse files
committed
Fix up Makefile to work with pyproject.toml
1 parent 4c7555f commit 8b919ef

1 file changed

Lines changed: 15 additions & 33 deletions

File tree

Makefile

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
# External utilities
44
PYTHON=python3
5-
PIP=pip
5+
PIP=pip3
66
PYTEST=pytest
77
TWINE=twine
88
PYFLAGS=
99
MSGINIT=msginit
1010
MSGMERGE=msgmerge
1111
MSGFMT=msgfmt
1212
XGETTEXT=xgettext
13-
DEST_DIR=/
13+
DESTDIR=/
14+
BUILDDIR=build
1415

1516
# Find the location of the GObject introspection libs and cairo (required for
1617
# the develop target)
@@ -20,12 +21,10 @@ GLIB:=
2021

2122
# Calculate the base names of the distribution, the location of all source,
2223
# documentation, packaging, icon, and executable script files
23-
NAME:=$(shell $(PYTHON) $(PYFLAGS) setup.py --name)
24+
NAME:=$(shell $(PYTHON) $(PYFLAGS) -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")
2425
WHEEL_NAME:=$(subst -,_,$(NAME))
25-
VER:=$(shell $(PYTHON) $(PYFLAGS) setup.py --version)
26-
PY_SOURCES:=$(shell \
27-
$(PYTHON) $(PYFLAGS) setup.py egg_info >/dev/null 2>&1 && \
28-
cat $(WHEEL_NAME).egg-info/SOURCES.txt | grep -v "\.egg-info" | grep -v "\.mo$$")
26+
VER:=$(shell $(PYTHON) $(PYFLAGS) -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
27+
PY_SOURCES:=$(wildcard pemmican/*.py)
2928
DOC_SOURCES:=docs/conf.py \
3029
$(wildcard docs/*.png) \
3130
$(wildcard docs/*.svg) \
@@ -34,12 +33,10 @@ DOC_SOURCES:=docs/conf.py \
3433
$(wildcard docs/*.gpi) \
3534
$(wildcard docs/*.rst) \
3635
$(wildcard docs/*.pdf)
37-
SUBDIRS:=
3836

3937
# Calculate the name of all outputs
4038
DIST_WHEEL=dist/$(WHEEL_NAME)-$(VER)-py3-none-any.whl
4139
DIST_TAR=dist/$(NAME)-$(VER).tar.gz
42-
DIST_ZIP=dist/$(NAME)-$(VER).zip
4340
POT_FILE=po/$(NAME).pot
4441
PO_FILES:=$(wildcard po/*.po)
4542
MO_FILES:=$(patsubst po/%.po,po/mo/%/LC_MESSAGES/$(NAME).mo,$(PO_FILES))
@@ -59,15 +56,13 @@ all:
5956
@echo "make doc - Generate HTML and PDF documentation"
6057
@echo "make source - Create source package"
6158
@echo "make wheel - Generate a PyPI wheel package"
62-
@echo "make zip - Generate a source zip package"
63-
@echo "make tar - Generate a source tar package"
6459
@echo "make dist - Generate all packages"
6560
@echo "make clean - Get rid of all generated files"
6661
@echo "make release - Create and tag a new release"
6762
@echo "make upload - Upload the new release to repositories"
6863

69-
install: $(SUBDIRS)
70-
$(PYTHON) $(PYFLAGS) setup.py install --root $(DEST_DIR)
64+
install:
65+
$(PIP) install . --root $(DESTDIR)
7166

7267
doc: $(DOC_SOURCES)
7368
$(MAKE) -C docs clean
@@ -79,14 +74,10 @@ doc: $(DOC_SOURCES)
7974
preview:
8075
$(MAKE) -C docs preview
8176

82-
source: $(DIST_TAR) $(DIST_ZIP)
77+
source: $(DIST_TAR)
8378

8479
wheel: $(DIST_WHEEL)
8580

86-
zip: $(DIST_ZIP)
87-
88-
tar: $(DIST_TAR)
89-
9081
dist: $(DIST_WHEEL) $(DIST_TAR) $(DIST_ZIP)
9182

9283
pot: $(POT_FILE) $(PO_FILES)
@@ -121,10 +112,7 @@ test:
121112
$(PYTEST)
122113

123114
clean:
124-
rm -fr dist/ build/ man/ .pytest_cache/ .mypy_cache/ $(WHEEL_NAME).egg-info/ tags .coverage
125-
for dir in $(SUBDIRS); do \
126-
$(MAKE) -C $$dir clean; \
127-
done
115+
rm -rf $(BUILDDIR) .pytest_cache/ .mypy_cache/ $(WHEEL_NAME).egg-info/ tags .coverage
128116
find $(CURDIR) -name "*.pyc" -delete
129117
find $(CURDIR) -name "__pycache__" -delete
130118

@@ -134,9 +122,6 @@ tags: $(PY_SOURCES)
134122
lint: $(PY_SOURCES)
135123
pylint $(WHEEL_NAME)
136124

137-
$(SUBDIRS):
138-
$(MAKE) -C $@
139-
140125
$(MAN_PAGES): $(DOC_SOURCES)
141126
$(MAKE) -C docs man
142127
mkdir -p man/
@@ -152,14 +137,11 @@ po/mo/%/LC_MESSAGES/$(NAME).mo: po/%.po
152137
mkdir -p $(dir $@)
153138
$(MSGFMT) $< -o $@
154139

155-
$(DIST_TAR): $(PY_SOURCES) $(SUBDIRS)
156-
$(PYTHON) $(PYFLAGS) setup.py sdist --formats gztar
157-
158-
$(DIST_ZIP): $(PY_SOURCES) $(SUBDIRS)
159-
$(PYTHON) $(PYFLAGS) setup.py sdist --formats zip
140+
$(DIST_TAR): $(PY_SOURCES)
141+
$(PYTHON) $(PYFLAGS) -m build --sdist -o $(BUILDDIR)/dist .
160142

161-
$(DIST_WHEEL): $(PY_SOURCES) $(SUBDIRS)
162-
$(PYTHON) $(PYFLAGS) setup.py bdist_wheel
143+
$(DIST_WHEEL): $(PY_SOURCES)
144+
$(PYTHON) $(PYFLAGS) -m build --wheel -o $(BUILDDIR)/dist .
163145

164146
release:
165147
$(MAKE) clean
@@ -171,4 +153,4 @@ upload: $(DIST_TAR) $(DIST_WHEEL)
171153
$(TWINE) check $(DIST_TAR) $(DIST_WHEEL)
172154
$(TWINE) upload $(DIST_TAR) $(DIST_WHEEL)
173155

174-
.PHONY: all install develop test doc source wheel zip tar dist clean tags release upload $(SUBDIRS)
156+
.PHONY: all install develop test doc source wheel zip tar dist clean tags release upload

0 commit comments

Comments
 (0)