Ticket #30674: Portfile

File Portfile, 6.1 KB (added by skymoo (Adam Mercer), 13 years ago)

unified Portfile for py*-numpy

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
2# $Id$
3
4PortSystem              1.0
5PortGroup               python 1.0
6
7name                    py-numpy
8version                 1.6.1
9categories              python math
10license                 BSD
11platforms               darwin
12maintainers             dh ram openmaintainer
13description             The core utilities for the scientific library scipy for Python
14long_description        ${description}
15
16homepage                http://numpy.scipy.org/
17master_sites            sourceforge:project/numpy/NumPy/${version}/
18distname                numpy-${version}
19
20checksums               md5 2bce18c08fc4fce461656f0f4dd9103e \
21                        sha1 3f73ff9231a1c15e28e6e259ef5cc35a72b34059 \
22                        rmd160 e4619fd5860c85a9c00bce0d0cb8dd9bb07a56f5
23
24if {${subport} != ${name}} {
25
26patchfiles              patch-f2py_setup.py.diff \
27                        patch-system_info.py.diff \
28                        patch-fcompiler_g95.diff
29
30depends_lib-append      port:fftw-3 \
31                        port:py${python.version}-nose
32
33if {[variant_isset universal] && ![variant_isset atlas]} {
34    build.env-append    ARCHFLAGS="${configure.universal_ldflags}"
35} else {
36    build.env-append    ARCHFLAGS="${configure.ld_archflags}"
37}
38
39variant atlas \
40description {Use the MacPorts' ATLAS libraries \
41             instead of Apple's Accelerate framework} {
42    build.env-append    ATLAS=${prefix}/lib \
43                        LAPACK=${prefix}/lib \
44                        BLAS=${prefix}/lib
45    destroot.env-append ATLAS=${prefix}/lib \
46                        LAPACK=${prefix}/lib \
47                        BLAS=${prefix}/lib
48    depends_lib-append  port:atlas
49}
50
51# when using ATLAS (whether by default or specified by the user via
52# the +atlas variant) ...
53set gcc_version ""
54if {[variant_isset atlas]} {
55
56    # see if the user has set -gcc4X to disable using MacPorts'
57    # compiler; if not, either use what the user set (as +gcc4X) or
58    # default to gcc44.
59
60    variant gcc43 conflicts gcc44 gcc45 \
61    description {Use the gcc43 compiler (enables fortran linking)} {
62        configure.compiler  macports-gcc-4.3
63    }
64
65    variant gcc44 conflicts gcc43 gcc45 \
66    description {Use the gcc44 compiler (enables fortran linking)} {
67        configure.compiler  macports-gcc-4.4
68    }
69
70    variant gcc45 conflicts gcc43 gcc44 \
71    description {Use the gcc45 compiler (enables fortran linking)} {
72        configure.compiler  macports-gcc-4.5
73    }
74
75    if {![variant_isset gcc43] && ![variant_isset gcc45]} {
76        default_variants +gcc44
77    }
78    if {[variant_isset gcc43]} {
79        set gcc_version "4.3"
80    } elseif {[variant_isset gcc44]} {
81        set gcc_version "4.4"
82    } elseif {[variant_isset gcc45]} {
83        set gcc_version "4.5"
84    }
85
86    # when using non-Apple GCC for universal install, it can
87    # create binaries only for the native OS architecture, at
88    # either 32 or 64 bits.  Restrict the supported archs
89    # accordingly.
90    if {${os.arch} == "i386"} {
91        supported_archs i386 x86_64
92    } elseif {${os.arch} == "powerpc"} {
93        supported_archs ppc ppc64
94    }
95
96    # include all the correct GCC4X port
97    depends_lib-append port:gcc[join [split ${gcc_version} "."] ""]
98
99    # force LDFLAGS for correct linking of the linalg module
100    # for non-Apple GCC compilers
101    patchfiles-append  patch-numpy_linalg_setup.py.diff
102
103    if {${gcc_version} == ""} {
104        # user specified -gcc4X but +atlas (either as default or
105        # explicitly); do not allow since it might lead to
106        # undetermined runtime execution.
107        return -code error \
108"\n\nWhen using the +atlas variant (either as the default or setting
109explicitly), one of the +gcc4X variants must be selected.\n"
110    }
111} else {
112    variant universal {
113        patchfiles-append   patch-setup.py.diff
114    }
115}
116
117post-patch {
118    reinplace "s|@@MPORTS_PYTHON@@|${python.bin}|" \
119        ${worksrcpath}/numpy/f2py/setup.py
120
121    if {[variant_isset universal] && [variant_isset atlas]} {
122        # Prepare wrappers
123        file copy -force ${filespath}/wrapper-template \
124            ${worksrcpath}/c-wrapper
125        file copy -force ${filespath}/wrapper-template \
126            ${worksrcpath}/f-wrapper
127        file copy -force ${filespath}/wrapper-template \
128            ${worksrcpath}/cxx-wrapper
129
130        if {[variant_isset gcc43]} {
131            set CC  "${prefix}/bin/gcc-mp-4.3"
132            set CXX "${prefix}/bin/g++-mp-4.3"
133            set F90 "${prefix}/bin/gfortran-mp-4.3"
134        } elseif {[variant_isset gcc44]} {
135            set CC  "${prefix}/bin/gcc-mp-4.4"
136            set CXX "${prefix}/bin/g++-mp-4.4"
137            set F90 "${prefix}/bin/gfortran-mp-4.4"
138        } elseif {[variant_isset gcc45]} {
139            set CC  "${prefix}/bin/gcc-mp-4.5"
140            set CXX "${prefix}/bin/g++-mp-4.5"
141            set F90 "${prefix}/bin/gfortran-mp-4.5"
142        }
143
144        reinplace   "s|@@@|${CC}|" ${worksrcpath}/c-wrapper
145        reinplace   "s|---|\\\\.c|" ${worksrcpath}/c-wrapper
146        reinplace   "s|&&&|${prefix}|" ${worksrcpath}/c-wrapper
147
148        reinplace   "s|@@@|${CXX}|" ${worksrcpath}/cxx-wrapper
149        reinplace   "s#---#(\\\\.C|\\\\.cpp|\\\\.cc)#" \
150            ${worksrcpath}/cxx-wrapper
151        reinplace   "s|&&&|${prefix}|" ${worksrcpath}/cxx-wrapper
152
153        reinplace   "s|@@@|${F90}|" ${worksrcpath}/f-wrapper
154        reinplace   "s|---|\\\\.f|" ${worksrcpath}/f-wrapper
155        reinplace   "s|&&&|${prefix}|" ${worksrcpath}/f-wrapper
156
157        build.env-append    CC="${worksrcpath}/c-wrapper" \
158                            CXX="${worksrcpath}/cxx-wrapper" \
159                            F77="${worksrcpath}/f-wrapper" \
160                            F90="${worksrcpath}/f-wrapper"
161
162        destroot.env-append CC="${worksrcpath}/c-wrapper" \
163                            CXX="${worksrcpath}/cxx-wrapper" \
164                            F77="${worksrcpath}/f-wrapper" \
165                            F90="${worksrcpath}/f-wrapper"
166    }
167}
168
169}
170
171livecheck.type        regex
172livecheck.url         http://www.scipy.org
173livecheck.regex       {NumPy (\d+(\.\d+)*) released}