source: trunk/dports/python/py-numpy/Portfile

Last change on this file was 153885, checked in by michaelld@…, 9 months ago

py*-numpy: fix rpath pass-through to ld setting, to work on most modern compilers; addresses tickets #51250 and #51419.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.3 KB
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: Portfile 153885 2016-10-14 23:27:21Z ryandesign@macports.org $
3
4PortSystem              1.0
5PortGroup               python 1.0
6PortGroup               github 1.0
7PortGroup               compilers 1.0
8
9github.setup            numpy numpy 1.11.2 v
10revision                1
11name                    py-numpy
12
13categories-append       math
14license                 BSD
15platforms               darwin
16maintainers             michaelld openmaintainer
17description             The core utilities for the scientific library scipy for Python
18long_description        ${description}
19
20checksums               rmd160 e2442df917593d8666025d04b892098956cccc3d \
21                        sha256 44685b9667b9e1a334e4ede73c0b3856c9049fdaca1cd5cb8169ed4c767d557b
22
23if {${name} ne ${subport}} {
24    # the python PortGroup puts compiler names in build.env and destroot.env
25    # for this to be done correctly, the following must be located before python.versions
26    pre-build    { set_compilers }
27    pre-destroot { set_compilers }
28}
29
30python.versions         26 27 33 34 35
31
32# respect ${build_arch} value
33compilers.clear_archflags  no
34
35# http://trac.macports.org/ticket/34562
36python.consistent_destroot yes
37
38# TODO: Fix the +universal variant.  This port is a fairly deep dependency and needs to be able to support +universal.
39# https://trac.macports.org/ticket/48263
40#universal_variant no
41
42if {${name} ne ${subport}} {
43    compilers.setup         require_fortran -clang -dragonegg -gcc44 -gcc45 -gcc46 \
44                            -gcc47 -gcc48 -g95 clang37
45
46    patchfiles              patch-f2py_setup.py.diff \
47                            patch-fcompiler_g95.diff \
48                            patch-numpy_core_setup.py.diff \
49                            patch-numpy_distutils_fcompiler_gnu.py.diff
50
51    depends_lib-append      port:fftw-3 \
52                            port:py${python.version}-nose \
53                            port:py${python.version}-cython
54
55    pre-build {
56        build.env-append        ARCHFLAGS="[get_canonical_archflags ld]"
57    }
58
59    pre-destroot {
60        destroot.env-append     ARCHFLAGS="[get_canonical_archflags ld]"
61    }
62
63    variant atlas description conflicts openblas {Use MacPorts ATLAS Libraries} {
64        depends_lib-append      port:atlas
65    }
66
67    variant openblas conflicts atlas description "Use MacPorts OpenBLAS Libraries" {
68        depends_lib-append  path:lib/libopenblas.dylib:openblas
69    }
70
71    # when using ATLAS (whether by default or specified by the user via
72    # the +atlas variant) ...
73    if {[variant_isset atlas]} {
74
75        # when using non-Apple GCC for universal install, it can
76        # create binaries only for the native OS architecture, at
77        # either 32 or 64 bits.  Restrict the supported archs
78        # accordingly.
79        if {${os.arch} eq "i386"} {
80            supported_archs         i386 x86_64
81        } elseif {${os.arch} eq "powerpc"} {
82            supported_archs         ppc ppc64
83        }
84
85        # force LDFLAGS for correct linking of the linalg module
86        # for non-Apple GCC compilers
87        patchfiles-append       patch-numpy_linalg_setup.py.diff
88
89        pre-fetch {
90            # numpy needs fortran; so we only need to check if atlas is
91            # compiled with +nofortran
92            if {![catch {set result [active_variants atlas "" nofortran]}]} {
93                if {!$result} {
94                    return -code error \
95"You have selected the +atlas variant but atlas was built with +nofortran.\
96numpy needs a fortran enabled atlas. Please rebuild atlas without the +nofortran\
97variant."
98                }
99            }
100        }
101
102        # use MacPorts atlas
103        build.env-append    OPENBLAS=None \
104                            ATLAS=${prefix}/lib \
105                            LAPACK=${prefix}/lib \
106                            BLAS=${prefix}/lib
107        destroot.env-append OPENBLAS=None \
108                            ATLAS=${prefix}/lib \
109                            LAPACK=${prefix}/lib \
110                            BLAS=${prefix}/lib
111
112    } elseif {[variant_isset openblas]} {
113
114        # use MacPorts OpenBLAS
115        build.env-append    OPENBLAS=${prefix}/lib \
116                            ATLAS=None
117        destroot.env-append OPENBLAS=${prefix}/lib \
118                            ATLAS=None
119        # force LDFLAGS for correct linking of the modules
120        # for non-Apple GCC compilers
121        patchfiles-append   patch-numpy_linalg_setup.py.diff
122
123    } else {
124        # use Accelerate BLAS
125        build.env-append    OPENBLAS=None \
126                            ATLAS=None \
127                            LAPACK=/usr/lib \
128                            BLAS=/usr/lib
129        destroot.env-append OPENBLAS=None \
130                            ATLAS=None \
131                            LAPACK=/usr/lib \
132                            BLAS=/usr/lib
133    }
134
135    platform darwin 8 {
136        patchfiles-append patch-Tiger-without-dflcn-header.diff
137    }
138
139    post-patch {
140        reinplace "s|@@MPORTS_PYTHON@@|${python.bin}|" \
141            ${worksrcpath}/numpy/f2py/setup.py
142
143        # https://trac.macports.org/ticket/46392
144        if {${os.arch} eq "powerpc"} {
145            reinplace "s,'-O3','-O2'," \
146                ${worksrcpath}/numpy/distutils/fcompiler/gnu.py
147        }
148
149        if { [use_wrapper] } {
150            # Prepare wrappers
151            file copy -force ${filespath}/wrapper-template \
152                ${worksrcpath}/c-wrapper
153            file copy -force ${filespath}/wrapper-template \
154                ${worksrcpath}/f-wrapper
155            file copy -force ${filespath}/wrapper-template \
156                ${worksrcpath}/cxx-wrapper
157
158            reinplace   "s|@@@|${configure.cc}|" ${worksrcpath}/c-wrapper
159            reinplace   "s|---|\\\\.c|" ${worksrcpath}/c-wrapper
160            reinplace   "s|&&&|${prefix}|" ${worksrcpath}/c-wrapper
161
162            reinplace   "s|@@@|${configure.cxx}|" ${worksrcpath}/cxx-wrapper
163            reinplace   "s#---#(\\\\.C|\\\\.cpp|\\\\.cc)#" \
164                ${worksrcpath}/cxx-wrapper
165            reinplace   "s|&&&|${prefix}|" ${worksrcpath}/cxx-wrapper
166
167            reinplace   "s|@@@|${configure.f90}|" ${worksrcpath}/f-wrapper
168            reinplace   "s|---|\\\\.f|" ${worksrcpath}/f-wrapper
169            reinplace   "s|&&&|${prefix}|" ${worksrcpath}/f-wrapper
170        }
171
172        if {[variant_isset atlas]} {
173            # We must link against libSatlas or libTatlas, not libAtlas
174            if {[file exists ${prefix}/lib/libtatlas.dylib]} {
175                reinplace -E \
176                    "s|_lib_atlas = \\\['atlas'\\\]|_lib_atlas = \\\['tatlas'\\\]|" \
177                    ${worksrcpath}/numpy/distutils/system_info.py
178            } elseif {[file exists ${prefix}/lib/libsatlas.dylib]} {
179                reinplace -E \
180                    "s|_lib_atlas = \\\['atlas'\\\]|_lib_atlas = \\\['satlas'\\\]|" \
181                    ${worksrcpath}/numpy/distutils/system_info.py
182            } else {
183                return -code error "Unable to find Atlas dylibs. Bailing out."
184            }
185        }
186    }
187
188    if {![fortran_variant_isset]} {
189        default_variants      +gfortran
190    }
191
192    # determine if special wrapper values are needed for compiler names
193    # a procedure is needed since variants from PortGroup compilers must
194    #    be evaluated before it can be determined if clang is being used
195    proc use_wrapper {} {
196        global configure.cc
197
198        if {[variant_isset universal]} {
199            if {[variant_isset atlas]} {
200                # uses fortran as a linker, which does not handle multile -arch values properly
201                return 1
202            }
203            if {![string match *clang* ${configure.cc}]} {
204                # gcc compilers do not handle multile -arch values properly
205                return 1
206            }
207        }
208        return 0
209    }
210
211    # set compiler names
212    proc set_compilers {} {
213        global configure.cc configure.cxx configure.fc worksrcpath
214
215        if {[use_wrapper]} {
216            # override values set in compilers PortGroup
217            configure.cc  ${worksrcpath}/c-wrapper
218            configure.cxx ${worksrcpath}/cxx-wrapper
219            configure.fc  ${worksrcpath}/f-wrapper
220            configure.f77 ${worksrcpath}/f-wrapper
221            configure.f90 ${worksrcpath}/f-wrapper
222        }
223    }
224
225    livecheck.type        none
226} else {
227    livecheck.regex       archive/[join ${github.tag_prefix} ""](\[\\d+(?:\\.\\d+)*"\]+)${extract.suffix}"
228}
Note: See TracBrowser for help on using the repository browser.