Hi,

this is the diff to update python.port.mk to permit to have both Python 2.x and 
3.x working on OpenBSD.

How it works:
1) Python2 port
- all ports existing don't need to change, they still build with Python 2

2) Python2 and Python3 port
- if you know that a port (and its dependencies...) work with Python 3 && 
Python 2, you just need to add:
IS_PY3 = Yes for all the ports. Be carefull to add ${MODPY_FLAVOR} to your 
dependencies (see examples at the end).
Next, to build your port you will need to precise the correct flavor: python3.

In this case, you must be very carreful with the conflict of the PLIST. If your 
port is a library, there is often no problems, but you will have problem with 
binaries/doc/examples/wub/...
So you will have to "play" with post-install, in moving files which are 
conflicting by suffixing it (see examples at the end).
FYI the port built with python3 will replace the prefix py- by py3-.

3) Python3 port
- if you know that a port (and its dependencies) work with Python 3 only, you 
just need to add:
IS_PY3 = Only, and it will automatically build this port with Python 3.
FYI the port built with python3 follow the same logic that in python2, so if 
the port PKGNAME begins with py- it will automatically be replaced by py3-.


More details about modifications needed:
- remove the devel/py3-distribute, not used and useless to have py3 in the dir 
name (maybe a quirks thing to permit distribute -> py3-distribute? If not used 
actually, are modifications in quirks needed?)
- some people don't want to replace py-setuptools by py-distribute, so keep 
py-setuptools (Python 2 only).
- add the port devel/py-distribute, only used with Python3 ports (IS_PY3 = 
Only, will have the py3-distribute FULLPKGNAME. I attached the diff between 
actual py3-distribute and what we want, easier to understand).
- remove the MODPY_DISTRIBUTE, useless. Keep the MODPY_SETUPTOOLS only, easier 
to maintain, even if we used distribute or setuptools after, it's not the 
problem of the porters.


So, if your ports use:
1) Python 2 only
- nothing to change

2) Python 2 and Python 3:
- add IS_PY3 = Yes
- add to your *_DEPENDS : ${MODPY_FLAVOR}, without comma (example: 
BUILD_DEPENDS: devel/py-distribute${MODPY_FLAVOR}).
- make sure your PLIST will not be in conflict by adding special tasks in 
post-install. Example:
post-install:
        mv ${WRKINST}/${LOCALBASE}/foo/bar 
${WRKINST}/${LOCALBASE}/foo/bar${MODPY_BIN_SUFFIX}

If you use the default FLAVOR (Python 2), MODPY_BIN_SUFFIX is "", so no 
modifications for people who use the default. If you use the FLAVOR Python 3, 
MODPY_BIN_SUFFIX = 3.
Add ${MODPY_BIN_SUFFIX} to your PLIST.

3) Python 3:
- add IS_PY3 = Only

I think the best thing to do now is to patch python.port.mk and run a full bulk 
build to see if all ports are ok :).

Cheers,
-- 
Remi
Index: python.port.mk
===================================================================
RCS file: /cvs/ports/lang/python/python.port.mk,v
retrieving revision 1.47
diff -u -r1.47 python.port.mk
--- python.port.mk      17 Oct 2011 13:55:24 -0000      1.47
+++ python.port.mk      16 Nov 2011 15:51:30 -0000
@@ -7,23 +7,66 @@
 
 CATEGORIES+=           lang/python
 
-MODPY_VERSION?=                2.7
+# define the default version
+_MODPY_DEFAULT_VERSION = 2.7
 
-.if ${MODPY_VERSION} == "2.4" || ${MODPY_VERSION} == "2.5" || ${MODPY_VERSION} 
== "2.7" || ${MODPY_VERSION} == "3.2"
-
-.  if ${MODPY_VERSION} < 2.6
-MODPY_JSON =           devel/py-simplejson
-.  else
-MODPY_JSON =
+.if !defined(MODPY_VERSION)
+.  if !defined(FLAVORS) && defined(IS_PY3)
+.    if ${IS_PY3:L:Myes}
+FLAVORS?=      python3
+# force to use python3 if ports is python3 only
+.    elif ${IS_PY3:L:Monly}
+FLAVORS?=      python3
+FLAVOR=                python3
+.    else
+ERRORS += "Fatal: please verify IS_PY3 is correctly defined: \n\
+       - set to Yes if your port can be build with python2 and python3 \n\
+       - set to Only if your port can be build only with python3 \n"
+.    endif
 .  endif
 
