From 2ea17c3f1e7a4a554022c1103551476588d989b5 Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Thu, 7 Mar 2024 09:59:27 +0100 Subject: [PATCH 1/6] bump deps --- api/py/requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/py/requirements.txt b/api/py/requirements.txt index ad35afec1f..77bfb1649e 100644 --- a/api/py/requirements.txt +++ b/api/py/requirements.txt @@ -1,4 +1,4 @@ -numpy==1.25.2 -setuptools==68.1.2 -setuptools_rust==1.6.0 +numpy==1.26.4 +setuptools==69.1.1 +setuptools_rust==1.9.0 toml==0.10.2 From a3d41f3100d2a5614461a3ff908b20ea6ac8b3db Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Thu, 7 Mar 2024 11:21:35 +0100 Subject: [PATCH 2/6] wip --- api/py/.gitignore | 1 + api/py/MANIFEST.in | 1 + api/py/requirements.txt | 1 + api/py/setup.py | 12 ++++++++++-- 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 api/py/MANIFEST.in diff --git a/api/py/.gitignore b/api/py/.gitignore index 0c0190c6d7..4cefc3f1c7 100644 --- a/api/py/.gitignore +++ b/api/py/.gitignore @@ -4,4 +4,5 @@ __pycache__ *.onnx build mobilenet_v2_1.0.onnx.nnef.tgz +rust-workspace diff --git a/api/py/MANIFEST.in b/api/py/MANIFEST.in new file mode 100644 index 0000000000..86f21c5743 --- /dev/null +++ b/api/py/MANIFEST.in @@ -0,0 +1 @@ +graft rust-workspace diff --git a/api/py/requirements.txt b/api/py/requirements.txt index 77bfb1649e..8892ad6bb7 100644 --- a/api/py/requirements.txt +++ b/api/py/requirements.txt @@ -1,4 +1,5 @@ numpy==1.26.4 +shtools==3.12.2 setuptools==69.1.1 setuptools_rust==1.9.0 toml==0.10.2 diff --git a/api/py/setup.py b/api/py/setup.py index 3ca3a97d42..340557af24 100644 --- a/api/py/setup.py +++ b/api/py/setup.py @@ -1,9 +1,17 @@ from setuptools import setup from setuptools_rust import Binding, RustExtension +import shutil import toml import re -version = toml.load("../Cargo.toml")["package"]["version"] +shutil.copytree( + "../..", + "rust-workspace", + ignore = shutil.ignore_patterns(".cached", "target", "rust-workspace", ".git", "issue-*", "cli", "api/py/*"), + dirs_exist_ok = True +) + +version = toml.load("rust-workspace/api/Cargo.toml")["package"]["version"] version = re.sub("\-alpha\.", "a", version) version = re.sub("\-.*", ".dev", version) @@ -38,7 +46,7 @@ "License :: OSI Approved :: Apache Software License", "License :: OSI Approved :: MIT License" ], - rust_extensions=[RustExtension("tract.tract", binding=Binding.NoBinding, path="../ffi/Cargo.toml")], + rust_extensions=[RustExtension("tract.tract", binding=Binding.NoBinding, path="rust-workspace/api/ffi/Cargo.toml")], packages=["tract"], zip_safe=False, python_requires=">=3.7", From 177a170332068d7ddef9b82dae5a82ef7e32f25b Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Thu, 7 Mar 2024 11:50:18 +0100 Subject: [PATCH 3/6] include tract source in package --- api/py/.gitignore | 1 + api/py/requirements.txt | 1 - api/py/setup.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/py/.gitignore b/api/py/.gitignore index 4cefc3f1c7..ddf184b451 100644 --- a/api/py/.gitignore +++ b/api/py/.gitignore @@ -5,4 +5,5 @@ __pycache__ build mobilenet_v2_1.0.onnx.nnef.tgz rust-workspace +dist diff --git a/api/py/requirements.txt b/api/py/requirements.txt index 8892ad6bb7..77bfb1649e 100644 --- a/api/py/requirements.txt +++ b/api/py/requirements.txt @@ -1,5 +1,4 @@ numpy==1.26.4 -shtools==3.12.2 setuptools==69.1.1 setuptools_rust==1.9.0 toml==0.10.2 diff --git a/api/py/setup.py b/api/py/setup.py index 340557af24..0c7e87f575 100644 --- a/api/py/setup.py +++ b/api/py/setup.py @@ -7,7 +7,7 @@ shutil.copytree( "../..", "rust-workspace", - ignore = shutil.ignore_patterns(".cached", "target", "rust-workspace", ".git", "issue-*", "cli", "api/py/*"), + ignore = shutil.ignore_patterns(".cached", "target", ".git", "issue-*", "cli", "py", ".travis", "assets"), dirs_exist_ok = True ) From 5078bc8819874e7d7dac358f5959234ed56d4c2b Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Thu, 7 Mar 2024 12:00:46 +0100 Subject: [PATCH 4/6] retro comp --- api/py/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/py/setup.py b/api/py/setup.py index 0c7e87f575..32bf368949 100644 --- a/api/py/setup.py +++ b/api/py/setup.py @@ -4,11 +4,11 @@ import toml import re +shutil.rmtree("rust-workspace") shutil.copytree( "../..", "rust-workspace", - ignore = shutil.ignore_patterns(".cached", "target", ".git", "issue-*", "cli", "py", ".travis", "assets"), - dirs_exist_ok = True + ignore = shutil.ignore_patterns(".cached", "target", ".git", "issue-*", ".travis", "assets", ".github") ) version = toml.load("rust-workspace/api/Cargo.toml")["package"]["version"] From bc101e2483bb69b07030e8629b5aa76059af14f8 Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Thu, 7 Mar 2024 13:35:09 +0100 Subject: [PATCH 5/6] fix rust code copy --- api/py/setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/py/setup.py b/api/py/setup.py index 32bf368949..0640afa3a2 100644 --- a/api/py/setup.py +++ b/api/py/setup.py @@ -3,12 +3,15 @@ import shutil import toml import re +import os + +if os.path.exists("rust-workspace"): + shutil.rmtree("rust-workspace") -shutil.rmtree("rust-workspace") shutil.copytree( "../..", "rust-workspace", - ignore = shutil.ignore_patterns(".cached", "target", ".git", "issue-*", ".travis", "assets", ".github") + ignore = shutil.ignore_patterns(".cached", "target", ".git", "issue-*", ".travis", "assets", ".github", "py") ) version = toml.load("rust-workspace/api/Cargo.toml")["package"]["version"] From 10c7ddd728ab7d80a4a5e1b68466c44f10ada4f8 Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Thu, 7 Mar 2024 17:00:14 +0100 Subject: [PATCH 6/6] rework copy so it happens only the first time (really ugly) --- api/py/MANIFEST.in | 1 + api/py/setup.py | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/api/py/MANIFEST.in b/api/py/MANIFEST.in index 86f21c5743..4ec41f1db1 100644 --- a/api/py/MANIFEST.in +++ b/api/py/MANIFEST.in @@ -1 +1,2 @@ graft rust-workspace +graft docs diff --git a/api/py/setup.py b/api/py/setup.py index 0640afa3a2..2baa5f1ab1 100644 --- a/api/py/setup.py +++ b/api/py/setup.py @@ -5,14 +5,12 @@ import re import os -if os.path.exists("rust-workspace"): - shutil.rmtree("rust-workspace") - -shutil.copytree( +if not os.path.exists("rust-workspace"): + shutil.copytree( "../..", "rust-workspace", ignore = shutil.ignore_patterns(".cached", "target", ".git", "issue-*", ".travis", "assets", ".github", "py") -) + ) version = toml.load("rust-workspace/api/Cargo.toml")["package"]["version"] version = re.sub("\-alpha\.", "a", version)