Skip to content

Commit 35b870b

Browse files
committed
generated with buf
1 parent 33c526f commit 35b870b

238 files changed

Lines changed: 6290 additions & 6836 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ jobs:
1515
python-version: '3.x'
1616
- name: Install dependencies
1717
run: |
18-
python -m pip install --upgrade pip
19-
pip install -r requirements.txt
18+
python -m pip install --upgrade build
2019
- name: Set VERSION environment variable
2120
run: |
2221
echo GitHub_ref: $GITHUB_REF

build.py

Lines changed: 11 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
#!/usr/bin/python
22

33
import os
4-
from pickle import FALSE
54
import subprocess
6-
import shutil
7-
8-
def create_dir_if_needed(dir):
9-
if(not(os.path.isdir(dir))):
10-
os.makedirs(dir)
115

126
def delete_dir_if_needed(top_dir):
137
if(os.path.isdir(top_dir)):
@@ -18,109 +12,20 @@ def delete_dir_if_needed(top_dir):
1812
os.rmdir(os.path.join(root, dir))
1913
os.rmdir(top_dir)
2014

21-
def is_grpc_file (path):
22-
"""Test if a *.proto file describe a grpc service"""
23-
for line in open(path, 'r').readlines() :
24-
if line.startswith('service ') :
25-
return True
26-
return False
27-
28-
def create_files_tuples(dir):
29-
"""Create the lists of files from `dir` and ventilate them in 3 categories :
30-
- grpc files (containing a grpc service)
31-
- proto files (without a grpc service)
32-
- python files
33-
34-
Returns a tuple with 3 lists.
35-
First list contains grpc files.
36-
Second list contains regular proto files
37-
Third list contains python files
38-
"""
39-
grpc_files = []
40-
proto_files = []
41-
python_files = []
42-
print(f"create_files_tuples(dir={dir})")
43-
for root, dirs, files in os.walk(dir, topdown=True):
44-
for file in files:
45-
path = os.path.join(root, file)
46-
if (file.endswith('.proto')) :
47-
if(is_grpc_file(path)) :
48-
print(f"grpc: {path}")
49-
grpc_files.append(path)
50-
else:
51-
proto_files.append(path)
52-
print(f"proto: {path}")
53-
if (file.endswith('.py')) :
54-
print(f"python: {path}")
55-
python_files.append(path)
56-
57-
return (grpc_files,proto_files,python_files)
58-
59-
def generate_grpc_file(files, scr_dir, target_dir):
60-
create_dir_if_needed(target_dir)
61-
all_files= " ".join(files)
62-
cmd = f"python3 -m grpc_tools.protoc --proto_path={scr_dir} --python_out={target_dir} --grpc_python_out={target_dir} {all_files}"
63-
print(cmd)
64-
subprocess.call(cmd, cwd=scr_dir, shell=True)
65-
66-
def generate_proto_file(files, scr_dir, target_dir):
67-
all_files= " ".join(files)
68-
create_dir_if_needed(target_dir)
69-
cmd = f"python3 -m grpc_tools.protoc --proto_path={scr_dir} --python_out={target_dir} {all_files}"
70-
print(cmd)
71-
subprocess.call(cmd, cwd=scr_dir, shell=True)
72-
73-
def copy_python_sources(files, src_dir, target_dir):
74-
create_dir_if_needed(target_dir)
75-
for file in files:
76-
file2 = file.replace(src_dir, target_dir)
77-
folder2=os.path.dirname(file2)
78-
create_dir_if_needed(folder2)
79-
print(f"Copying \n {file} to \n {file2}")
80-
shutil.copy(file, file2)
81-
82-
def generate(tuple_of_list, src_dir, target_dir):
83-
grpc_files = tuple_of_list[0]
84-
proto_files = tuple_of_list[1]
85-
python_files = tuple_of_list[2]
86-
87-
copy_python_sources(python_files, src_dir, target_dir)
88-
generate_grpc_file(grpc_files, src_dir, target_dir)
89-
generate_proto_file(proto_files, src_dir, target_dir)
90-
91-
def add_namespace_import_to_init_py(dir):
92-
for root, _, _ in os.walk(dir, topdown=True):
93-
path = os.path.join(root,'__init__.py')
94-
with open(path, 'w') as f:
95-
f.write("__import__('pkg_resources').declare_namespace(__name__)")
96-
97-
def extract_version(data):
98-
version_pattern ='version="'
99-
l = len(version_pattern)
100-
start = data.find('version="')
101-
end = data.find('"', start + l + 1)
102-
return data[start + l : end]
103-
104-
def replace_version_in_setup(dir):
15+
def update_version(dir):
10516
# Read in the file
106-
path = os.path.join(dir,'setup.py')
107-
with open(path, 'r') as file :
108-
filedata = file.read()
109-
110-
old_version = extract_version(filedata)
17+
path = os.path.join(dir,'__init__.py')
11118

