-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathsetup.py
More file actions
84 lines (75 loc) · 3.34 KB
/
setup.py
File metadata and controls
84 lines (75 loc) · 3.34 KB
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
import os
import re
import setuptools
import subprocess
from glob import glob
def getRemoteRoot():
base = 'https://raw.githubusercontent.com/Quandela/Perceval/'
git_command = subprocess.run(["git", "describe", "--tags", "--exact-match"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
universal_newlines=True)
if git_command.returncode == 0:
return base + 'refs/tags/' + git_command.stdout.strip() + '/'
# Not a tag. Should we raise a warning?
git_command = subprocess.run(["git", "rev-parse", "HEAD"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
universal_newlines=True)
if git_command.returncode == 0:
return base + git_command.stdout.strip() + '/'
# Some git error, leave path unchanged
return None
def addRemoteRootToImages(content, root):
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 and os.path.isfile(filename):
result += content[current:x.start(i)] + root + content[x.start(i):x.end(i)]
current = x.end(i)
return content if current == 0 else result + content[current:]
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
root = getRemoteRoot()
if root:
long_description = addRemoteRootToImages(long_description, root)
# 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)]
setuptools.setup(
name="perceval-quandela",
author="quandela",
author_email="perceval@quandela.com",
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.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"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~=1.1.0',
'multipledispatch<2', 'protobuf>=3.20.3', 'drawsvg>=2.0', 'requests<3',
'networkx>=3.1,<4', 'latexcodec<4', 'platformdirs<5', 'tqdm'
],
setup_requires=["scmver"],
python_requires=">=3.10,<3.15",
scmver=True
)