swiginac

Mark Brethen mark.brethen at gmail.com
Fri Nov 13 22:54:43 PST 2015


> On Nov 13, 2015, at 11:03 PM, Joshua Root <jmr at macports.org> wrote:
> 
> On 2015-11-14 15:25 , Mark Brethen wrote:
>> I’d like to write a port file for swiginac. The install notes indicate it can be installed using python distutils or make. The python setup file was written for version 2.4, I’d like to use it with 2.7. I did not find a configure script and the Makefile does not use the CC, etc. variables, so will have to be patched.
>> 
>> This is my first attempt at writing a portfile for python. In addition to the Python wiki, are there other guides I should read before I begin?
> 
> An old setup.py has a fairly good chance of still working fine with
> python 2.7. You could try generating an initial Portfile with pypi2port;
> the result will not be perfect but it saves some work.
> 
> The python portgroup documentation is at
> <http://guide.macports.org/#reference.portgroup.python>.
> 
> - Josh

After running pypi2port and further tweeking I have the Portfile:

PortSystem          1.0
PortGroup           python 1.0

name                py-swiginac
version             1.5.1.1
platforms           darwin
license             GPL
maintainers         nomaintainer

description         interface to GiNaC providing Python with symbolic mathematics
long_description    ${description}

homepage            none
master_sites        sourceforge:swiginac.berlios
distname            swiginac-${version}
extract.suffix      .tgz
checksums           md5     f1ca51b766eeb7a46967507fbf9cb31d \
                    sha1    d3067a31686466580b589c6bb184ec494bf740a5 \
                    rmd160  9b473942a8a4b010ddd4d51ec19b84d3f83a2c5c

python.versions     27

depends_build       port:pkgconfig

depends_lib-append  port:GiNaC \
                    port:swig

if {${name} ne ${subport}} {
    depends_build-append \
                        port:py${python.version}-setuptools

    livecheck.type      none
} else {
    livecheck.type      regex
    livecheck.url       ${master_sites}
}


However, I’m getting the following build error:

:debug:build Environment: 
CC='/usr/bin/clang'
CC_PRINT_OPTIONS='YES'
CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_Users_marbre_ports_python_py-swiginac/py27-swiginac/work/.CC_PRINT_OPTIONS'
CFLAGS='-arch x86_64'
CPATH='/opt/local/include'
CXX='/usr/bin/clang++'
CXXFLAGS='-arch x86_64'
F90FLAGS='-m64'
FCFLAGS='-m64'
FFLAGS='-m64'
LDFLAGS='-arch x86_64'
LIBRARY_PATH='/opt/local/lib'
MACOSX_DEPLOYMENT_TARGET='10.10'
OBJC='/usr/bin/clang'
OBJCFLAGS='-arch x86_64'
:debug:build Assembled command: 'cd "/opt/local/var/macports/build/_Users_marbre_ports_python_py-swiginac/py27-swiginac/work/swiginac-1.5.1.1" && /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 setup.py --no-user-cfg build'
:debug:build Executing command line:  cd "/opt/local/var/macports/build/_Users_marbre_ports_python_py-swiginac/py27-swiginac/work/swiginac-1.5.1.1" && /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 setup.py --no-user-cfg build 
:info:build running build
:info:build running build_py
:info:build file swiginac.py (for module swiginac) not found
:info:build file swiginac.py (for module swiginac) not found
:info:build running build_ext
:info:build building '_swiginac' extension
:info:build swigging swiginac.i to swiginac_wrap.c
:info:build swig -python -o swiginac_wrap.c swiginac.i
:info:build /opt/local/share/swig/3.0.7/python/std_common.i:73: Error: Syntax error in input(1).
:info:build error: command 'swig' failed with exit status 1
:info:build Command failed:  cd "/opt/local/var/macports/build/_Users_marbre_ports_python_py-swiginac/py27-swiginac/work/swiginac-1.5.1.1" && /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 setup.py --no-user-cfg build 
:info:build Exit code: 1
:error:build org.macports.build for port py27-swiginac returned: command execution failed
:debug:build Error code: CHILDSTATUS 98534 1
:debug:build Backtrace: command execution failed
    while executing
"system -nice 0 $fullcmdstring"
    ("eval" body line 1)
    invoked from within
"eval system $notty $nice \$fullcmdstring"
    invoked from within
"command_exec build"
    (procedure "portbuild::build_main" line 8)
    invoked from within
"portbuild::build_main org.macports.build"
    ("eval" body line 1)
    invoked from within
"eval $procedure $targetname"


Below is the setup.py file:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Standard setup.py file using Python's native distutils module for installation.
Make sure that you have at least SWIG version 1.3.24 and GiNaC version 1.5.1.

To build and install swiginac, type:
python setup.py build
python setup.py install

To check your installation, change directory to ./tests/swiginac, and run 
python checkall.py

Ola Skavhaug
Ondrej Certik
Åsmund Ødegård
"""

from distutils.core import setup, Extension
import distutils
from  sys import argv, exit
import os
from os.path import join as pjoin, sep as psep
import commands

def pkgconfig(*packages, **kw):
    """
    Use pkgconfig to find out where ginac is installed. Function found here:
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502261.
    Modified by Skavhaug 2008 to better catch errors.
    """
    flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
    output = commands.getoutput("pkg-config --libs --cflags %s" % ' '.join(packages))
    if "not found" in output:
        exit(1)

    for token in output.split():
        if token[:2] != "-W":
            kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
    return kw

os.chdir(pjoin("src", "swiginac"))

# The command line argument for running swig in c++ mode has changed from
# Python 2.3 to 2.4. We support both.
swig_opt = '--swig-cpp'
if distutils.__version__ >= '2.4': swig_opt = '--swig-opts=-c++'

if argv[1] == 'build':
    argv[1] = 'build_ext'
if argv[1] == 'build_ext':
    argv.insert(2, swig_opt)
    
e = Extension(name='_swiginac',
              sources=['swiginac.i'],
              **pkgconfig("ginac")
             )

setup(name='swiginac',
    version='1.5.1',
    description='interface to GiNaC, providing Python with symbolic mathematics',
    author='Ola Skavhaug',
    author_email='skavhaug at simula.no',
    url='http://swiginac.berlios.de/',
    ext_modules=[e],
    py_modules= ['swiginac'],
    )

os.chdir(os.pardir)

setup(name='Symbolic',
    version='0.3',
    description='Higher level mathematics module',
    author='Ola Skavhaug',
    author_email='skavhaug at simula.no',
    url='http://swiginac.berlios.de/',
    packages=["Symbolic"]
    )


Mark






More information about the macports-dev mailing list