112-
# Check is done before taht this env variable exists
19+
# Check is done before that this env variable exists
11320
new_version = os.getenv('VERSION', "")
114-
115-
# Replace the target string
116-
filedata = filedata.replace(old_version, new_version)
21+
print(f"__version__ = \"{new_version}\"")
11722

11823
# Write the file out again
11924
with open(path, 'w') as file:
120-
file.write(filedata)
25+
file.write(f"__version__ = \"{new_version}\"")
12126

12227
def generate_package(root_dir):
123-
cmd = "python3 setup.py sdist"
28+
cmd = "python3 -m build"
12429
subprocess.call(cmd, cwd=root_dir, shell=True)
12530

12631
def check_environement():
@@ -142,55 +47,6 @@ def check_environement():
14247
raise Exception("missing env var TWINE_PASSWORD")
14348
password = ''
14449

145-
# # used by publish_package function
146-
# key = os.getenv('PYPI_PUBLISH_INDIRECT_KEY','')
147-
# if(key == ''):
148-
# raise Exception("missing env var PYPI_PUBLISH_INDIRECT_KEY")
149-
150-
# # used by publish_package function
151-
# user = os.getenv('PYPI_USERNAME','')
152-
# if(user == ''):
153-
# raise Exception("missing env var PYPI_USERNAME")
154-
155-
# # used by publish_package function
156-
# repository = os.getenv('PYPI_REPOSITORY','')
157-
# if(repository == ''):
158-
# raise Exception("missing env var PYPI_REPOSITORY")
159-
160-
def publish_test_package(root_dir):
161-
# pass_out generated with
162-
# > echo -n ${{PASSWORD}} > ./pass
163-
# > openssl aes-256-cbc -pbkdf2 -e -k "${{PYPI_PUBLISH_INDIRECT_KEY}}" < ./pass > ./pass_out
164-
165-
# used by publish_package function
166-
key = os.getenv('PYPI_PUBLISH_INDIRECT_KEY','')
167-
if(key == ''):
168-
raise Exception("missing env var PYPI_PUBLISH_INDIRECT_KEY")
169-
170-
# used by publish_package function
171-
user = os.getenv('PYPI_USERNAME','')
172-
if(user == ''):
173-
raise Exception("missing env var PYPI_USERNAME")
174-
175-
# used by publish_package function
176-
repository = os.getenv('PYPI_REPOSITORY','')
177-
if(repository == ''):
178-
raise Exception("missing env var PYPI_REPOSITORY")
179-
180-
# convert password, as strange chars are not always accepted in env var...
181-
path = os.path.join(root_dir, "pass")
182-
path_out = os.path.join(root_dir, "..", "pass_out")
183-
openssl_cmd = f'openssl aes-256-cbc -pbkdf2 -d -k "{key}" < {path_out} > {path}'
184-
subprocess.call(openssl_cmd, cwd=root_dir, shell=True)
185-
186-
with open(path, 'r') as f:
187-
password = f.read()
188-
189-
cmd = f"python3 -m twine upload --repository {repository} dist/* -u {user} -p '{password}'"
190-
191-
os.remove(path)
192-
subprocess.call(cmd, cwd=root_dir, shell=True)
193-
19450
def publish_package(root_dir):
19551
# used by publish_package function
19652
cmd = f"python3 -m twine upload dist/*"
@@ -205,36 +61,21 @@ def main():
20561
# define vars
20662
root = os.path.dirname(os.path.realpath(__file__))
20763
src_dir = os.path.join(root, "src")
208-
out_dir = os.path.join(root, "python")
209-
stx_dir = os.path.join(out_dir, "systemathics")
210-
dist_dir = os.path.join(out_dir, "dist")
64+
stx_dir = os.path.join(src_dir, "systemathics","apis")
65+
dist_dir = os.path.join(src_dir, "dist")
21166

