summaryrefslogtreecommitdiffstats
path: root/Makefile.python.am
blob: 665893f435f772a6b4359b702f920f33b8d031a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pkgname = $(shell basename "$(abs_srcdir)")
pkgpythondir = $(pythondir)/$(pkgname)

if VERBOSE_MAKE
VERBOSITY="--verbose"
else
VERBOSITY="--quiet"
endif !VERBOSE_MAKE

# hack to handle back-in-the-hierarchy depedency on ipasetup.py
.PHONY: $(top_builddir)/ipasetup.py
$(top_builddir)/ipasetup.py:
	(cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ipasetup.py)

all-local: $(top_builddir)/ipasetup.py
	cd $(srcdir); $(PYTHON) setup.py \
		$(VERBOSITY) \
		build \
		--build-base "$(abs_builddir)/build"

install-exec-local: $(top_builddir)/ipasetup.py
	$(PYTHON) $(srcdir)/setup.py \
		$(VERBOSITY) \
		install \
		--prefix "$(DESTDIR)$(prefix)" \
		--single-version-externally-managed \
		--record "$(DESTDIR)$(pkgpythondir)/install_files.txt" \
		--optimize 1

uninstall-local:
	cat "$(DESTDIR)$(pkgpythondir)/install_files.txt" | xargs rm -rf
	rm -rf "$(DESTDIR)$(pkgpythondir)"

clean-local: $(top_builddir)/ipasetup.py
	$(PYTHON) "$(srcdir)/setup.py" clean --all
	rm -rf "$(srcdir)/build" "$(srcdir)/dist" "$(srcdir)/MANIFEST"
	find "$(srcdir)" \
		-name "*.py[co]" -delete -o	\
		-name "__pycache__" -delete -o	\
		-name "*.egg-info" -exec rm -rf {} +

# take list of all Python source files and copy them into distdir
# SOURCES.txt does not contain directories so we need to create those
dist-hook: $(top_builddir)/ipasetup.py
	$(PYTHON) "$(srcdir)/setup.py" egg_info
	PYTHON_SOURCES=$$(cat "$(srcdir)/$(pkgname).egg-info/SOURCES.txt") || exit $$?;	\
	for FILEN in $${PYTHON_SOURCES}; 						\
	do										\
		if test -x "$(srcdir)/$${FILEN}"; then MODE=755; else MODE=644; fi;	\
		$(INSTALL) -D -m $${MODE} "$(srcdir)/$${FILEN}" "$(distdir)/$${FILEN}" || exit $$?;	\
	done

WHEELDISTDIR = $(top_builddir)/dist/wheels
.PHONY: bdist_wheel
bdist_wheel: $(top_builddir)/ipasetup.py
	rm -rf $(WHEELDISTDIR)/$(pkgname)*.whl
	$(PYTHON) "$(srcdir)/setup.py" bdist_wheel --dist-dir=$(WHEELDISTDIR)