Annotation of pkgsrc/lang/python/pyversion.mk, revision 1.105
1.105 ! tsarna 1: # $NetBSD: pyversion.mk,v 1.104 2012/10/03 23:48:00 cheusov Exp $
1.44 rillig 2:
3: # This file determines which Python version is used as a dependency for
4: # a package.
5: #
1.48 rillig 6: # === User-settable variables ===
1.44 rillig 7: #
8: # PYTHON_VERSION_DEFAULT
9: # The preferred Python version to use.
10: #
1.105 ! tsarna 11: # Possible values: 26 27 31 32 33
1.96 wiz 12: # Default: 27
1.44 rillig 13: #
1.104 cheusov 14: # === Infrastructure variables ===
15: #
1.101 cheusov 16: # PYTHON_VERSION_REQD
1.104 cheusov 17: # Python version to use. This variable should not be set in
18: # packages. Normally it is used by bulk build tools.
1.101 cheusov 19: #
20: # Possible: ${PYTHON_VERSIONS_ACCEPTED}
21: # Default: ${PYTHON_VERSION_DEFAULT}
22: #
1.48 rillig 23: # === Package-settable variables ===
1.44 rillig 24: #
25: # PYTHON_VERSIONS_ACCEPTED
26: # The Python versions that are acceptable for the package. The
1.48 rillig 27: # order of the entries matters, since earlier entries are
1.62 joerg 28: # preferred over later ones.
1.44 rillig 29: #
1.105 ! tsarna 30: # Possible values: 33 32 31 27 26
! 31: # Default: (33 32 31) 27 26
1.92 joerg 32: #
33: # PYTHON_VERSIONS_INCLUDE_3X
34: # Wether the default PYTHON_VERSIONS_ACCEPTED should include
35: # 3.x versions for for this package or not.
36: # This variable must be set before including bsd.prefs.mk.
37: #
38: # Possible values: yes no
39: # Default: no
1.44 rillig 40: #
41: # PYTHON_VERSIONS_INCOMPATIBLE
42: # The Python versions that are NOT acceptable for the package.
43: #
1.105 ! tsarna 44: # Possible values: 26 27 31 32 33
1.44 rillig 45: # Default: (depends on the platform)
46: #
47: # PYTHON_FOR_BUILD_ONLY
48: # Whether Python is needed only at build time or at run time.
49: #
50: # Possible values: (defined) (undefined)
51: # Default: (undefined)
52: #
1.103 cheusov 53: # PYTHON_SELF_CONFLICT
54: # If set to "yes", additional CONFLICTS entries are added for
55: # registering a conflict between pyNN-<modulename> packages.
56: #
57: # Possible values: yes no
58: # Default: no
59: #
1.52 rillig 60: # === Defined variables ===
61: #
62: # PYPKGPREFIX
63: # The prefix to use in PKGNAME for extensions which are meant
64: # to be installed for multiple Python versions.
65: #
1.96 wiz 66: # Example: py27
1.52 rillig 67: #
68: # PYVERSSUFFIX
69: # The suffix to executables and in the library path, equal to
70: # sys.version[0:3].
71: #
1.96 wiz 72: # Example: 2.7
1.52 rillig 73: #
1.46 rillig 74: # Keywords: python
75: #
1.2 drochner 76:
77: .if !defined(PYTHON_PYVERSION_MK)
78: PYTHON_PYVERSION_MK= defined
1.1 drochner 79:
1.66 joerg 80: # derive a python version from the package name if possible
81: # optionally handled quoted package names
82: .if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mpy[0-9][0-9]-*) || \
83: defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-py[0-9][0-9]-*)
84: PYTHON_VERSION_REQD?= ${PKGNAME_REQD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
85: .elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mpy[0-9][0-9]-*) || \
86: defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-py[0-9][0-9]-*)
87: PYTHON_VERSION_REQD?= ${PKGNAME_OLD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
88: .endif
89:
1.1 drochner 90: .include "../../mk/bsd.prefs.mk"
91:
1.46 rillig 92: BUILD_DEFS+= PYTHON_VERSION_DEFAULT
93: BUILD_DEFS_EFFECTS+= PYPACKAGE
94:
1.96 wiz 95: PYTHON_VERSION_DEFAULT?= 27
1.92 joerg 96: .if ${PYTHON_VERSIONS_INCLUDE_3X:U:tl} == "yes"
1.105 ! tsarna 97: PYTHON_VERSIONS_ACCEPTED?= 33 32 31 27 26
1.92 joerg 98: .else
1.102 wiz 99: PYTHON_VERSIONS_ACCEPTED?= 27 26
1.92 joerg 100: .endif
1.56 joerg 101: PYTHON_VERSIONS_INCOMPATIBLE?= # empty by default
102:
1.70 snj 103: BUILDLINK_API_DEPENDS.python26?= python26>=2.6
1.84 obache 104: BUILDLINK_API_DEPENDS.python27?= python27>=2.7
1.89 reed 105: BUILDLINK_API_DEPENDS.python31?= python31>=3.1
1.99 obache 106: BUILDLINK_API_DEPENDS.python32?= python32>=3.2
1.105 ! tsarna 107: BUILDLINK_API_DEPENDS.python33?= python33>=3.3
1.4 drochner 108:
1.1 drochner 109: # transform the list into individual variables
110: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28 tv 111: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1 drochner 112: _PYTHON_VERSION_${pv}_OK= yes
1.56 joerg 113: _PYTHON_VERSIONS_ACCEPTED+= ${pv}
1.28 tv 114: .endif
1.1 drochner 115: .endfor
116:
117: #
118: # choose a python version where to add,
119: # try to be intelligent
120: #
1.2 drochner 121: # if a version is explicitely required, take it
122: .if defined(PYTHON_VERSION_REQD)
1.40 joerg 123: # but check if it is acceptable first, error out otherwise
124: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2 drochner 125: _PYTHON_VERSION= ${PYTHON_VERSION_REQD}
1.40 joerg 126: . endif
127: .else
128: # if the default is accepted, it is first choice
129: . if !defined(_PYTHON_VERSION)
130: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1 drochner 131: _PYTHON_VERSION= ${PYTHON_VERSION_DEFAULT}
1.40 joerg 132: . endif
133: . endif
1.1 drochner 134: # prefer an already installed version, in order of "accepted"
1.40 joerg 135: . if !defined(_PYTHON_VERSION)
136: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
137: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1 drochner 138: _PYTHON_VERSION?= ${pv}
1.40 joerg 139: . endif
140: . endfor
141: . endif
1.1 drochner 142: .endif
1.40 joerg 143:
1.87 wiz 144: #
145: # Variable assignment for multi-python packages
146: MULTI+= PYTHON_VERSION_REQD=${_PYTHON_VERSION}
147:
1.40 joerg 148: # No supported version found, annotate to simplify statements below.
1.1 drochner 149: .if !defined(_PYTHON_VERSION)
1.40 joerg 150: _PYTHON_VERSION= none
1.1 drochner 151: .endif
152:
1.103 cheusov 153: # Additional CONFLICTS
154: .if ${PYTHON_SELF_CONFLICT:U:tl} == "yes"
155: .for i in ${PYTHON_VERSIONS_ACCEPTED:N${_PYTHON_VERSION}}
156: CONFLICTS += ${PKGNAME:S/py${_PYTHON_VERSION}/py${i}/:C/-[0-9].*$/-[0-9]*/}
157: .endfor
158: .endif # PYCONFLICTS
159:
160: #
1.100 drochner 161: PLIST_VARS+= py2x py3x
162:
1.105 ! tsarna 163: .if ${_PYTHON_VERSION} == "33"
! 164: PYPKGSRCDIR= ../../lang/python33
! 165: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python33}:${PYPKGSRCDIR}
! 166: PYPACKAGE= python33
! 167: PYVERSSUFFIX= 3.3
! 168: PYPKGPREFIX= py33
! 169: PLIST.py3x= yes
! 170: .elif ${_PYTHON_VERSION} == "32"
1.99 obache 171: PYPKGSRCDIR= ../../lang/python32
172: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python32}:${PYPKGSRCDIR}
173: PYPACKAGE= python32
174: PYVERSSUFFIX= 3.2
175: PYPKGPREFIX= py32
1.100 drochner 176: PLIST.py3x= yes
1.99 obache 177: .elif ${_PYTHON_VERSION} == "31"
1.89 reed 178: PYPKGSRCDIR= ../../lang/python31
1.90 reed 179: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python31}:${PYPKGSRCDIR}
1.89 reed 180: PYPACKAGE= python31
181: PYVERSSUFFIX= 3.1
182: PYPKGPREFIX= py31
1.100 drochner 183: PLIST.py3x= yes
1.89 reed 184: .elif ${_PYTHON_VERSION} == "27"
1.83 obache 185: PYPKGSRCDIR= ../../lang/python27
186: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python27}:${PYPKGSRCDIR}
187: PYPACKAGE= python27
188: PYVERSSUFFIX= 2.7
189: PYPKGPREFIX= py27
1.100 drochner 190: PLIST.py2x= yes
1.83 obache 191: .elif ${_PYTHON_VERSION} == "26"
1.68 wiz 192: PYPKGSRCDIR= ../../lang/python26
193: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python26}:${PYPKGSRCDIR}
194: PYPACKAGE= python26
195: PYVERSSUFFIX= 2.6
196: PYPKGPREFIX= py26
1.100 drochner 197: PLIST.py2x= yes
1.8 drochner 198: .else
1.48 rillig 199: PKG_FAIL_REASON+= "No valid Python version"
1.93 joerg 200: PYPKGPREFIX=
1.1 drochner 201: .endif
1.5 drochner 202:
1.38 rillig 203: PTHREAD_OPTS+= require
1.33 jlam 204: .include "../../mk/pthread.buildlink3.mk"
1.38 rillig 205:
1.33 jlam 206: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36 seb 207: BUILDLINK_DEPMETHOD.python?= build
1.11 jlam 208: .endif
1.37 kristerw 209: .if defined(PYPKGSRCDIR)
1.33 jlam 210: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37 kristerw 211: .endif
1.11 jlam 212:
213: PYTHONBIN= ${LOCALBASE}/bin/python${PYVERSSUFFIX}
1.78 joerg 214: PYTHONCONFIG= ${LOCALBASE}/bin/python${PYVERSSUFFIX}-config
1.73 joerg 215: PY_COMPILE_ALL= \
216: ${PYTHONBIN} ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
217: PY_COMPILE_O_ALL= \
218: ${PYTHONBIN} -O ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
1.11 jlam 219:
1.61 snj 220: .if exists(${PYTHONBIN})
1.11 jlam 221: PYINC!= ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85 obache 222: print (distutils.sysconfig.get_python_inc(0, \"\"))" || ${ECHO} ""
1.11 jlam 223: PYLIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85 obache 224: print (distutils.sysconfig.get_python_lib(0, 1, \"\"))" || ${ECHO} ""
1.11 jlam 225: PYSITELIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85 obache 226: print (distutils.sysconfig.get_python_lib(0, 0, \"\"))" || ${ECHO} ""
1.72 joerg 227:
228: PRINT_PLIST_AWK+= /^${PYINC:S|/|\\/|g}/ \
1.82 obache 229: { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}") }
1.72 joerg 230: PRINT_PLIST_AWK+= /^${PYSITELIB:S|/|\\/|g}/ \
1.82 obache 231: { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}") }
1.72 joerg 232: PRINT_PLIST_AWK+= /^${PYLIB:S|/|\\/|g}/ \
1.82 obache 233: { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}") }
1.6 drochner 234: .endif
1.2 drochner 235:
1.47 rillig 236: ALL_ENV+= PYTHON=${PYTHONBIN}
1.80 drochner 237: .if defined(USE_CMAKE)
238: # used by FindPythonInterp.cmake and FindPythonLibs.cmake
239: CMAKE_ARGS+= -DPYVERSSUFFIX:STRING=${PYVERSSUFFIX}
240: .endif
1.47 rillig 241:
1.2 drochner 242: .endif # PYTHON_PYVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>