-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
59 lines (54 loc) · 1.78 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
import subprocess
import sys
import os
from setuptools import setup
from libs.pybind11.setup_helpers import Pybind11Extension
os.environ["MACOSX_DEPLOYMENT_TARGET"] = '10.15' # needed for std::filesystem
p = subprocess.Popen("cmake pyqasm3 && make -j8 antlr4_static",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
eigen_prefix = "Detecting Eigen3 - done (in "
eigen_path = None
qpp_prefix = "Found Quantum++ in "
qpp_path = None
print("Running cmake pyqasm3")
for line in p.stdout.read().decode('ascii', 'ignore').split('\n'):
print(line)
pos = line.find(eigen_prefix)
if pos != -1:
eigen_path = line[pos + len(eigen_prefix):-1]
pos = line.find(qpp_prefix)
if pos != -1:
qpp_path = line[pos + len(qpp_prefix):]
if eigen_path is None:
raise Exception('Eigen3 not found!')
elif qpp_path is None:
raise Exception('Quantum++ not found!')
else:
qpp_path = qpp_path[:-4] # remove '/qpp' suffix
ext_modules = [
Pybind11Extension(
"pyqasm3",
["pyqasm3/qasm3_wrapper.cpp"],
extra_compile_args=["-Ilibs",
"-Iinclude",
"-iquoteantlr4cpp_runtime/runtime/src",
"-Iantlr4cpp_generated",
"-I" + eigen_path,
"-I" + qpp_path],
extra_link_args=["-Lpyqasm3/dist", "-lantlr4-runtime"],
cxx_std=17,
include_pybind11=False,
),
]
setup(
name='pyqasm3',
version='0.1',
description='Python 3 wrapper for qasm3tools',
author='softwareQ',
author_email='info@softwareq.ca',
url='https://github.com/softwareQinc/qasm3tools',
license='MIT',
platforms=sys.platform,
ext_modules=ext_modules)