summaryrefslogtreecommitdiff
path: root/cad/src/experimental/pyrex_test/setup.py
blob: 3f63248f02cf2d5e6d5c9e558171db1b915b553a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 2005-2007 Nanorex, Inc.  See LICENSE file for details. 
"""
setup.py

Distutils setup file -- tells distutils how to rebuild our custom extension modules.

$Id$

This file is NOT meant to be imported directly by nE-1.

One way to run it might be "make extensions"; see Makefile in this directory.
A more direct way is to ask your shell to do

  python setup.py build_ext --inplace
  
(I don't know if that works on Windows.)

Running this makes some output files and subdirectories, and prints lots of output.
I think it only recompiles what needs to be recompiled (based on modtimes), but I'm not sure.
(I've had a hard time finding any documentation about the internal workings of distutils,
though it's easy to find basic instructions about how to use it.)

==

For now [051202], all our custom extension modules are written in Pyrex, and we have exactly one,
which is just for testing our use of Pyrex and our integration of Pyrex code into our release-building system.

For plans and status related to our use of Pyrex, see:

  http://www.nanoengineer-1.net/mediawiki/index.php?title=Integrating_Pyrex_into_the_Build_System

See README-Pyrex for the list of related files and their roles.

This is based on the Pyrex example file Pyrex-0.9.3/Demos/Setup.py.

"""
__author__ = 'bruce'

import sys
from distutils.core import setup
from distutils.extension import Extension

if (__name__ == '__main__'):
    print "running cad/src/setup.py, sys.argv is %r" % (sys.argv,) # ['setup.py', 'build_ext', '--inplace']
    # note: this is NOT the same setup.py that is run during Mac release building
    # by autoBuild.py. That one lives in Distribution or Distribution/tmp,
    # whereever you run autoBuild from. (I don't know if other platforms ever run setup.py then.)
    # [bruce 070427 comment]

    try:
        from Pyrex.Distutils import build_ext
    except:
        print "Problem importing Pyrex. You need to install Pyrex before it makes sense to run this."
        print "For more info see README-Pyrex and/or "
        print "  http://www.nanoengineer-1.net/mediawiki/index.php?title=Integrating_Pyrex_into_the_Build_System"
        print "(If you already installed Pyrex, there's a bug in your Pyrex installation or in setup.py, "
        print " since the import should have worked.)"
        sys.exit(1)
    
    setup(
      name = 'xxx', #k doc says name and version are required, but it works w/o version and with this stub name.
      ext_modules=[ 
        Extension("pyrex_test",       ["pyrex_test.pyx"]),
        ],
      cmdclass = {'build_ext': build_ext}
    )
    
    # this exit reminds people not to "import setup" from nE-1 itself!
    print "setup.py finished; exiting."
    sys.exit(0)