summaryrefslogtreecommitdiff
path: root/lang/python/pyversion.mk
blob: ea43846583008182543e4f17542853bdbe7824cd (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# $NetBSD: pyversion.mk,v 1.28 2004/06/06 16:24:55 tv Exp $

.if !defined(PYTHON_PYVERSION_MK)
PYTHON_PYVERSION_MK=	defined

.include "../../mk/bsd.prefs.mk"

PYTHON_VERSION_DEFAULT?=		23
.if ${OPSYS} == "Darwin"
PYTHON_VERSIONS_INCOMPATIBLE+=		23 22 21 21pth 20 15
BUILDLINK_DEPENDS.python22-pth?=	python22-pth>=2.2.3nb2
BUILDLINK_DEPENDS.python23-pth?=	python23-pth>=2.3.3nb3
.endif
PYTHON_VERSIONS_ACCEPTED?=		23 23pth 22 22pth 21 21pth 20
PYTHON_VERSIONS_INCOMPATIBLE?=		# empty by default

BUILDLINK_DEPENDS.python15?=		python15>=1.5
BUILDLINK_DEPENDS.python20?=		python20>=2.0
BUILDLINK_DEPENDS.python21?=		python21>=2.1
BUILDLINK_DEPENDS.python21-pth?=	python21-pth>=2.1
BUILDLINK_DEPENDS.python22?=		python22>=2.2
BUILDLINK_DEPENDS.python22-pth?=	python22-pth>=2.2
BUILDLINK_DEPENDS.python23?=		python23>=2.3
BUILDLINK_DEPENDS.python23-pth?=	python23-pth>=2.3

# transform the list into individual variables
.for pv in ${PYTHON_VERSIONS_ACCEPTED}
.if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
_PYTHON_VERSION_${pv}_OK=	yes
.endif
.endfor

# check what is installed
.if exists(${LOCALBASE}/bin/python2.3)
_PYTHON_VERSION_23_INSTALLED=	yes
.endif
.if exists(${LOCALBASE}/bin/python2p3)
_PYTHON_VERSION_23pth_INSTALLED=yes
.endif
.if exists(${LOCALBASE}/bin/python2.2)
_PYTHON_VERSION_22_INSTALLED=	yes
.endif
.if exists(${LOCALBASE}/bin/python2p2)
_PYTHON_VERSION_22pth_INSTALLED=yes
.endif
.if exists(${LOCALBASE}/bin/python2.1)
_PYTHON_VERSION_21_INSTALLED=	yes
.endif
.if exists(${LOCALBASE}/bin/python2p1)
_PYTHON_VERSION_21pth_INSTALLED=yes
.endif
.if exists(${LOCALBASE}/bin/python2.0)
_PYTHON_VERSION_20_INSTALLED=	yes
.endif
.if exists(${LOCALBASE}/bin/python1.5)
_PYTHON_VERSION_15_INSTALLED=	yes
.endif

#
# choose a python version where to add,
# try to be intelligent
#
# if a version is explicitely required, take it
.if defined(PYTHON_VERSION_REQD)
_PYTHON_VERSION=	${PYTHON_VERSION_REQD}
.endif
# if the default is already installed, it is first choice
.if !defined(_PYTHON_VERSION)
.if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
.if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_INSTALLED)
_PYTHON_VERSION=	${PYTHON_VERSION_DEFAULT}
.endif
.endif
.endif
# prefer an already installed version, in order of "accepted"
.if !defined(_PYTHON_VERSION)
.for pv in ${PYTHON_VERSIONS_ACCEPTED}
.if defined(_PYTHON_VERSION_${pv}_OK)
.if defined(_PYTHON_VERSION_${pv}_INSTALLED)
_PYTHON_VERSION?=	${pv}
.else
# keep information as last resort - see below
_PYTHON_VERSION_FIRSTACCEPTED?=	${pv}
.endif
.endif
.endfor
.endif
# if the default is OK for the addon pkg, take this
.if !defined(_PYTHON_VERSION)
.if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
_PYTHON_VERSION=	${PYTHON_VERSION_DEFAULT}
.endif
.endif
# take the first one accepted by the package
.if !defined(_PYTHON_VERSION)
_PYTHON_VERSION=	${_PYTHON_VERSION_FIRSTACCEPTED}
.endif

