Annotation of pkgsrc/lang/python/pyversion.mk, revision 1.117
1.117 ! rodent 1: # $NetBSD: pyversion.mk,v 1.116 2015/01/27 06:33:46 dbj 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.117 ! rodent 11: # Possible values: 27 33 34
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.117 ! rodent 30: # Possible values: 34 33 27
! 31: # Default: 34 33 27
1.92 joerg 32: #
1.44 rillig 33: # PYTHON_VERSIONS_INCOMPATIBLE
34: # The Python versions that are NOT acceptable for the package.
35: #
1.117 ! rodent 36: # Possible values: 27 33 34
1.113 wiz 37: # Default: (empty)
1.44 rillig 38: #
39: # PYTHON_FOR_BUILD_ONLY
40: # Whether Python is needed only at build time or at run time.
41: #
1.108 riastrad 42: # Possible values: yes no tool
43: # Default: no
1.44 rillig 44: #
1.103 cheusov 45: # PYTHON_SELF_CONFLICT
46: # If set to "yes", additional CONFLICTS entries are added for
47: # registering a conflict between pyNN-<modulename> packages.
48: #
49: # Possible values: yes no
50: # Default: no
51: #
1.52 rillig 52: # === Defined variables ===
53: #
54: # PYPKGPREFIX
55: # The prefix to use in PKGNAME for extensions which are meant
56: # to be installed for multiple Python versions.
57: #
1.96 wiz 58: # Example: py27
1.52 rillig 59: #
60: # PYVERSSUFFIX
61: # The suffix to executables and in the library path, equal to
62: # sys.version[0:3].
63: #
1.96 wiz 64: # Example: 2.7
1.52 rillig 65: #
1.46 rillig 66: # Keywords: python
67: #
1.2 drochner 68:
69: .if !defined(PYTHON_PYVERSION_MK)
70: PYTHON_PYVERSION_MK= defined
1.1 drochner 71:
1.66 joerg 72: # derive a python version from the package name if possible
73: # optionally handled quoted package names
74: .if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mpy[0-9][0-9]-*) || \
75: defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-py[0-9][0-9]-*)
76: PYTHON_VERSION_REQD?= ${PKGNAME_REQD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
77: .elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mpy[0-9][0-9]-*) || \
78: defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-py[0-9][0-9]-*)
79: PYTHON_VERSION_REQD?= ${PKGNAME_OLD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
80: .endif
81:
1.1 drochner 82: .include "../../mk/bsd.prefs.mk"
83:
1.46 rillig 84: BUILD_DEFS+= PYTHON_VERSION_DEFAULT
85: BUILD_DEFS_EFFECTS+= PYPACKAGE
86:
1.96 wiz 87: PYTHON_VERSION_DEFAULT?= 27
1.117 ! rodent 88: PYTHON_VERSIONS_ACCEPTED?= 34 33 27
1.56 joerg 89: PYTHON_VERSIONS_INCOMPATIBLE?= # empty by default
90:
1.1 drochner 91: # transform the list into individual variables
92: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28 tv 93: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1 drochner 94: _PYTHON_VERSION_${pv}_OK= yes
1.56 joerg 95: _PYTHON_VERSIONS_ACCEPTED+= ${pv}
1.28 tv 96: .endif
1.1 drochner 97: .endfor
98:
99: #
100: # choose a python version where to add,
101: # try to be intelligent
102: #
1.2 drochner 103: # if a version is explicitely required, take it
104: .if defined(PYTHON_VERSION_REQD)
1.40 joerg 105: # but check if it is acceptable first, error out otherwise
106: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2 drochner 107: _PYTHON_VERSION= ${PYTHON_VERSION_REQD}
1.40 joerg 108: . endif
109: .else
110: # if the default is accepted, it is first choice
111: . if !defined(_PYTHON_VERSION)
112: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1 drochner 113: _PYTHON_VERSION= ${PYTHON_VERSION_DEFAULT}
1.40 joerg 114: . endif
115: . endif
1.1 drochner 116: # prefer an already installed version, in order of "accepted"
1.40 joerg 117: . if !defined(_PYTHON_VERSION)
118: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
119: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1 drochner 120: _PYTHON_VERSION?= ${pv}
1.40 joerg 121: . endif
122: . endfor
123: . endif
1.1 drochner 124: .endif
1.40 joerg 125:
1.87 wiz 126: #
127: # Variable assignment for multi-python packages
128: MULTI+= PYTHON_VERSION_REQD=${_PYTHON_VERSION}
129:
1.40 joerg 130: # No supported version found, annotate to simplify statements below.
1.1 drochner 131: .if !defined(_PYTHON_VERSION)
1.40 joerg 132: _PYTHON_VERSION= none
1.115 obache 133: PKG_FAIL_REASON+= "No valid Python version"
1.1 drochner 134: .endif
135:
1.103 cheusov 136: # Additional CONFLICTS
137: .if ${PYTHON_SELF_CONFLICT:U:tl} == "yes"
138: .for i in ${PYTHON_VERSIONS_ACCEPTED:N${_PYTHON_VERSION}}
139: CONFLICTS += ${PKGNAME:S/py${_PYTHON_VERSION}/py${i}/:C/-[0-9].*$/-[0-9]*/}
140: .endfor
141: .endif # PYCONFLICTS
142:
143: #
1.100 drochner 144: PLIST_VARS+= py2x py3x
145:
1.115 obache 146: .if empty(_PYTHON_VERSION:Mnone)
1.114 obache 147: PYPACKAGE= python${_PYTHON_VERSION}
148: PYVERSSUFFIX= ${_PYTHON_VERSION:C/^([0-9])/\1./1}
149: BUILDLINK_API_DEPENDS.${PYPACKAGE}?= ${PYPACKAGE}>=${PYVERSSUFFIX}
150: PYPKGSRCDIR= ../../lang/${PYPACKAGE}
151: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.${PYPACKAGE}}:${PYPKGSRCDIR}
152: PYPKGPREFIX= py${_PYTHON_VERSION}
1.115 obache 153: .endif
1.114 obache 154: .if !empty(_PYTHON_VERSION:M3*)
1.105 tsarna 155: PLIST.py3x= yes
1.114 obache 156: .endif
157: .if !empty(_PYTHON_VERSION:M2*)
1.100 drochner 158: PLIST.py2x= yes
1.1 drochner 159: .endif
1.5 drochner 160:
1.38 rillig 161: PTHREAD_OPTS+= require
1.33 jlam 162: .include "../../mk/pthread.buildlink3.mk"
1.38 rillig 163:
1.109 riastrad 164: PYTHON_FOR_BUILD_ONLY?= no
1.37 kristerw 165: .if defined(PYPKGSRCDIR)
1.108 riastrad 166: . if !empty(PYTHON_FOR_BUILD_ONLY:M[tT][oO][oO][lL])
167: TOOL_DEPENDS+= ${PYDEPENDENCY}
1.107 riastrad 168: . else
1.108 riastrad 169: . if !empty(PYTHON_FOR_BUILD_ONLY:M[yY][eE][sS])
170: BUILDLINK_DEPMETHOD.python?= build
171: . endif
1.107 riastrad 172: . include "${PYPKGSRCDIR}/buildlink3.mk"
173: . endif
1.37 kristerw 174: .endif
1.11 jlam 175:
176: PYTHONBIN= ${LOCALBASE}/bin/python${PYVERSSUFFIX}
1.78 joerg 177: PYTHONCONFIG= ${LOCALBASE}/bin/python${PYVERSSUFFIX}-config
1.73 joerg 178: PY_COMPILE_ALL= \
179: ${PYTHONBIN} ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
180: PY_COMPILE_O_ALL= \
181: ${PYTHONBIN} -O ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
1.11 jlam 182:
1.61 snj 183: .if exists(${PYTHONBIN})
1.11 jlam 184: PYINC!= ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85 obache 185: print (distutils.sysconfig.get_python_inc(0, \"\"))" || ${ECHO} ""
1.11 jlam 186: PYLIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85 obache 187: print (distutils.sysconfig.get_python_lib(0, 1, \"\"))" || ${ECHO} ""
1.11 jlam 188: PYSITELIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85 obache 189: print (distutils.sysconfig.get_python_lib(0, 0, \"\"))" || ${ECHO} ""
1.72 joerg 190:
191: PRINT_PLIST_AWK+= /^${PYINC:S|/|\\/|g}/ \
1.82 obache 192: { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}") }
1.72 joerg 193: PRINT_PLIST_AWK+= /^${PYSITELIB:S|/|\\/|g}/ \
1.82 obache 194: { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}") }
1.72 joerg 195: PRINT_PLIST_AWK+= /^${PYLIB:S|/|\\/|g}/ \
1.82 obache 196: { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}") }
1.6 drochner 197: .endif
1.2 drochner 198:
1.47 rillig 199: ALL_ENV+= PYTHON=${PYTHONBIN}
1.80 drochner 200: .if defined(USE_CMAKE)
201: # used by FindPythonInterp.cmake and FindPythonLibs.cmake
202: CMAKE_ARGS+= -DPYVERSSUFFIX:STRING=${PYVERSSUFFIX}
1.116 dbj 203: .if ${OPSYS} == "Darwin"
204: # set this explicitly, as by default it will prefer the built in framework
205: CMAKE_ARGS+= -DPYTHON_INCLUDE_DIR:PATH=${BUILDLINK_DIR}/${PYINC}
206: CMAKE_ARGS+= -DPYTHON_EXECUTABLE:FILEPATH=${PYTHONBIN}
207: .endif
1.80 drochner 208: .endif
1.47 rillig 209:
1.2 drochner 210: .endif # PYTHON_PYVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>