forked from dwavesystems/minorminer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
104 lines (82 loc) · 3.23 KB
/
setup.py
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
from setuptools import setup, extension
from setuptools.command.build_ext import build_ext
import sys
import os
import platform
cwd = os.path.abspath(os.path.dirname(__file__))
if not os.path.exists(os.path.join(cwd, 'PKG-INFO')):
try:
from Cython.Build import cythonize
USE_CYTHON = True
except ImportError:
USE_CYTHON = False
else:
USE_CYTHON = False
_PY2 = sys.version_info.major == 2
# Change directories so this works when called from other locations. Useful in build systems that build from source.
setup_folder_loc = os.path.dirname(os.path.abspath(__file__))
os.chdir(setup_folder_loc)
# Add __version__, __author__, __authoremail__, __description__ to this namespace
path_to_package_info = os.path.join('.', 'minorminer', 'package_info.py')
if _PY2:
execfile(path_to_package_info)
else:
exec(open(path_to_package_info).read())
extra_compile_args = {
'msvc': ['/std:c++latest', '/MT', '/EHsc'],
'unix': ['-std=c++11', '-Wextra', '-Wno-format-security', '-Ofast', '-fomit-frame-pointer', '-DNDEBUG', '-fno-rtti'],
}
extra_link_args = {
'msvc': [],
'unix': ['-std=c++11'],
}
if '--debug' in sys.argv or '-g' in sys.argv or 'CPPDEBUG' in os.environ:
extra_compile_args['msvc'].append('/DCPPDEBUG')
extra_compile_args['unix'] = ['-std=c++1y', '-w',
'-O0', '-g', '-fipa-pure-const', '-DCPPDEBUG']
class build_ext_compiler_check(build_ext):
def build_extensions(self):
compiler = self.compiler.compiler_type
compile_args = extra_compile_args[compiler]
for ext in self.extensions:
ext.extra_compile_args = compile_args
link_args = extra_compile_args[compiler]
for ext in self.extensions:
ext.extra_compile_args = link_args
build_ext.build_extensions(self)
class Extension(extension.Extension, object):
pass
ext = '.pyx' if USE_CYTHON else '.cpp'
extensions = [Extension(
name="minorminer._minorminer",
sources=["./minorminer/_minorminer" + ext],
include_dirs=['', './include/'],
language='c++',
)]
if USE_CYTHON:
extensions = cythonize(extensions)
os.environ["MACOSX_DEPLOYMENT_TARGET"] = platform.mac_ver()[0]
classifiers = [
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
]
python_requires = '>=3.5'
setup(
name="minorminer",
description=__description__,
long_description="minorminer is a tool for finding graph minors, developed to embed Ising problems onto quantum annealers (QA). Where it can be used to find minors in arbitrary graphs, it is particularly geared towards the state of the art in QA: problem graphs of a few to a few hundred variables, and hardware graphs of a few thousand qubits.",
author=__author__,
author_email=__authoremail__,
url="https://github.com/dwavesystems/minorminer",
version=__version__,
license="Apache 2.0",
ext_modules=extensions,
packages=['minorminer'],
classifiers=classifiers,
python_requires=python_requires,
cmdclass={'build_ext': build_ext_compiler_check}
)