OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: New python.port.mk diff

From: Federico G. Schwindt (fgschlodoss.net)
Date: Tue Sep 14 2010 - 19:17:08 CDT


On Wed, Sep 15, 2010 at 12:08:56AM +0100, Federico G. Schwindt wrote:
>
> Widening the audience with updated diff:
>
> The first bit (posted earlier) is meant to replace ::devel/py-simplejson on
> ports that use json (python >= 2.6) and fallback to simplejson otherwise, like
> py-zine, py-couchdb and the upcoming py-buildbot update.
> The second bit, as the comment says, try to detect the situation when a
> port will build regardless of setuptools but the plist will be different if
> setuptools is present as seen in ports.
> Comments? Suggestions? OKs?

  New version that should work better. I've renamed a few variables
for clarity as well and prefixed the message with 'OpenBSD ports:'
as suggested by sthen.

  f.-

Index: python.port.mk
===================================================================
RCS file: /cvs/ports/lang/python/python.port.mk,v
retrieving revision 1.36
diff -u -r1.36 python.port.mk
--- python.port.mk 30 Aug 2010 16:35:02 -0000 1.36
+++ python.port.mk 15 Sep 2010 00:11:19 -0000
-17,6 +17,12
 .endif
 MODPYSPEC = python-${MODPY_VSPEC}
 
+.if ${MODPY_VERSION} < 2.6
+MODPY_JSON = ::devel/py-simplejson
+.else
+MODPY_JSON =
+.endif
+
 MODPY_RUN_DEPENDS= :${MODPYSPEC}:lang/python/${MODPY_VERSION}
 MODPY_LIB_DEPENDS= python${MODPY_VERSION}:${MODPYSPEC}:lang/python/${MODPY_VERSION}
 _MODPY_BUILD_DEPENDS= :${MODPYSPEC}:lang/python/${MODPY_VERSION}
-31,6 +37,7
 RUN_DEPENDS+= ${MODPY_RUN_DEPENDS}
 .endif
 
+MODPY_FAKE_SETUPTOOLS = :
 .if defined(MODPY_SETUPTOOLS) && ${MODPY_SETUPTOOLS:U} == YES
 # The setuptools module provides a package locator (site.py) that is
 # required at runtime for the pkg_resources stuff to work
-39,6 +46,17
 BUILD_DEPENDS+= ${MODPY_SETUPUTILS_DEPEND}
 # The setuptools uses test target
 REGRESS_TARGET?= test
+_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.
+_MODPY_SETUPTOOLS_FAKE_DIR = \
+ ${WRKINST}/lib/python${MODPY_VERSION}/site-packages/setuptools
+MODPY_FAKE_SETUPTOOLS += \
+ ;mkdir -p ${_MODPY_SETUPTOOLS_FAKE_DIR} \
+ ;echo "def setup(*args, **kwargs): raise Exception('OpenBSD ports: MODPY_SETUPTOOLS = Yes is required')\nExtension = setup" > \
+ ${_MODPY_SETUPTOOLS_FAKE_DIR}/__init__.py
+_MODPY_USERBASE = ${WRKINST}
 .endif
 
 .if !defined(NO_SHARED_LIBS) || ${NO_SHARED_LIBS:U} != YES
-75,7 +93,7
                                 --root=${DESTDIR}
 .endif
 
-MAKE_ENV+= CC=${CC}
+MAKE_ENV+= CC=${CC} PYTHONUSERBASE=${_MODPY_USERBASE}
 CONFIGURE_ENV+= PYTHON="${MODPY_BIN}"
 
 _MODPY_CMD= cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
-87,6 +105,7
 .if empty(CONFIGURE_STYLE)
 . if !target(do-build)
 do-build:
+ ${MODPY_FAKE_SETUPTOOLS}
         ${_MODPY_CMD} ${MODPY_DISTUTILS_BUILD} ${MODPY_DISTUTILS_BUILDARGS}
         ${MODPY_POST_BUILD_BAD_EGGS}
 . endif