473,695 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
version.

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
  3.  
  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. )
  11.  
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_DEPLOYME NT_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
fine).

The issues:

- distutils.ccomp iler 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:
_main
_PyInt_FromLong
_PyObject_GetAt trString
_PyObject_HasAt trString
_PyObject_SetAt trString
_PyString_AsStr ing
_PyString_FromS tring
_PyTuple_New
_PyTuple_SetIte m
__Py_NoneStruct
Traceback (most recent call last):
File "run.py", line 7, in ?
parser = calc.Parser(ver bose=1, keepfiles=1)
File ". . ./python2.3/site-packages/bison.py", line 308,
in __init__ self.engine = ParserEngine(se lf)
File "bison_.pyx ", line 187, in bison_.ParserEn gine.__init__
File "bison_.pyx ", line 202, in
bison_.ParserEn gine.openCurren tLib
File "bison_.pyx ", line 540, in bison_.ParserEn gine.buildLib
File ". . ./python2.3/distutils/ccompiler.py", line 843,
in link_shared_obj ect extra_preargs, extra_postargs,
build_temp, target_lang)
File ". . ./python2.3/distutils/unixccompiler.p y", line 178,
in link raise LinkError, msg
distutils.error s.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,

Maarten

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

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

Similar topics

3
1973
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 system for "3rd party" Haskell libraries (those not distributed with the compilers). Python's Distutils has come up a few times. The Haskell Library Infrastructure Project's web page is just a wiki page which can be found here:...
1
2654
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: setup.py /bin/
15
4119
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: * Distutils-1.0.2.tar.gz (source distribution) (233k) * Distutils-1.0.2.zip (source distribution) (274k) * Distutils-1.0.2.win32.exe (Windows installer) (187k)
1
1717
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 this for me, and so far, it works very well, so I'm trying to make it easier to use and available to more developers. There is a brief (and somewhat dated) tutorial explaining what BuildImage itself does at:
7
2302
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: /usr/local/lib/python2.4/lib/site-packages/foo/bar.txt How do I figure out the rest, if I know foo/bar.txt? sys.prefix doesn't get me far. I've googled, and looked in the python reference. I must be blind if the
1
2149
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 more complicated than usual. Looking at the options for the bdist_wininst command to distutils, I see it's possible to specify --install-script=<myinstallscript> which ought to do the trick. But to use this, myinstallscript itself must first be...
6
2343
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, PyObject *args){ int n, input; if (!PyArg_ParseTuple(args, "i", &input))
7
4287
by: vedrandekovic | last post by:
Hello again, Is there any patch for python "distutils", for this ImportError: cannot import name log Regards, Vedran
0
1463
by: newbie73 | last post by:
OS: Vista Python 2.5.2.2 (ActiveState Software Installation) Running latest Cygwin release The error generated is pasted below - please help. - Luis ***************************************
0
8623
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8977
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8839
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5837
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2997
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1971
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.