-.  if ${MODPY_VERSION} < 3.2
-MODPY_WANTLIB =        python${MODPY_VERSION}
-.  else
-MODPY_WANTLIB = python${MODPY_VERSION}m
+FLAVOR?=
+
+.  if empty(FLAVOR)
+# without flavor, assume we use the default version
+MODPY_VERSION?=                ${_MODPY_DEFAULT_VERSION}
+.  elif ${FLAVOR:L:Mpython3}
+# define default version 3
+MODPY_VERSION?=                3.2
 .  endif
+
+# verify if MODPY_VERSION forced is correct
 .else
+.  if ${MODPY_VERSION} != "2.4" && \
+      ${MODPY_VERSION} != "2.5" && \
+      ${MODPY_VERSION} != "2.7" && \
+      ${MODPY_VERSION} != "3.2"
 ERRORS += "Fatal: unknown or unsupported MODPY_VERSION: ${MODPY_VERSION}"
+.  endif
+.endif
+
+_MODPY_MAJOR_VERSION = ${MODPY_VERSION:C/\.[1-9]*//g}
+
+.if ${_MODPY_MAJOR_VERSION} == 2
+MODPY_LIB_SUFFIX =
+MODPY_FLAVOR =
+MODPY_BIN_SUFFIX =
+
+.elif ${_MODPY_MAJOR_VERSION} == 3
+MODPY_LIB_SUFFIX =     m
+# replace py- prefix by py3-
+FULLPKGNAME =  ${PKGNAME:S/^py-/py3-/}
+MODPY_FLAVOR = ,python3
+# add the modpy_version without the '.' to the binaries to avoid conflict
+MODPY_BIN_SUFFIX =     ${_MODPY_MAJOR_VERSION}
+.endif
+
+MODPY_WANTLIB = python${MODPY_VERSION}${MODPY_LIB_SUFFIX}
+
+.if ${MODPY_VERSION} < 2.6
+MODPY_JSON =           devel/py-simplejson
+.else
+MODPY_JSON =
 .endif
 
 MODPY_RUN_DEPENDS=     lang/python/${MODPY_VERSION}
@@ -41,15 +84,17 @@
 .endif
 
 MODPY_PRE_BUILD_STEPS = @:
-.if (defined(MODPY_SETUPTOOLS) && ${MODPY_SETUPTOOLS:U} == YES) || \
-    (defined(MODPY_DISTRIBUTE) && ${MODPY_DISTRIBUTE:U} == YES)
+.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
-.if ${MODPY_SETUPTOOLS:U} == YES
+.  if ${_MODPY_MAJOR_VERSION} == 2
 MODPY_SETUPUTILS_DEPEND?=devel/py-setuptools
-.else
-MODPY_SETUPUTILS_DEPEND ?= devel/py3-distribute
-.endif
+.  elif ${_MODPY_MAJOR_VERSION} == 3
+MODPY_SETUPUTILS_DEPEND?=devel/py-distribute,python3
+.  else
+ERRORS += "Fatal: unknown or unsupported _MODPY_MAJOR_VERSION: 
${_MODPY_MAJOR_VERSION}"
+.  endif
+
 MODPY_RUN_DEPENDS+=    ${MODPY_SETUPUTILS_DEPEND}
 BUILD_DEPENDS+=                ${MODPY_SETUPUTILS_DEPEND}
 MODPY_SETUPUTILS =     Yes
@@ -65,8 +110,7 @@
        ;mkdir -p ${_MODPY_SETUPUTILS_FAKE_DIR} \
        ;exec >${_MODPY_SETUPUTILS_FAKE_DIR}/__init__.py \
        ;echo 'def setup(*args, **kwargs):' \
-       ;echo '    msg = "OpenBSD ports: MODPY_SETUPTOOLS = Yes or\\n" \' \
-       ;echo '          "\\t\\t\\t  MODPY_DISTRIBUTE = Yes required"' \
+       ;echo '    msg = "OpenBSD ports: MODPY_SETUPTOOLS = Yes is required"' \
        ;echo '    raise Exception(msg)' \
        ;echo 'Extension = Feature = find_packages = setup'
 MODPY_SETUPUTILS =     No
@@ -110,7 +154,7 @@
 _MODPY_CMD=    @cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
                        ${MODPY_BIN} ./${MODPY_SETUP}
 
-SUBST_VARS:=   MODPY_BIN MODPY_EGG_VERSION MODPY_VERSION ${SUBST_VARS}
+SUBST_VARS:=   MODPY_BIN MODPY_BIN_SUFFIX MODPY_EGG_VERSION MODPY_VERSION 
${SUBST_VARS}
 
 # set MODPY_BIN for executable scripts
 MODPY_BIN_ADJ= perl -pi \
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/py3-distribute/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- Makefile    25 Sep 2011 13:36:18 -0000      1.3
+++ Makefile    16 Nov 2011 16:03:13 -0000
@@ -2,10 +2,9 @@
 
 COMMENT =              fork of setuptools Python packages
 
-MODPY_EGG_VERSION =    0.6.21
+MODPY_EGG_VERSION =    0.6.24
 DISTNAME =             distribute-${MODPY_EGG_VERSION}
-
-REVISION =             0
+PKGNAME =              py-${DISTNAME}
 
 CATEGORIES =           devel
 
@@ -22,8 +21,9 @@ PERMIT_DISTFILES_FTP =        Yes
 MASTER_SITES =         ${MASTER_SITE_PYPI:=d/distribute/}
 
 MODULES =              lang/python
-MODPY_VERSION =                3.2
 
 NO_REGRESS =           Yes
+
+IS_PY3 =               Only
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/devel/py3-distribute/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo    17 Sep 2011 12:15:40 -0000      1.1.1.1
+++ distinfo    16 Nov 2011 16:03:13 -0000
@@ -1,5 +1,5 @@
-MD5 (distribute-0.6.21.tar.gz) = yM/P1C7Jq5APs5YKMwju8g==
-RMD160 (distribute-0.6.21.tar.gz) = OiWB7Z6zOLF/J+KDu29gUM9i/xc=
-SHA1 (distribute-0.6.21.tar.gz) = S8PfUkuh1oS6mXyqszRgQFUaOCA=
-SHA256 (distribute-0.6.21.tar.gz) = 
HtS1iV5yKwb2cB9W3SJ91qoly/wMds4EZbdV7ZL1IJc=
-SIZE (distribute-0.6.21.tar.gz) = 399934
+MD5 (distribute-0.6.24.tar.gz) = F3IrIhQauoI1eH95gAzEUg==
+RMD160 (distribute-0.6.24.tar.gz) = zEzpX74O8kmssu8uxqBra4NoN4g=
+SHA1 (distribute-0.6.24.tar.gz) = BnC9u6K+aJL2em+UYll3b6gzFSU=
+SHA256 (distribute-0.6.24.tar.gz) = 
xh/enziMlgDrjuVL1xaAOcX7dPozQTi8Sc32psE0Fic=
+SIZE (distribute-0.6.24.tar.gz) = 620771
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/devel/py3-distribute/pkg/PLIST,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 PLIST
--- pkg/PLIST   17 Sep 2011 12:15:40 -0000      1.1.1.1
+++ pkg/PLIST   16 Nov 2011 16:03:13 -0000
@@ -6,7 +6,6 @@ lib/python${MODPY_VERSION}/site-packages
 
lib/python${MODPY_VERSION}/site-packages/distribute-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info/SOURCES.txt
 
lib/python${MODPY_VERSION}/site-packages/distribute-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info/dependency_links.txt
 
lib/python${MODPY_VERSION}/site-packages/distribute-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info/entry_points.txt
-lib/python${MODPY_VERSION}/site-packages/distribute-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info/entry_points.txt.orig
 
lib/python${MODPY_VERSION}/site-packages/distribute-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info/top_level.txt
 
lib/python${MODPY_VERSION}/site-packages/distribute-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info/zip-safe
 lib/python${MODPY_VERSION}/site-packages/easy_install.py
@@ -20,6 +19,8 @@ lib/python${MODPY_VERSION}/site-packages
 lib/python${MODPY_VERSION}/site-packages/setuptools/__init__.pyc
 lib/python${MODPY_VERSION}/site-packages/setuptools/archive_util.py
 lib/python${MODPY_VERSION}/site-packages/setuptools/archive_util.pyc
+lib/python${MODPY_VERSION}/site-packages/setuptools/cli-32.exe
+lib/python${MODPY_VERSION}/site-packages/setuptools/cli-64.exe
 lib/python${MODPY_VERSION}/site-packages/setuptools/cli.exe
 lib/python${MODPY_VERSION}/site-packages/setuptools/command/
 lib/python${MODPY_VERSION}/site-packages/setuptools/command/__init__.py
@@ -72,6 +73,8 @@ lib/python${MODPY_VERSION}/site-packages
 lib/python${MODPY_VERSION}/site-packages/setuptools/dist.pyc
 lib/python${MODPY_VERSION}/site-packages/setuptools/extension.py
 lib/python${MODPY_VERSION}/site-packages/setuptools/extension.pyc
+lib/python${MODPY_VERSION}/site-packages/setuptools/gui-32.exe
+lib/python${MODPY_VERSION}/site-packages/setuptools/gui-64.exe
 lib/python${MODPY_VERSION}/site-packages/setuptools/gui.exe
 lib/python${MODPY_VERSION}/site-packages/setuptools/package_index.py
 lib/python${MODPY_VERSION}/site-packages/setuptools/package_index.pyc

Reply via email to