2018-07-15 00:01:37 +02:00
|
|
|
|
|
|
|
|
from distutils.core import setup, Extension, Distribution
|
|
|
|
|
import glob
|
2018-07-15 00:30:12 +02:00
|
|
|
import os
|
|
|
|
|
import sysconfig
|
2018-07-15 00:01:37 +02:00
|
|
|
|
2018-07-15 00:30:12 +02:00
|
|
|
class Config(object):
|
2018-07-15 00:01:37 +02:00
|
|
|
|
2018-07-15 00:30:12 +02:00
|
|
|
def __init__(self):
|
2018-07-15 00:01:37 +02:00
|
|
|
|
2018-07-15 00:42:18 +02:00
|
|
|
# TODO: is this really how we get the build paths?
|
|
|
|
|
|
2018-07-15 00:30:12 +02:00
|
|
|
build_cmd = Distribution().get_command_obj('build')
|
|
|
|
|
build_cmd.finalize_options()
|
|
|
|
|
self.build_platlib = build_cmd.build_platlib
|
2018-07-15 00:01:37 +02:00
|
|
|
|
2018-07-15 00:42:18 +02:00
|
|
|
install_cmd = Distribution().get_command_obj('install')
|
|
|
|
|
install_cmd.finalize_options()
|
|
|
|
|
self.install_platlib = install_cmd.install_platlib
|
|
|
|
|
|
2018-07-15 00:30:12 +02:00
|
|
|
self.ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
|
|
|
|
|
|
|
|
|
|
def libname_of(self, mod):
|
|
|
|
|
return mod + self.ext_suffix
|
|
|
|
|
|
|
|
|
|
def path_of(self, mod):
|
|
|
|
|
return os.path.join(self.build_platlib, "klayout", self.libname_of(mod))
|
|
|
|
|
|
|
|
|
|
def rpath(self):
|
2018-07-15 00:42:18 +02:00
|
|
|
return [ os.path.join(self.install_platlib, "klayout") ]
|
2018-07-15 00:30:12 +02:00
|
|
|
|
|
|
|
|
def link_args(self, mod):
|
2018-07-15 00:42:18 +02:00
|
|
|
if os.name == "nt":
|
|
|
|
|
return [ ]
|
|
|
|
|
else:
|
|
|
|
|
# this makes the libraries suitable for linking with a path -
|
|
|
|
|
# i.e. from path_of('_tl')
|
|
|
|
|
return ['-Wl,-soname,' + self.libname_of(mod)]
|
2018-07-15 00:30:12 +02:00
|
|
|
|
|
|
|
|
config = Config()
|
2018-07-15 00:01:37 +02:00
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
macros = [ ('HAVE_CURL', 1), ('HAVE_EXPAT', 1) ]
|
|
|
|
|
|
|
|
|
|
_tl_sources = glob.glob("src/tl/tl/*.cc")
|
|
|
|
|
|
|
|
|
|
# Exclude sources which are compatible with Qt only
|
|
|
|
|
_tl_sources.remove("src/tl/tl/tlHttpStreamQt.cc")
|
|
|
|
|
_tl_sources.remove("src/tl/tl/tlFileSystemWatcher.cc")
|
|
|
|
|
_tl_sources.remove("src/tl/tl/tlDeferredExecutionQt.cc")
|
|
|
|
|
|
|
|
|
|
_tl = Extension('klayout._tl',
|
|
|
|
|
define_macros = macros + [ ('MAKE_TL_LIBRARY', 1) ],
|
|
|
|
|
language = 'c++',
|
|
|
|
|
libraries = [ 'curl', 'expat' ],
|
2018-07-15 00:30:12 +02:00
|
|
|
extra_link_args = config.link_args('_tl'),
|
2018-07-15 00:01:37 +02:00
|
|
|
sources = _tl_sources)
|
|
|
|
|
|
|
|
|
|
_gsi_sources = glob.glob("src/gsi/gsi/*.cc")
|
|
|
|
|
|
|
|
|
|
_gsi = Extension('klayout._gsi',
|
|
|
|
|
define_macros = macros + [ ('MAKE_GSI_LIBRARY', 1) ],
|
|
|
|
|
include_dirs = [ 'src/tl/tl' ],
|
2018-07-15 00:30:12 +02:00
|
|
|
extra_objects = [ config.path_of('_tl') ],
|
|
|
|
|
runtime_library_dirs = config.rpath(),
|
2018-07-15 00:01:37 +02:00
|
|
|
language = 'c++',
|
2018-07-15 00:30:12 +02:00
|
|
|
extra_link_args = config.link_args('_gsi'),
|
2018-07-15 00:01:37 +02:00
|
|
|
sources = _gsi_sources)
|
|
|
|
|
|
|
|
|
|
_pya_sources = glob.glob("src/pya/pya/*.cc")
|
|
|
|
|
|
|
|
|
|
_pya = Extension('klayout._pya',
|
|
|
|
|
define_macros = macros + [ ('MAKE_PYA_LIBRARY', 1) ],
|
|
|
|
|
include_dirs = [ 'src/tl/tl', 'src/gsi/gsi' ],
|
2018-07-15 00:30:12 +02:00
|
|
|
extra_objects = [ config.path_of('_tl'), config.path_of('_gsi') ],
|
|
|
|
|
runtime_library_dirs = config.rpath(),
|
2018-07-15 00:01:37 +02:00
|
|
|
language = 'c++',
|
2018-07-15 00:30:12 +02:00
|
|
|
extra_link_args = config.link_args('_pya'),
|
2018-07-15 00:01:37 +02:00
|
|
|
sources = _pya_sources)
|
|
|
|
|
|
|
|
|
|
tl_sources = glob.glob("src/pymod/tl/*.cc")
|
|
|
|
|
|
|
|
|
|
tl = Extension('klayout.tl',
|
|
|
|
|
define_macros = macros,
|
|
|
|
|
include_dirs = [ 'src/tl/tl', 'src/gsi/gsi', 'src/pya/pya' ],
|
2018-07-15 00:30:12 +02:00
|
|
|
extra_objects = [ config.path_of('_tl'), config.path_of('_gsi'), config.path_of('_pya') ],
|
|
|
|
|
runtime_library_dirs = config.rpath(),
|
2018-07-15 00:01:37 +02:00
|
|
|
sources = tl_sources)
|
|
|
|
|
|
2018-07-15 00:42:18 +02:00
|
|
|
setup (name = 'klayout',
|
2018-07-15 00:01:37 +02:00
|
|
|
version = '0.26',
|
|
|
|
|
description = 'KLayout standalone Python package',
|
|
|
|
|
author = 'Matthias Koefferlein',
|
|
|
|
|
author_email = 'matthias@klayout.de',
|
|
|
|
|
ext_modules = [ _tl, _gsi, _pya, tl ])
|