#
# set variables for the version we decided to use:
#  PYVERSSUFFIX: suffix to executables and in library path,
#                equal to sys.version[0:3]
#  PYPKGPREFIX: prefix to use in PKGNAME for extensions which can install
#               to multiple Python versions
#
.if ${_PYTHON_VERSION} == "23"
PYPKGSRCDIR=	../../lang/python23
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python23}:${PYPKGSRCDIR}
PYPACKAGE=	python23
PYVERSSUFFIX=	2.3
PYPKGPREFIX=	py23
.elif ${_PYTHON_VERSION} == "23pth"
PYPKGSRCDIR=	../../lang/python23-pth
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python23-pth}:${PYPKGSRCDIR}
PYPACKAGE=	python23-pth
PYVERSSUFFIX=	2p3
PYPKGPREFIX=	py23pth
.  if defined(USE_BUILDLINK3) && empty(USE_BUILDLINK3:M[nN][oO])
PTHREAD_OPTS=	require
.    include "../../mk/pthread.buildlink3.mk"
.    if ${PTHREAD_TYPE} == "pth"
.        include "../../devel/pth/buildlink3.mk"
.    endif
.  endif
.elif ${_PYTHON_VERSION} == "22"
PYPKGSRCDIR=	../../lang/python22
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python22}:${PYPKGSRCDIR}
PYPACKAGE=	python22
PYVERSSUFFIX=	2.2
PYPKGPREFIX=	py22
.elif ${_PYTHON_VERSION} == "22pth"
PYPKGSRCDIR=	../../lang/python22-pth
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python22-pth}:${PYPKGSRCDIR}
PYPACKAGE=	python22-pth
PYVERSSUFFIX=	2p2
PYPKGPREFIX=	py22pth
.  if defined(USE_BUILDLINK3) && empty(USE_BUILDLINK3:M[nN][oO])
PTHREAD_OPTS=	require
.    include "../../mk/pthread.buildlink3.mk"
.    if ${PTHREAD_TYPE} == "pth"
.        include "../../devel/pth/buildlink3.mk"
.    endif
.  endif
.elif ${_PYTHON_VERSION} == "21"
PYPKGSRCDIR=	../../lang/python21
PYPACKAGE=	python21
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python21}:${PYPKGSRCDIR}
PYVERSSUFFIX=	2.1
PYPKGPREFIX=	py21
.elif ${_PYTHON_VERSION} == "21pth"
PYPKGSRCDIR=	../../lang/python21-pth
PYPACKAGE=	python21-pth
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python21-pth}:${PYPKGSRCDIR}
PYVERSSUFFIX=	2p1
PYPKGPREFIX=	py21pth
.  if defined(USE_BUILDLINK3) && empty(USE_BUILDLINK3:M[nN][oO])
PTHREAD_OPTS=	require
.    include "../../mk/pthread.buildlink3.mk"
.    if ${PTHREAD_TYPE} == "pth"
.        include "../../devel/pth/buildlink3.mk"
.    endif
.  endif
.elif ${_PYTHON_VERSION} == "20"
PYPKGSRCDIR=	../../lang/python20
PYPACKAGE=	python20
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python20}:${PYPKGSRCDIR}
PYVERSSUFFIX=	2.0
PYPKGPREFIX=	py20
.elif ${_PYTHON_VERSION} == "15"
PYPKGSRCDIR=	../../lang/python15
PYPACKAGE=	python15
PYDEPENDENCY=	${BUILDLINK_DEPENDS.python15}:${PYPKGSRCDIR}
PYVERSSUFFIX=	1.5
PYPKGPREFIX=	py15
.if !defined(PYTHON_DISTUTILS_BOOTSTRAP)
BUILD_DEPENDS+=	py15-distutils-*:../../devel/py-distutils
.endif
.else
# force an error
	error: no valid Python version
.endif

.if (defined(USE_BUILDLINK3) && empty(USE_BUILDLINK3:M[nN][oO]))
.  if defined(PYTHON_FOR_BUILD_ONLY)
BUILD_DEPMETHOD.python?=	build
.  endif
.  include "${PYPKGSRCDIR}/buildlink3.mk"
.else
.  if defined(PYTHON_FOR_BUILD_ONLY)
BUILD_DEPENDS+=	${PYDEPENDENCY}
.  else
DEPENDS+=	${PYDEPENDENCY}
.  endif
.endif

PYTHONBIN=	${LOCALBASE}/bin/python${PYVERSSUFFIX}

.if exists(${PYTHONBIN})
PYINC!=	${PYTHONBIN} -c "import distutils.sysconfig; \
	print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
PYLIB!=	${PYTHONBIN} -c "import distutils.sysconfig; \
	print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
PYSITELIB!=	${PYTHONBIN} -c "import distutils.sysconfig; \
	print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""
.endif

.endif	# PYTHON_PYVERSION_MK