472,790 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,790 software developers and data experts.

distutils, PyBison and Mac OS X

I'm trying to build PyBison[1] on Mac OS X, and I'm running into some
problems with the distutils.

Just for starters: PyBison requires Pyrex[2]. This is not a problem,
and Pyrex seems to work without problems, at least the primes sample
module shows a nice 25 to 30 fold speed increase over the pure python

I used the distutils to create the module from the primes.pyx sample,
following the setup.py from the PyBison distrubution:

Expand|Select|Wrap|Line Numbers
  1. from distutils.core import setup, Extension
  2. from Pyrex.Distutils import build_ext
  4. setup( name = "primes", version = "1.0",
  5. description="Pyrex sample for calculating prime numbers",
  6. author='Greg Ewing',
  7. url='http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/',
  8. ext_modules=[Extension("primes", ["primes.pyx"])],
  9. cmdclass = {'build_ext': build_ext}
  10. )
I mention this, because PyBison seems to use the distutils to compile
the bison and flex source code on the fly, but fails to pick up some
parameters, which prevents it from working correctly.

Although Mac OS X uses gcc, and is an otherwise pretty complete unix
install, it is missing some components: shared libraries are not
linked with -shared but use -bundle instead. A succesful build of
primes is linked with:

export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -Wl,-F. -Wl,-F. \
-bundle -undefined dynamic_lookup \
build/temp.darwin-7.9.0-Power_Macintosh-2.3/primes.o \
-o primes.so

(Another difference that caused major headaches: the absense of a
'dl' library has been resolved with version 10.3 ("Panther"). A dl
library is included as a wrapper around the bundles mechanism that
were present all along. Since the linux version uses the dl library,
I tried to compile the same source, and that part seems to run just

The issues:

- distutils.ccompiler uses the unixcompiler, which has hard coded a
cc -shared to create shared objects. I've tried to override this,
but no luck there (other issues seem to crop up). Is this a known
issue with distutils?

I installed pybison using the linux C-source, and tried it out
using the 'calc' example. After setting verbose=1 in the run.py,
and enabling the "int lineno = 0" in calc.py, the compilation phase
finishes without a hitch, but linking fails badly:

bisonCmd=['bison', '-d', '-v', '-t', 'tmp.y']
renaming bison output files
tmp.tab.c => tmp.bison.c
tmp.tab.h => tokens.h
cc: unrecognized option `-shared'
ld: Undefined symbols:
Traceback (most recent call last):
File "run.py", line 7, in ?
parser = calc.Parser(verbose=1, keepfiles=1)
File ". . ./python2.3/site-packages/bison.py", line 308,
in __init__ self.engine = ParserEngine(self)
File "bison_.pyx", line 187, in bison_.ParserEngine.__init__
File "bison_.pyx", line 202, in
File "bison_.pyx", line 540, in bison_.ParserEngine.buildLib
File ". . ./python2.3/distutils/ccompiler.py", line 843,
in link_shared_object extra_preargs, extra_postargs,
build_temp, target_lang)
File ". . ./python2.3/distutils/unixccompiler.py", line 178,
in link raise LinkError, msg
distutils.errors.LinkError: command 'cc' failed with exit status 1

- Would it be possible to modify PyBison to use a call to the
distutils.core.setup(. . .) function and call that as if 'python
setup.py build_ext --inplace' had been called from the command line,
since that seems to pick up the correct options.

- Where do I start: distutils is pretty large, and it seems to have
the right options, but they just aren't used in PyBison.

Thanks in advance for any insights that get me going,


[1] http://www.freenet.org.nz/python/pybison/
[2] http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
Jul 19 '05 #1
0 1790

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Isaac Jones | last post by:
Hello Python Community. I bring greetings from the Haskell community (http://www.haskell.org) ;) There has been a lot of discussion of late about creating a grand-unified build & distribution...
by: Mathieu Malaterre | last post by:
Hello, I thought this would be easy but I guess I didn't get the distutil feeling. I am trying to write a setup for install my package but I don't understand how to do that. organisation: ...
by: Colin J. Williams | last post by:
The distutils download page has: -------------------------------------------------------- Current stable release The current stable release is Distutils 1.0.2; you can download it as: *...
by: Terry Hancock | last post by:
Some time ago, I got the idea that I wanted to build image resources from vector graphic originals, instead of marshalling hundreds of tiny little icon images by hand. I wrote "BuildImage" to do...
by: Frans Englich | last post by:
This is silly. How do I access data files I've installed with distutils? In a portable, generic way, I want to find out what is the following path on most systems: ...
by: George van den Driessche | last post by:
Hi folks, I'm looking at packaging a project I'm working on using distutils. The project is for Windows and contains a COM server which needs registration, so the installer needs to be a little...
by: ajikoe | last post by:
Hello I tried to combine c++ and python together. So I follow from this website: http://kortis.to/radix/python_ext/ I have this code: # prmodule.c static PyObject *pr_isprime(PyObject *self,...
by: vedrandekovic | last post by:
Hello again, Is there any patch for python "distutils", for this ImportError: cannot import name log Regards, Vedran
by: newbie73 | last post by:
OS: Vista Python (ActiveState Software Installation) Running latest Cygwin release The error generated is pasted below - please help. - Luis ***************************************
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.