21267
print("Clean old generated code")
213-
create_dir_if_needed(out_dir)
214-
delete_dir_if_needed(stx_dir)
21568
delete_dir_if_needed(dist_dir)
21669

217-
# get proto files (grpc and regular)
218-
print("Get files")
219-
result = create_files_tuples(src_dir)
220-
221-
# generate new python file from proto
222-
print("Generate")
223-
generate(result, src_dir, out_dir)
224-
225-
# add proto import to __init__.py files
226-
print("Add namespace import to __init__.py files")
227-
add_namespace_import_to_init_py(stx_dir)
228-
22970
# generate package
23071
print("Setting version in setup.py")
231-
replace_version_in_setup(out_dir)
72+
update_version(stx_dir)
23273
print("Generate package")
233-
generate_package(out_dir)
74+
generate_package(src_dir)
23475

23576
# publish package
23677
print("Publish package")
237-
publish_package(out_dir)
78+
publish_package(src_dir)
23879

23980
if __name__ == "__main__":
24081
# execute only if run as a script

pass_out

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

python/setup.py

Lines changed: 0 additions & 32 deletions
This file was deleted.
File renamed without changes.

python/README.rst renamed to src/README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
About Ganymede
2-
==============
1+
# About Ganymede
32

43
Built as cloud native, Ganymede is a fully managed platform,
54
continuously updated with high-quality, curated, and cross validated
@@ -11,21 +10,19 @@ optimized for fast response times, supports full order book natively and
1110
allows fine grained/customizable trade and quote conditions mapping and
1211
filtering.
1312

14-
For further information, please visit `Ganymede home
15-
page <https://ganymede.cloud>`__
13+
For further information, please visit [Ganymede home page](https://ganymede.cloud)
1614

17-
About this package
18-
===================
15+
## About this package
1916

20-
This package provides up-to-date gRPC clients to access `Ganymede
21-
API <https://ganymede.cloud/api-documentation.html>`__
2217

23-
Python version
18+
This package provides up-to-date gRPC clients to access [Ganymede API](https://ganymede.cloud/api-documentation.html)
2419

25-
About us
26-
========
20+
Python version 3
2721

28-
`Systemathics <https://systemathics.com>`__ is a French fintech founded
22+
## About us
23+
24+
25+
[Systemathics](https://systemathics.com) is a French fintech founded
2926
in 2008 developing its innovative products with the highest quality
3027
standards 100% in France. Our main mission is to provide global
3128
investors with a complete end-to-end solution to systematize alpha

src/buf.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/buf.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/pyproject.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[build-system]
2+
requires = ["setuptools>=68.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "systemathics.apis"
7+
dynamic = ["version"]
8+
authors = [
9+
{ name="Systemathics", email="contact@systemathics.com" },
10+
]
11+
description = "Grpc stub for Systemathics API."
12+
readme = "README.md"
13+
requires-python = ">=3.7"
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"License :: OSI Approved :: MIT License",
17+
"Operating System :: OS Independent",
18+
"Intended Audience :: Developers",
19+
"Intended Audience :: Information Technology",
20+
"Intended Audience :: Science/Research"
21+
]
22+
license = {file = "LICENSE"}
23+
dependencies = [
24+
'googleapis-common-protos'
25+
]
26+
27+
[project.urls]
28+
Homepage = "https://ganymede.cloud"
29+
"Bug Tracker" = "https://github.com/systemathics/sdk-python/issues"
30+
Documentation = "https://ganymede.cloud/api-documentation.html"
31+
32+
[tool.setuptools.packages.find]
33+
where = ["."]
34+
include = ["systemathics.apis*"]
35+
36+
[tool.setuptools.dynamic]
37+
version = {attr = "systemathics.apis.__version__"}

0 commit comments

Comments
 (0)