On Jan 11, 2013, at 03:59, [email protected] wrote:

> Revision: 101459
>          https://trac.macports.org/changeset/101459
> Author:   [email protected]
> Date:     2013-01-11 01:59:36 -0800 (Fri, 11 Jan 2013)
> Log Message:
> -----------
> py-polygon: update to version 2.0.5
> 
> Modified Paths:
> --------------
>    trunk/dports/python/py-polygon/Portfile
>    trunk/dports/python/py-polygon/files/patch-setup.py.diff
> 
> Modified: trunk/dports/python/py-polygon/Portfile
> ===================================================================
> --- trunk/dports/python/py-polygon/Portfile   2013-01-11 09:44:57 UTC (rev 
> 101458)
> +++ trunk/dports/python/py-polygon/Portfile   2013-01-11 09:59:36 UTC (rev 
> 101459)
> @@ -5,8 +5,8 @@
> PortGroup           python 1.0
> 
> name                py-polygon
> -version             2.0.4
> -revision            1
> +version             2.0.5
> +revision            0
> categories-append   devel math
> license             LGPL
> platforms           darwin
> @@ -26,17 +26,21 @@
> distname            Polygon-${version}
> use_zip             yes
> 
> -checksums           md5     9a036b22d1ee9568b8cbfa40b0bfa721 \
> -                    sha1    aa734572c911c0ddb4b39d1bf21f8ecbfa3685c8 \
> -                    rmd160  dfb26325998f3e8b44ac36f6ef2c0be30b8d9fd9
> +checksums           rmd160  6593a9ea0c8b25cab29c9cbaaf5d37230364b32d \
> +                    sha256  
> e0a111559eee27c8aee455cca6a1c5480a593ad5b0c11719a5cf066867d7a465
> 
> python.versions     25 26 27
> python.default_version 27
> 
> +patchfiles-append   patch-setup.py.diff
> +
> variant numpy description {Build with NumPy support} {
>     if {$subport != $name} {
>         depends_lib-append  port:py${python.version}-numpy
> -        patchfiles-append   patch-setup.py.diff
> +
> +        post-patch {
> +            reinplace "s|withNumPy=False|withNumPy=True|g" 
> ${worksrcpath}/setup.py
> +        }
>     }
> }
> 
> 
> Modified: trunk/dports/python/py-polygon/files/patch-setup.py.diff
> ===================================================================
> --- trunk/dports/python/py-polygon/files/patch-setup.py.diff  2013-01-11 
> 09:44:57 UTC (rev 101458)
> +++ trunk/dports/python/py-polygon/files/patch-setup.py.diff  2013-01-11 
> 09:59:36 UTC (rev 101459)
> @@ -1,21 +1,24 @@
> ---- setup.py.orig    2011-04-07 15:26:45.000000000 +0400
> -+++ setup.py 2011-04-07 15:27:57.000000000 +0400
> -@@ -6,12 +6,16 @@
> +--- setup.py.orig    2012-07-03 13:55:50.000000000 +0400
> ++++ setup.py 2013-01-11 13:54:00.000000000 +0400
> +@@ -5,12 +5,19 @@
>  #  * faster adding of contours from NumPy arrays
>  #  * data style STYLE_NUMPY to get contours and TriStrips
>  #    as NumPy arrays
> --withNumPy=False
> -+withNumPy=True
> +-withNumPy=True
> ++withNumPy=False
> 
>  # if withNumPy is True, set the include path for numpy/arrayobject.h
>  # the example is for python on Windows:
>  # numPyIncludePath='C:\\Python26\\Lib\\site-packages\\numpy\\core\\include'
> -numPyIncludePath=''
> -+try:
> -+    import numpy
> -+except ImportError:
> -+    raise Exception("PYTHON interface requires numpy")
> -+numPyIncludePath = numpy.get_include()
> ++if withNumPy:
> ++    try:
> ++        import numpy
> ++    except ImportError:
> ++        raise Exception("PYTHON interface requires numpy")
> ++    numPyIncludePath = numpy.get_include()
> ++else:
> ++    numPyIncludePath = ''
> 
>  # defaultStyle may be used to set the default style to one of:
>  #  * STYLE_TUPLE to get tuples of points


I see you're applying a patch in the main part of the portfile which disables 
numpy in the setup file, and then in the numpy variant, you're applying a 
reinplace to turn it back on again. reinplaces are fragile, and you don't get 
any notification from MacPorts if they fail to apply. This can lead to problems 
when the software is updated in the future. An alternate method I could 
recommend would be to break the patchfile up into two files. Apply one of them 
in the main part of the port, and apply the other one (the one that turns off 
numpy support) only if the numpy variant is not selected.

Additionally, the numpy variant should be declared inside the "if {$subport != 
$name}" block; stub ports shouldn't have variants. (You can then remove the "if 
{$subport != $name}" check that's inside the variant.)


_______________________________________________
macports-dev mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macports-dev

Reply via email to