Files
ortools-clone/python/setup.py.in

105 lines
3.2 KiB
Python
Raw Normal View History

import os
2017-06-28 15:45:56 +05:30
from setuptools import setup, find_packages, Extension
from distutils.command.build import build as _build
class build(_build):
sub_commands = [
('build_ext', _build.has_ext_modules),
('build_py', _build.has_pure_modules),
('build_clib', _build.has_c_libraries),
('build_scripts', _build.has_scripts)]
2017-06-28 15:45:56 +05:30
SWIG_CXX_OPTS = "${CMAKE_SWIG_FLAGS}"
PROJ_INC_DIRS = ".;/usr/include;/usr/local/include"
2017-06-28 15:45:56 +05:30
MODULE_MAP = {
'pywrapcp': 'ortools/constraint_solver/python/routing.i',
'pywrapknapsack_solver': 'ortools/algorithms/python/knapsack_solver.i',
'pywrapgraph': 'ortools/graph/python/graph.i',
'pywraplp': 'ortools/linear_solver/python/linear_solver.i'
}
def split_cmake_list(lst, prefix=None):
lst_ = lst.strip().split(';')
if prefix is None:
return lst_
_lst = []
for item in lst_:
_lst.append('{}{}'.format(prefix, item))
return _lst
def get_outdir(_file):
if 'python' in _file:
return _file.split('python')[0]
return '/'.join(_file.split('/')[:-1])
2017-06-28 15:45:56 +05:30
extensions = []
for module, _file in MODULE_MAP.items():
ext = Extension(
'_{}'.format(module),
[_file],
swig_opts=split_cmake_list(SWIG_CXX_OPTS) + [
'-c++', '-I.', '-module', module] + split_cmake_list(
PROJ_INC_DIRS, '-I') + [
'-outdir', get_outdir(_file)],
include_dirs=split_cmake_list(PROJ_INC_DIRS),
libraries=['${PROJECT_NAME}'],
extra_compile_args="${CMAKE_CXX_FLAGS}".strip().split(' ')
)
extensions.append(ext)
modules = []
for module, _file in MODULE_MAP.items():
_path = os.path.dirname(_file)
_path = _path.split('python')[0]
_path = _path.split('/')
lst = []
for __path in _path:
if __path:
lst.append(__path)
lst.append(module)
modules.append('.'.join(lst))
2017-06-28 15:45:56 +05:30
with open('${README_FILE}') as f:
long_description = f.read()
setup(
name="${PROJECT_NAME}",
cmdclass={'build': build},
2017-06-28 15:45:56 +05:30
version="${PROJECT_VERSION}",
description="Google OR-Tools python libraries and modules",
long_description=long_description,
url='https://developers.google.com/optimization/',
author='${AUTHORS}',
author_email='${AUTHOR_EMAIL}',
license='${LICENSE}',
keywords = (
'operations research, constraint programming, linear programming, '
'flow algorithms, python'),
classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Office/Business :: Scheduling',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Software Development :: Libraries :: Python Modules'],
packages=find_packages(),
ext_modules=extensions,
py_modules=modules,
2017-06-28 15:45:56 +05:30
)