Annotation of pkgsrc/lang/python/pyversion.mk, revision 1.39
1.39 ! reed 1: # $NetBSD: pyversion.mk,v 1.38 2005/11/04 18:24:37 rillig Exp $
1.2 drochner 2:
3: .if !defined(PYTHON_PYVERSION_MK)
4: PYTHON_PYVERSION_MK= defined
1.1 drochner 5:
6: .include "../../mk/bsd.prefs.mk"
7:
1.26 danw 8: PYTHON_VERSION_DEFAULT?= 23
1.17 schmonz 9: .if ${OPSYS} == "Darwin"
1.32 recht 10: PYTHON_VERSIONS_INCOMPATIBLE+= 22 21 20 15
1.28 tv 11: .endif
1.31 recht 12: PYTHON_VERSIONS_ACCEPTED?= 24 23 22 21 20
1.28 tv 13: PYTHON_VERSIONS_INCOMPATIBLE?= # empty by default
1.1 drochner 14:
1.39 ! reed 15: BUILDLINK_API_DEPENDS.python15?= python15>=1.5
! 16: BUILDLINK_API_DEPENDS.python20?= python20>=2.0
! 17: BUILDLINK_API_DEPENDS.python21?= python21>=2.1
! 18: BUILDLINK_API_DEPENDS.python22?= python22>=2.2
! 19: BUILDLINK_API_DEPENDS.python23?= python23>=2.3
! 20: BUILDLINK_API_DEPENDS.python24?= python24>=2.4
1.4 drochner 21:
1.1 drochner 22: # transform the list into individual variables
23: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28 tv 24: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1 drochner 25: _PYTHON_VERSION_${pv}_OK= yes
1.28 tv 26: .endif
1.1 drochner 27: .endfor
28:
29: # check what is installed
1.30 recht 30: .if exists(${LOCALBASE}/bin/python2.4)
31: _PYTHON_VERSION_24_INSTALLED= yes
32: .endif
1.21 drochner 33: .if exists(${LOCALBASE}/bin/python2.3)
34: _PYTHON_VERSION_23_INSTALLED= yes
35: .endif
1.2 drochner 36: .if exists(${LOCALBASE}/bin/python2.2)
37: _PYTHON_VERSION_22_INSTALLED= yes
38: .endif
1.1 drochner 39: .if exists(${LOCALBASE}/bin/python2.1)
40: _PYTHON_VERSION_21_INSTALLED= yes
41: .endif
42: .if exists(${LOCALBASE}/bin/python2.0)
43: _PYTHON_VERSION_20_INSTALLED= yes
44: .endif
1.7 drochner 45: .if exists(${LOCALBASE}/bin/python1.5)
46: _PYTHON_VERSION_15_INSTALLED= yes
47: .endif
1.1 drochner 48:
49: #
50: # choose a python version where to add,
51: # try to be intelligent
52: #
1.2 drochner 53: # if a version is explicitely required, take it
54: .if defined(PYTHON_VERSION_REQD)
55: _PYTHON_VERSION= ${PYTHON_VERSION_REQD}
56: .endif
1.1 drochner 57: # if the default is already installed, it is first choice
1.2 drochner 58: .if !defined(_PYTHON_VERSION)
1.1 drochner 59: .if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
60: .if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_INSTALLED)
61: _PYTHON_VERSION= ${PYTHON_VERSION_DEFAULT}
62: .endif
63: .endif
1.2 drochner 64: .endif
1.1 drochner 65: # prefer an already installed version, in order of "accepted"
66: .if !defined(_PYTHON_VERSION)
67: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28 tv 68: .if defined(_PYTHON_VERSION_${pv}_OK)
1.1 drochner 69: .if defined(_PYTHON_VERSION_${pv}_INSTALLED)
70: _PYTHON_VERSION?= ${pv}
71: .else
72: # keep information as last resort - see below
73: _PYTHON_VERSION_FIRSTACCEPTED?= ${pv}
74: .endif
1.28 tv 75: .endif
1.1 drochner 76: .endfor
77: .endif
78: # if the default is OK for the addon pkg, take this
79: .if !defined(_PYTHON_VERSION)
80: .if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
81: _PYTHON_VERSION= ${PYTHON_VERSION_DEFAULT}
82: .endif
83: .endif
84: # take the first one accepted by the package
85: .if !defined(_PYTHON_VERSION)
86: _PYTHON_VERSION= ${_PYTHON_VERSION_FIRSTACCEPTED}
87: .endif
88:
89: #
1.5 drochner 90: # set variables for the version we decided to use:
91: # PYVERSSUFFIX: suffix to executables and in library path,
92: # equal to sys.version[0:3]
93: # PYPKGPREFIX: prefix to use in PKGNAME for extensions which can install
94: # to multiple Python versions
1.1 drochner 95: #
1.30 recht 96: .if ${_PYTHON_VERSION} == "24"
97: PYPKGSRCDIR= ../../lang/python24
1.39 ! reed 98: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python24}:${PYPKGSRCDIR}
1.30 recht 99: PYPACKAGE= python24
100: PYVERSSUFFIX= 2.4
101: PYPKGPREFIX= py24
102: .elif ${_PYTHON_VERSION} == "23"
1.21 drochner 103: PYPKGSRCDIR= ../../lang/python23
1.39 ! reed 104: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python23}:${PYPKGSRCDIR}
1.21 drochner 105: PYPACKAGE= python23
106: PYVERSSUFFIX= 2.3
107: PYPKGPREFIX= py23
108: .elif ${_PYTHON_VERSION} == "22"
1.10 jlam 109: PYPKGSRCDIR= ../../lang/python22
1.39 ! reed 110: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python22}:${PYPKGSRCDIR}
1.14 jlam 111: PYPACKAGE= python22
1.5 drochner 112: PYVERSSUFFIX= 2.2
1.2 drochner 113: PYPKGPREFIX= py22
114: .elif ${_PYTHON_VERSION} == "21"
1.10 jlam 115: PYPKGSRCDIR= ../../lang/python21
1.14 jlam 116: PYPACKAGE= python21
1.39 ! reed 117: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python21}:${PYPKGSRCDIR}
1.5 drochner 118: PYVERSSUFFIX= 2.1
1.1 drochner 119: PYPKGPREFIX= py21
120: .elif ${_PYTHON_VERSION} == "20"
1.10 jlam 121: PYPKGSRCDIR= ../../lang/python20
1.14 jlam 122: PYPACKAGE= python20
1.39 ! reed 123: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python20}:${PYPKGSRCDIR}
1.5 drochner 124: PYVERSSUFFIX= 2.0
1.1 drochner 125: PYPKGPREFIX= py20
1.7 drochner 126: .elif ${_PYTHON_VERSION} == "15"
1.10 jlam 127: PYPKGSRCDIR= ../../lang/python15
1.14 jlam 128: PYPACKAGE= python15
1.39 ! reed 129: PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python15}:${PYPKGSRCDIR}
1.7 drochner 130: PYVERSSUFFIX= 1.5
131: PYPKGPREFIX= py15
132: .if !defined(PYTHON_DISTUTILS_BOOTSTRAP)
133: BUILD_DEPENDS+= py15-distutils-*:../../devel/py-distutils
134: .endif
1.8 drochner 135: .else
136: # force an error
1.37 kristerw 137: PKG_SKIP_REASON+= "No valid Python version"
1.1 drochner 138: .endif
1.5 drochner 139:
1.38 rillig 140: PTHREAD_OPTS+= require
1.33 jlam 141: .include "../../mk/pthread.buildlink3.mk"
1.38 rillig 142:
1.33 jlam 143: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36 seb 144: BUILDLINK_DEPMETHOD.python?= build
1.11 jlam 145: .endif
1.37 kristerw 146: .if defined(PYPKGSRCDIR)
1.33 jlam 147: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37 kristerw 148: .endif
1.11 jlam 149:
150: PYTHONBIN= ${LOCALBASE}/bin/python${PYVERSSUFFIX}
151:
152: .if exists(${PYTHONBIN})
153: PYINC!= ${PYTHONBIN} -c "import distutils.sysconfig; \
154: print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
155: PYLIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \
156: print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
157: PYSITELIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \
158: print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""
1.29 recht 159:
160: PRINT_PLIST_AWK+= /^@dirrm ${PYINC:S|/|\\/|g}$$/ { next; }
161: PRINT_PLIST_AWK+= /^@dirrm ${PYSITELIB:S|/|\\/|g}$$/ { next; }
162: PRINT_PLIST_AWK+= /^@dirrm ${PYLIB:S|/|\\/|g}$$/ { next; }
163:
164: PRINT_PLIST_AWK+= /^(@dirrm )?${PYINC:S|/|\\/|g}/ \
165: { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}"); \
166: print; next; }
167: PRINT_PLIST_AWK+= /^(@dirrm )?${PYSITELIB:S|/|\\/|g}/ \
168: { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}"); \
169: print; next; }
170: PRINT_PLIST_AWK+= /^(@dirrm )?${PYLIB:S|/|\\/|g}/ \
171: { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}"); \
172: print; next; }
1.6 drochner 173: .endif
1.2 drochner 174:
175: .endif # PYTHON_PYVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>