summaryrefslogtreecommitdiff
path: root/lang/python/wheel.mk
blob: 22908c722e464ba2e0ceed5ebfb12b5dc1a69377 (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
58
59
60
61
62
63
64
# $NetBSD: wheel.mk,v 1.2 2022/01/13 09:49:35 wiz Exp $
#
# Initial mk for building and installing python wheels
#
# Variables:
# 
# WHEELFILE:		path to the wheelfile to be installed
#			only needs to be set if do-build is redefined
#
# MASTER_SITE_WHEEL:	master site to grab wheels directly 
#			use like ${MASTER_SITE_WHEEL:=project/}
#			uses debian pypi redirector so that there
#			is no need for hashes in urls.
#
# TODO: 		fix BUILDDIR support
#			
# Feel free to contribute to this file
#			

.include "../../lang/python/pyversion.mk"

TOOL_DEPENDS+= ${PYPKGPREFIX}-pip>=0:../../devel/py-pip

WHEELFILE?= ${WRKSRC}/dist/*.whl

.if defined(NO_BUILD)

MASTER_SITE_WHEEL= https://pypi.debian.net/

WHEELFILE= ${DISTFILES}

.for i in 2 3
.if !empty(_PYTHON_VERSIONS_ACCEPTED:M${i}*)
PYMAJORVERSIONS+= py${i}
.endif
.endfor

EXTRACT_SUFX= -${PYMAJORVERSIONS:ts.}-none-any.whl

.else
#we need to build a wheel

TOOL_DEPENDS+= ${PYPKGPREFIX}-build>=0:../../devel/py-build

.if !target(do-build)
do-build:
	${RUN} cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${PYTHONBIN} -m build --wheel -x -n
.endif

.endif

WHEEL_NAME?=	${DISTNAME:C/-([^0-9])/_\1/g}
_WHEEL_INFODIR=	${WHEEL_NAME}.dist-info
PLIST_SUBST+=	PYSITELIB=${PYSITELIB}
PLIST_SUBST+=	WHEEL_INFODIR=${_WHEEL_INFODIR}

PRINT_PLIST_AWK+=	{ gsub(/${_WHEEL_INFODIR:S,.,\.,g}/, "$${WHEEL_INFODIR}") }

INSTALL_ENV+= PIP_NO_CACHEDIR=1

do-install:
	${RUN} cd ${WRKDIR} && \
	${SETENV} ${INSTALL_ENV} \
	${PYTHONBIN} -m pip install --no-cache-dir --no-deps --root ${DESTDIR:Q} --prefix ${PREFIX:Q} --compile --force-reinstall -I ${WHEELFILE}