2013-04-04 08:36:43 -04:00
|
|
|
# $OpenBSD: python.port.mk,v 1.61 2013/04/04 12:36:43 sthen Exp $
|
2003-07-31 03:01:21 -04:00
|
|
|
#
|
|
|
|
# python.port.mk - Xavier Santolaria <xavier@santolaria.net>
|
|
|
|
# This file is in the public domain.
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2012-12-21 13:19:38 -05:00
|
|
|
CATEGORIES += lang/python
|
2007-12-10 16:06:58 -05:00
|
|
|
|
2011-12-14 15:31:28 -05:00
|
|
|
# define the default versions
|
2012-10-14 13:26:12 -04:00
|
|
|
MODPY_DEFAULT_VERSION_2 = 2.7
|
|
|
|
MODPY_DEFAULT_VERSION_3 = 3.2
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2011-12-14 15:31:28 -05:00
|
|
|
.if !defined(MODPY_VERSION)
|
2011-10-17 09:55:24 -04:00
|
|
|
|
2012-12-21 13:19:38 -05:00
|
|
|
FLAVOR ?=
|
2010-09-16 18:58:19 -04:00
|
|
|
|
2013-02-09 09:49:50 -05:00
|
|
|
. if ${FLAVOR:Mpython3}
|
2011-12-14 15:31:28 -05:00
|
|
|
# define default version 3
|
2012-12-21 13:19:38 -05:00
|
|
|
MODPY_VERSION ?= ${MODPY_DEFAULT_VERSION_3}
|
2011-10-17 09:55:24 -04:00
|
|
|
. else
|
2011-12-14 15:31:28 -05:00
|
|
|
# without flavor, assume we use the default version 2
|
2012-12-21 13:19:38 -05:00
|
|
|
MODPY_VERSION ?= ${MODPY_DEFAULT_VERSION_2}
|
2011-10-17 09:55:24 -04:00
|
|
|
. endif
|
2011-12-14 15:31:28 -05:00
|
|
|
|
|
|
|
# verify if MODPY_VERSION forced is correct
|
2011-10-17 09:55:24 -04:00
|
|
|
.else
|
2011-12-20 08:08:06 -05:00
|
|
|
. if ${MODPY_VERSION} != "2.5" && \
|
2011-12-14 15:31:28 -05:00
|
|
|
${MODPY_VERSION} != "2.7" && \
|
|
|
|
${MODPY_VERSION} != "3.2"
|
2011-10-17 09:55:24 -04:00
|
|
|
ERRORS += "Fatal: unknown or unsupported MODPY_VERSION: ${MODPY_VERSION}"
|
2011-12-14 15:31:28 -05:00
|
|
|
. endif
|
|
|
|
.endif
|
|
|
|
|
2012-12-21 13:19:38 -05:00
|
|
|
MODPY_MAJOR_VERSION = ${MODPY_VERSION:R}
|
2011-12-14 15:31:28 -05:00
|
|
|
|
2012-12-21 13:19:38 -05:00
|
|
|
.if ${MODPY_MAJOR_VERSION} == 2
|
2011-12-14 15:31:28 -05:00
|
|
|
MODPY_LIB_SUFFIX =
|
|
|
|
MODPY_FLAVOR =
|
|
|
|
MODPY_BIN_SUFFIX =
|
|
|
|
MODPY_PY_PREFIX = py-
|
2012-06-27 14:56:26 -04:00
|
|
|
MODPY_PYCACHE =
|
|
|
|
MODPY_PYC_MAGIC_TAG =
|
|
|
|
MODPY_COMMENT = "@comment "
|
2011-12-14 15:31:28 -05:00
|
|
|
|
2012-12-21 13:19:38 -05:00
|
|
|
.elif ${MODPY_MAJOR_VERSION} == 3
|
2011-12-14 15:31:28 -05:00
|
|
|
MODPY_LIB_SUFFIX = m
|
|
|
|
# replace py- prefix by py3-
|
|
|
|
FULLPKGNAME = ${PKGNAME:S/^py-/py3-/}
|
|
|
|
MODPY_FLAVOR = ,python3
|
|
|
|
# use MODPY_SUFFIX for binaries to avoid conflict
|
|
|
|
MODPY_BIN_SUFFIX = -3
|
|
|
|
MODPY_PY_PREFIX = py3-
|
2012-06-27 14:56:26 -04:00
|
|
|
MODPY_PYCACHE = "__pycache__/"
|
|
|
|
MODPY_MAJORMINOR = ${MODPY_VERSION:C/\.//g}
|
|
|
|
MODPY_PYC_MAGIC_TAG = "cpython-${MODPY_MAJORMINOR}."
|
|
|
|
MODPY_COMMENT =
|
|
|
|
|
2011-12-14 15:31:28 -05:00
|
|
|
.endif
|
|
|
|
|
|
|
|
MODPY_WANTLIB = python${MODPY_VERSION}${MODPY_LIB_SUFFIX}
|
|
|
|
|
|
|
|
.if ${MODPY_VERSION} < 2.6
|
|
|
|
MODPY_JSON = devel/py-simplejson
|
|
|
|
.else
|
|
|
|
MODPY_JSON =
|
2011-09-21 10:37:28 -04:00
|
|
|
.endif
|
2011-10-17 09:55:24 -04:00
|
|
|
|
2012-12-21 13:19:38 -05:00
|
|
|
MODPY_RUN_DEPENDS = lang/python/${MODPY_VERSION}
|
|
|
|
MODPY_LIB_DEPENDS = ${MODPY_RUN_DEPENDS}
|
|
|
|
_MODPY_BUILD_DEPENDS = ${MODPY_RUN_DEPENDS}
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2012-12-21 13:19:38 -05:00
|
|
|
MODPY_BUILDDEP ?= Yes
|
|
|
|
MODPY_RUNDEP ?= Yes
|
2007-10-10 17:42:14 -04:00
|
|
|
|
2010-07-22 06:39:19 -04:00
|
|
|
.if ${NO_BUILD:L} == "no" && ${MODPY_BUILDDEP:L} == "yes"
|
2012-12-21 13:19:38 -05:00
|
|
|
BUILD_DEPENDS += ${_MODPY_BUILD_DEPENDS}
|
2004-02-06 03:37:22 -05:00
|
|
|
.endif
|
2007-10-22 06:14:02 -04:00
|
|
|
.if ${MODPY_RUNDEP:L} == "yes"
|
2012-12-21 13:19:38 -05:00
|
|
|
RUN_DEPENDS += ${MODPY_RUN_DEPENDS}
|
2007-10-10 17:42:14 -04:00
|
|
|
.endif
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2012-03-31 04:53:57 -04:00
|
|
|
.if ${MODPY_BUILDDEP:L} == "yes" || ${MODPY_RUNDEP:L} == "yes"
|
2012-12-21 13:19:38 -05:00
|
|
|
SHARED_ONLY = Yes
|
2012-03-31 04:53:57 -04:00
|
|
|
.endif
|
|
|
|
|
2012-10-12 15:57:46 -04:00
|
|
|
_MODPY_PRE_BUILD_STEPS = @:
|
2012-08-28 15:10:45 -04:00
|
|
|
.if defined(MODPY_SETUPTOOLS) && ${MODPY_SETUPTOOLS:L} == "yes"
|
2006-09-26 11:27:02 -04:00
|
|
|
# The setuptools module provides a package locator (site.py) that is
|
|
|
|
# required at runtime for the pkg_resources stuff to work
|
2012-12-21 13:19:38 -05:00
|
|
|
. if ${MODPY_MAJOR_VERSION} == 2
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_SETUPUTILS_DEPEND ?= devel/py-setuptools
|
2012-12-21 13:19:38 -05:00
|
|
|
. elif ${MODPY_MAJOR_VERSION} == 3
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_SETUPUTILS_DEPEND ?= devel/py-distribute${MODPY_FLAVOR}
|
2011-12-14 15:31:28 -05:00
|
|
|
. endif
|
|
|
|
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_RUN_DEPENDS += ${MODPY_SETUPUTILS_DEPEND}
|
|
|
|
BUILD_DEPENDS += ${MODPY_SETUPUTILS_DEPEND}
|
2011-10-03 09:54:12 -04:00
|
|
|
MODPY_SETUPUTILS = Yes
|
2007-05-22 11:34:26 -04:00
|
|
|
# The setuptools uses test target
|
2013-03-11 07:20:26 -04:00
|
|
|
TEST_TARGET ?= test
|
2010-09-16 18:58:19 -04:00
|
|
|
_MODPY_USERBASE =
|
|
|
|
.else
|
|
|
|
# Try to detect the case where a port will build regardless of setuptools
|
|
|
|
# but the final plist will be different if it's present.
|
2011-10-03 09:54:12 -04:00
|
|
|
_MODPY_SETUPUTILS_FAKE_DIR = \
|
2010-09-16 18:58:19 -04:00
|
|
|
${WRKDIR}/lib/python${MODPY_VERSION}/site-packages/setuptools
|
2012-10-12 15:57:46 -04:00
|
|
|
_MODPY_PRE_BUILD_STEPS += \
|
2011-10-03 09:54:12 -04:00
|
|
|
;mkdir -p ${_MODPY_SETUPUTILS_FAKE_DIR} \
|
|
|
|
;exec >${_MODPY_SETUPUTILS_FAKE_DIR}/__init__.py \
|
2010-09-16 18:58:19 -04:00
|
|
|
;echo 'def setup(*args, **kwargs):' \
|
2011-12-14 15:31:28 -05:00
|
|
|
;echo ' msg = "OpenBSD ports: MODPY_SETUPTOOLS = Yes is required"' \
|
2010-09-16 18:58:19 -04:00
|
|
|
;echo ' raise Exception(msg)' \
|
|
|
|
;echo 'Extension = Feature = find_packages = setup'
|
2011-10-03 09:54:12 -04:00
|
|
|
MODPY_SETUPUTILS = No
|
2010-09-16 18:58:19 -04:00
|
|
|
_MODPY_USERBASE = ${WRKDIR}
|
2006-09-26 11:27:02 -04:00
|
|
|
.endif
|
|
|
|
|
2012-08-28 15:10:45 -04:00
|
|
|
.if !defined(NO_SHARED_LIBS) || ${NO_SHARED_LIBS:L} != "yes"
|
|
|
|
MODPY_TKINTER_DEPENDS = ${MODPY_RUN_DEPENDS},-tkinter
|
2004-08-06 03:33:19 -04:00
|
|
|
.endif
|
|
|
|
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_BIN = ${LOCALBASE}/bin/python${MODPY_VERSION}
|
|
|
|
MODPY_INCDIR = ${LOCALBASE}/include/python${MODPY_VERSION}${MODPY_LIB_SUFFIX}
|
|
|
|
MODPY_LIBDIR = ${LOCALBASE}/lib/python${MODPY_VERSION}
|
|
|
|
MODPY_SITEPKG = ${MODPY_LIBDIR}/site-packages
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2010-02-27 12:52:18 -05:00
|
|
|
.if defined(MODPY_BADEGGS)
|
|
|
|
. for egg in ${MODPY_BADEGGS}
|
2012-10-12 15:57:46 -04:00
|
|
|
_MODPY_PRE_BUILD_STEPS += ;mkdir -p ${WRKBUILD}/${egg}.egg-info
|
2010-02-27 12:52:18 -05:00
|
|
|
. endfor
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
2003-07-28 13:48:13 -04:00
|
|
|
# usually setup.py but Setup.py can be found too
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_SETUP ?= setup.py
|
2003-07-28 13:48:13 -04:00
|
|
|
|
|
|
|
# build or build_ext are commonly used
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_DISTUTILS_BUILD ?= build --build-base=${WRKSRC}
|
2006-09-26 11:27:02 -04:00
|
|
|
|
2011-10-03 09:54:12 -04:00
|
|
|
.if ${MODPY_SETUPUTILS:L} == "yes"
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_DISTUTILS_INSTALL ?= install --prefix=${LOCALBASE} \
|
2006-09-26 11:27:02 -04:00
|
|
|
--root=${DESTDIR} \
|
|
|
|
--single-version-externally-managed
|
|
|
|
.else
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_DISTUTILS_INSTALL ?= install --prefix=${LOCALBASE} \
|
2009-01-01 16:03:27 -05:00
|
|
|
--root=${DESTDIR}
|
2006-09-26 11:27:02 -04:00
|
|
|
.endif
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2012-08-28 15:10:45 -04:00
|
|
|
MAKE_ENV += CC=${CC} PYTHONUSERBASE=${_MODPY_USERBASE}
|
2012-12-21 13:19:38 -05:00
|
|
|
CONFIGURE_ENV += PYTHON="${MODPY_BIN}" \
|
2012-04-03 05:21:42 -04:00
|
|
|
ac_cv_prog_PYTHON="${MODPY_BIN}"
|
2004-06-21 19:25:07 -04:00
|
|
|
|
2012-08-28 15:10:45 -04:00
|
|
|
_MODPY_CMD = @cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
|
2003-07-29 15:35:32 -04:00
|
|
|
${MODPY_BIN} ./${MODPY_SETUP}
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2013-04-04 08:36:43 -04:00
|
|
|
SUBST_VARS := MODPY_PYCACHE MODPY_COMMENT MODPY_PYC_MAGIC_TAG MODPY_BIN MODPY_EGG_VERSION MODPY_VERSION MODPY_BIN_SUFFIX ^MODPY_PY_PREFIX ${SUBST_VARS}
|
2003-07-28 13:48:13 -04:00
|
|
|
|
2010-10-26 10:29:26 -04:00
|
|
|
# set MODPY_BIN for executable scripts
|
2013-04-01 12:49:53 -04:00
|
|
|
MODPY_BIN_ADJ = perl -pi \
|
2010-10-26 10:29:26 -04:00
|
|
|
-e '$$. == 1 && s|^.*env python.*$$|\#!${MODPY_BIN}|;' \
|
|
|
|
-e '$$. == 1 && s|^.*bin/python.*$$|\#!${MODPY_BIN}|;' \
|
|
|
|
-e 'close ARGV if eof;'
|
|
|
|
|
2012-08-28 15:10:45 -04:00
|
|
|
MODPY_ADJ_FILES ?=
|
2010-10-26 10:29:26 -04:00
|
|
|
.if !empty(MODPY_ADJ_FILES)
|
|
|
|
MODPYTHON_pre-configure += for f in ${MODPY_ADJ_FILES}; do \
|
2013-04-01 12:49:53 -04:00
|
|
|
${MODPY_BIN_ADJ} ${WRKSRC}/$${f}; done
|
2010-10-26 10:29:26 -04:00
|
|
|
.endif
|
|
|
|
|
2003-07-28 13:48:13 -04:00
|
|
|
# dirty way to do it with no modifications in bsd.port.mk
|
2006-01-27 12:50:54 -05:00
|
|
|
.if empty(CONFIGURE_STYLE)
|
|
|
|
. if !target(do-build)
|
2003-07-28 13:48:13 -04:00
|
|
|
do-build:
|
2012-10-12 15:57:46 -04:00
|
|
|
${_MODPY_PRE_BUILD_STEPS}
|
2003-08-12 16:23:20 -04:00
|
|
|
${_MODPY_CMD} ${MODPY_DISTUTILS_BUILD} ${MODPY_DISTUTILS_BUILDARGS}
|
2006-01-27 12:50:54 -05:00
|
|
|
. endif
|
2003-07-28 13:48:13 -04:00
|
|
|
|
|
|
|
# extra documentation or scripts should be installed via post-install
|
2006-01-27 12:50:54 -05:00
|
|
|
. if !target(do-install)
|
2003-07-28 13:48:13 -04:00
|
|
|
do-install:
|
2003-10-10 12:38:18 -04:00
|
|
|
${_MODPY_CMD} ${MODPY_DISTUTILS_BUILD} ${MODPY_DISTUTILS_BUILDARGS} \
|
|
|
|
${MODPY_DISTUTILS_INSTALL} ${MODPY_DISTUTILS_INSTALLARGS}
|
2006-01-27 12:50:54 -05:00
|
|
|
. endif
|
2006-09-26 11:27:02 -04:00
|
|
|
|
|
|
|
# setuptools supports regress testing from setup.py using a standard target
|
2013-03-11 07:20:26 -04:00
|
|
|
. if !target(do-test) && ${MODPY_SETUPUTILS:L} == "yes"
|
|
|
|
do-test:
|
|
|
|
${_MODPY_CMD} ${TEST_TARGET}
|
2006-09-26 11:27:02 -04:00
|
|
|
. endif
|
|
|
|
|
2003-07-28 13:48:13 -04:00
|
|
|
.endif
|