File: setup.py.in

package info (click to toggle)
cryptominisat 5.8.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,172 kB
  • sloc: cpp: 48,714; python: 7,597; ansic: 4,396; sh: 1,032; php: 477; sql: 369; javascript: 156; makefile: 38; xml: 34
file content (161 lines) | stat: -rw-r--r-- 5,161 bytes parent folder | download
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#
# CryptoMiniSat
#
# Copyright (c) 2009-2017, Mate Soos. All rights reserved.
# Copyright (c) 2017, Pierre Vignet
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


import sys
import os
import platform
from distutils.core import setup, Extension
from distutils import sysconfig
from distutils.cmd import Command

__PACKAGE_VERSION__ = "0.2.0"
__LIBRARY_VERSION__ = "${CMS_FULL_VERSION}"
os.environ["CC"] = "${CMAKE_C_COMPILER}"
os.environ["CXX"] = "${CMAKE_CXX_COMPILER}"

cconf = """${PY_C_CONFIG}""".split(" ")
is_apple = """${APPLE}"""


def cleanup(dat):
    ret = []
    for elem in dat:
        elem = elem.strip()
        #if is_apple != "" and "-ldl" in elem:
            #continue
        if elem != "" and not "flto" in elem:
            ret.append(elem)

    return ret

cconf = cleanup(cconf)
# print "Extra C flags from python-config:", cconf


def _init_posix(init):
    """
    Forces g++ instead of gcc on most systems
    credits to eric jones (eric@enthought.com) (found at Google Groups)
    """
    def wrapper():
        init()

        config_vars = sysconfig.get_config_vars()  # by reference
        if config_vars["MACHDEP"].startswith("sun"):
            # Sun needs forced gcc/g++ compilation
            config_vars['CC'] = 'gcc'
            config_vars['CXX'] = 'g++'

        config_vars['CFLAGS'] = '-g -W -Wall -Wno-deprecated -std=c++11'
        config_vars['OPT'] = '-g -W -Wall -Wno-deprecated -std=c++11'

    return wrapper

sysconfig._init_posix = _init_posix(sysconfig._init_posix)


class TestCommand(Command):
    """Call tests with the custom 'python setup.py test' command."""

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):

        import os
        import glob
        print("our CWD is:", os.getcwd(), "files here: ", glob.glob("*"))
        sys.path.append(os.getcwd())
        path2 = os.path.join(os.getcwd(), "..")
        path2 = os.path.join(path2, "lib")
        path2 = os.path.normpath(path2)
        print("path2 is:", path2)
        sys.path.append(path2)
        print("our sys.path is", sys.path)

        import tests as tp
        return tp.run()


__version__ = '@PROJECT_VERSION@'

# needed because Mac doesn't make use of runtime_library_dirs
extra_link_args = []
if platform.system() == 'Darwin':
    extra_link_args.append('-Wl,-rpath,'+"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
    # NOTE: below apparently could be obtained via: "xcrun --show-sdk-path"

if platform.system() == 'Windows':
    libname = "cryptominisat5win"
else:
    libname = "cryptominisat5"

modules = dict(
    name = "pycryptosat",
    sources = ["${CMAKE_CURRENT_BINARY_DIR}/src/pycryptosat.cpp"],
    define_macros = [('LIBRARY_VERSION', '"' + __LIBRARY_VERSION__ + '"')],
    extra_compile_args = cconf + ['-I${PROJECT_SOURCE_DIR}', '-I${PROJECT_BINARY_DIR}/cmsat5-src'],
    extra_link_args = extra_link_args,
    language = "c++",
    library_dirs=['.', '${PROJECT_BINARY_DIR}/lib', '${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}'],
    runtime_library_dirs=['${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}'],
    libraries = [libname]
)

if platform.system() == 'Windows':
    del modules['runtime_library_dirs']

setup(
    name = "pycryptosat",
    version = __PACKAGE_VERSION__,
    author = "Mate Soos",
    author_email = "soos.mate@gmail.com",
    url = "https://github.com/msoos/cryptominisat",
    license = "MIT",
    classifiers = [
        "Development Status :: 4 - Beta",
        "Intended Audience :: Developers",
        "Operating System :: OS Independent",
        "Programming Language :: C++",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.5",
        "License :: OSI Approved :: MIT License",
        "Topic :: Utilities",
    ],
    ext_modules =  [Extension(**modules)],
    description = "Bindings to CryptoMiniSat {} (a SAT solver)".\
        format(__LIBRARY_VERSION__),
#    py_modules = ['pycryptosat'],
    long_description = open('${CMAKE_CURRENT_SOURCE_DIR}/README.rst').read(),
    cmdclass={
        'test': TestCommand
    }

)