-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathsetup.py
93 lines (85 loc) · 3.75 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
import argparse
import base64
import os
import re
import sys
import setuptools
from glob import glob
def getLocalFileContent(filename):
if not os.path.isfile(filename):
return None
fileExtension = os.path.splitext(filename)[1]
if fileExtension not in ['.gif', '.jpeg', '.jpg', '.png']:
return None
with open(filename, "rb") as img_file:
return "data:image/{};base64,{}".format(fileExtension, base64.b64encode(img_file.read()).decode('utf-8'))
def expandImageFiles(content):
image_source_patterns = [
r'<\s*img\s+.*src\s*=\s*"([^"]*)".*>', # <img src="link">
r"<\s*img\s+.*src\s*=\s*'([^']*)'.*>", # <img src='link'>
r'!\s*\[.*\]\s*\((.*)\)', # 
]
current = 0
result = ""
for x in re.finditer('|'.join(image_source_patterns), content):
for i in range(len(image_source_patterns)):
filename = x.group(i)
if filename:
localContent = getLocalFileContent(filename)
if localContent:
result += content[current:x.start(i)] + localContent
current = x.end(i)
return content if current == 0 else result + content[current:]
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('--embed-readme-images', help='Transform README.md images inside the repository into base64 string ', action='store_true')
args, unknown = argparser.parse_known_args()
sys.argv = [sys.argv[0]] + unknown
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
if args.embed_readme_images:
long_description = expandImageFiles(long_description)
# Package list is autogenerated to be any 'perceval' subfolder containing a __init__.py file
package_list = [os.path.dirname(p).replace('\\', '.') for p in glob('perceval/**/__init__.py', recursive=True)]
QISKIT_BRIDGE_PKGS = ["qiskit~=1.3.1", "seaborn~=0.13"]
QUTIP_BRIDGE_PKGS = ["qutip~=5.0.4"]
MYQLM_BRIDGE_PKGS = ["myqlm~=1.10.4"]
CQASM_BRIDGE_PKGS = ["libqasm==0.6.7"] # libqasm is not stable enough to put ~=
setuptools.setup(
name="perceval-quandela",
author="quandela",
author_email="[email protected]",
description="A powerful Quantum Photonic Framework",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Quandela/Perceval",
project_urls={
"Documentation": "https://perceval.quandela.net/docs/",
"Source": "https://github.com/Quandela/Perceval",
"Tracker": "https://github.com/Quandela/Perceval/issues"
},
classifiers=[
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
packages=package_list,
install_requires=['sympy~=1.12', 'numpy>=1.26,<3', 'scipy~=1.13', 'tabulate~=0.9', 'matplotlib<4', 'exqalibur~=0.6.4',
'multipledispatch<2', 'protobuf>=3.20.3', 'drawsvg>=2.0', 'requests<3',
'networkx~=3.1', 'latexcodec<4', 'platformdirs<5', 'tqdm',
"typing_extensions; python_version == '3.9'" # TODO: remove when dropping 3.9
],
extras_require={
"qiskit_bridge": QISKIT_BRIDGE_PKGS,
"qutip_bridge": QUTIP_BRIDGE_PKGS,
"myqlm_bridge": MYQLM_BRIDGE_PKGS,
"cqasm_bridge": CQASM_BRIDGE_PKGS,
"all": QISKIT_BRIDGE_PKGS+QUTIP_BRIDGE_PKGS+MYQLM_BRIDGE_PKGS+CQASM_BRIDGE_PKGS
},
setup_requires=["scmver"],
python_requires=">=3.9,<3.14",
scmver=True
)