tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

patch: handling python distutils and egg files



distutils is part of python.  In 2.5 and newer egg files are created,
for dependency resolution.  pkgsrc contains a mechanism to make 2.5+
refrain from creating egg files, but the right approach is to accomodate
them in the PLIST if upstream thinks they should be present.

The following patch:

  Adds a variable in pyversion.mk to denote that 24 doesn't create egg
  files.  Alternately, this could be a conditional in distutils.mk, but
  it seems sensible to have versions declare their capabilities.

  Adds lang/python/distutils.mk, for use with python distributions that
  use distutils.  This is structurally cloned from egg.mk.

  Supports having egg files in PLIST if the python version creates egg
  files, both in using a conditional PLIST and generating it
  automatically.

  Changes one package to use the new mechanism.  It builds with python24
  and python26.

Comments requested.  (Committing this doesn't affect much, since it's a
new abstraction that very little would use until packages are changed
over to it.)

Index: lang/python/distutils.mk
===================================================================
RCS file: lang/python/distutils.mk
diff -N lang/python/distutils.mk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lang/python/distutils.mk    24 Jul 2010 01:39:23 -0000
@@ -0,0 +1,41 @@
+# $NetBSD$
+#
+# Common logic for python distributions that use distutils.
+#
+.include "../../mk/bsd.fast.prefs.mk"
+
+.include "../../lang/python/pyversion.mk"
+
+# This file should be included to package python "distributions" which
+# use distutils.  See egg.mk for distributions that use setuptools and
+# extensions.mk for ad hoc cases.
+
+# Set the egg file basename.  The egg file may or may not be created.
+EGG_NAME?=     ${DISTNAME}
+
+PYDISTUTILSPKG=        yes
+
+PY_PATCHPLIST= yes
+
+# By default, we expect distutils to create an egg-info file if Python
+# distutils can do so.  If the package set PY_NO_EGG, respect that
+# choice.
+.if defined(PYDISTUTILS_NO_EGGFILES)
+# Python distutils will not create eggfiles.
+PLIST_SUBST+=  EGG_MAYBE="@comment (not in 2.4) "
+PY_NO_EGG?=    yes
+.else
+PLIST_SUBST+=  EGG_MAYBE=""
+PY_NO_EGG?=    no
+.endif
+
+# XXX Why isn't this in extension.mk instead?
+INSTALLATION_DIRS+=    ${PYSITELIB}
+
+# Egg files have the version encoded, so generalize in PLIST.  Make eggs
+# optional.
+PLIST_SUBST+=  EGG_FILE=${EGG_NAME}-py${PYVERSSUFFIX}.egg-info
+PRINT_PLIST_AWK+=      { 
gsub("${PYSITELIB}/${EGG_NAME}-py${PYVERSSUFFIX}.egg-info", \
+                               "$${EGG_MAYBE}$${PYSITELIB}/$${EGG_FILE}") }
+
+.include "../../lang/python/extension.mk"
Index: lang/python/pyversion.mk
===================================================================
RCS file: /cvsroot/pkgsrc/lang/python/pyversion.mk,v
retrieving revision 1.80
diff -u -p -r1.80 pyversion.mk
--- lang/python/pyversion.mk    12 Feb 2010 13:45:54 -0000      1.80
+++ lang/python/pyversion.mk    24 Jul 2010 01:39:23 -0000
@@ -134,6 +134,7 @@ PYDEPENDENCY=       ${BUILDLINK_API_DEPENDS.py
 PYPACKAGE=     python24
 PYVERSSUFFIX=  2.4
 PYPKGPREFIX=   py24
+PYDISTUTILS_NO_EGGFILES=       YES
 .else
 PKG_FAIL_REASON+=   "No valid Python version"
 .endif


Index: security/py-crypto/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/security/py-crypto/Makefile,v
retrieving revision 1.18
diff -u -p -r1.18 Makefile
--- security/py-crypto/Makefile 23 Jul 2010 23:12:36 -0000      1.18
+++ security/py-crypto/Makefile 24 Jul 2010 01:39:23 -0000
@@ -2,7 +2,7 @@
 #
 
 DISTNAME=      pycrypto-2.1.0
-PKGREVISION=   2
+PKGREVISION=   3
 PKGNAME=       ${PYPKGPREFIX}-crypto-2.1.0
 CATEGORIES=    security python
 MASTER_SITES=  http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/
@@ -15,12 +15,7 @@ COMMENT=     Cryptographic and hash function
 
 PKG_DESTDIR_SUPPORT=   user-destdir
 
-PYDISTUTILSPKG=        yes
-PY_NO_EGG=     no
-EGG_NAME?=     ${DISTNAME}
-PLIST_SUBST+=  EGG_FILE=${EGG_NAME}-py${PYVERSSUFFIX}.egg-info
-
 .include "../../devel/gmp/buildlink3.mk"
-.include "../../lang/python/extension.mk"
+.include "../../lang/python/distutils.mk"
 .include "../../security/openssl/buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"
Index: security/py-crypto/PLIST
===================================================================
RCS file: /cvsroot/pkgsrc/security/py-crypto/PLIST,v
retrieving revision 1.4
diff -u -p -r1.4 PLIST
--- security/py-crypto/PLIST    23 Jul 2010 23:24:19 -0000      1.4
+++ security/py-crypto/PLIST    24 Jul 2010 01:39:23 -0000
@@ -265,4 +265,4 @@ ${PYSITELIB}/Crypto/__init__.pyo
 ${PYSITELIB}/Crypto/pct_warnings.py
 ${PYSITELIB}/Crypto/pct_warnings.pyc
 ${PYSITELIB}/Crypto/pct_warnings.pyo
-${PYSITELIB}/${EGG_FILE}
+${EGG_MAYBE}${PYSITELIB}/${EGG_FILE}

Attachment: pgpyD29h_Otsh.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index