Changeset 300 for trunk/setup.py.in


Ignore:
Timestamp:
01/17/14 14:01:25 (10 years ago)
Author:
bas
Message:

C directory is used for Torque version 2.X.
rewrite setup.py inspired by stijn de weirdt (University Gent), see #36

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/setup.py.in

    r295 r300  
    88import sys
    99import os
     10import glob
    1011
    1112from distutils.core import setup, Extension
     13from distutils.version import LooseVersion
    1214
    1315# Strip off the -L it is also added by the python setup tools
     
    2325LIBS = ['torque']
    2426
    25 ### Make symlinks to right torque version
    26 #
    2727VERSION = "@pbs_version@"
    28 tmp = VERSION.split('.')
     28SOURCE_DIR='src'
    2929
    30 major_version = int(tmp[0])
    31 minor_version = int(tmp[1])
    32 #build_version = int(tmp[2])
    33 build_version = int(tmp[2].split('-')[0])
     30os.chdir(SOURCE_DIR)
    3431
    35 
    36 os.chdir('src')
    37 
    38 ## Always unlink previous links
    39 #
    4032try:
    4133    os.unlink('pbs.py')
    42     os.unlink('pbs_wrap.c')
    4334except OSError:
    4435    pass
    4536
    46 if major_version  >= 2 and minor_version >= 4 and build_version >= 7:
    47     os.symlink('pbs_wrap_2.4.c', 'pbs_wrap.c')
    48     os.symlink('pbs_2.4.py', 'pbs.py')
    49     TORQUE_VERSION='TORQUE_2_4'
     37if LooseVersion(VERSION) >= LooseVersion('4.2'):
     38
     39    inc=os.environ.get('PBS_PYTHON_INCLUDEDIR','/usr/include/torque')
     40    os.environ['CC']='g++'
     41    os.environ['CFLAGS']=' '.join(os.environ.get('CFLAGS','').split(' ')+['-I%s'%inc])
     42   
     43    if not os.path.exists(os.path.join(inc,'log.h')):
     44        print 'Failed to find log.h in inlcude dir %s. (Set incude dir via PBS_PYTHON_INCLUDEDIR variable)'%inc
     45        sys.exit(2)
     46 
     47    for fn in glob.glob('*.h'):
     48        os.remove(fn)
     49     
     50    TORQUE_VERSION='TORQUE_4'
     51    SOURCE_FILE='src/C++/pbs_wrap.cxx'
     52
     53    os.symlink('C++/pbs.py', 'pbs.py')
     54
     55elif LooseVersion(VERSION) >= LooseVersion('2.4'):
     56
     57    TORQUE_VERSION='TORQUE_2'
     58    SOURCE_FILE='src/C/pbs_wrap.c'
     59
     60    os.symlink('C++/pbs.py', 'pbs.py')
     61
    5062else:
    51     os.symlink('pbs_wrap_2.1.c', 'pbs_wrap.c')
    52     os.symlink('pbs_2.1.py', 'pbs.py')
    53     TORQUE_VERSION='TORQUE_OLD'
     63
     64    print "Version: %s is not supported" %(VERSION)
     65    sys.exit(1)
     66
    5467
    5568os.chdir('..')
     
    5770setup (
    5871    name = 'pbs_python',
    59     version = '4.3.6',
     72    version = '4.8.0',
    6073    description = 'openpbs/torque python interface',
    6174    license = 'LGPLV3',
     
    6679
    6780    extra_path = 'pbs',
    68         package_dir = { '' : 'src' },
    69         py_modules = [ 'pbs', 'PBSQuery', 'PBSAdvancedParser' ],
     81        package_dir = { '' : SOURCE_DIR },
     82        py_modules = [ 'pbs',  'PBSQuery'],
    7083
    7184    ext_modules = [
    72         Extension( '_pbs', ['src/pbs_wrap.c'],
     85        Extension( '_pbs', [SOURCE_FILE],
    7386        library_dirs = [ PBS_LIB_DIR ],
    7487        extra_link_args = [ PBS_LIB_COMPILE_LINE ],
Note: See TracChangeset for help on using the changeset viewer.