diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 09dc6c4..a24a7ad 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -125,5 +125,4 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} run: | - cd actuator/robstride - cargo publish + cargo publish -p robstride diff --git a/.gitignore b/.gitignore index 88e541b..8dfcfb1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ __pycache__/ .pytest_cache/ .ruff_cache/ .dmypy.json +*.pyi # Databases *.db diff --git a/actuator/bindings.pyi b/actuator/bindings.pyi deleted file mode 120000 index 99c2419..0000000 --- a/actuator/bindings.pyi +++ /dev/null @@ -1 +0,0 @@ -bindings/bindings.pyi \ No newline at end of file diff --git a/actuator/bindings/.gitignore b/actuator/bindings/.gitignore deleted file mode 100644 index f7eab8d..0000000 --- a/actuator/bindings/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# .gitignore - -*.pyi diff --git a/actuator/bindings/Cargo.toml b/actuator/bindings/Cargo.toml index 7b43db2..f19691d 100644 --- a/actuator/bindings/Cargo.toml +++ b/actuator/bindings/Cargo.toml @@ -18,12 +18,6 @@ crate-type = ["cdylib", "rlib"] pyo3 = { version = ">= 0.21.0", features = ["extension-module"] } pyo3-stub-gen = ">= 0.6.0" -tokio = { version = "1.28.0", features = ["full"] } -async-trait = "0.1.68" -futures = "0.3" -log = "0.4" -env_logger = "0.11.5" -serialport = "4.5.1" # Other packages in the workspace. robstride = { path = "../robstride" } diff --git a/actuator/bindings/pyproject.toml b/actuator/bindings/pyproject.toml index 4117fe1..ea7be96 100644 --- a/actuator/bindings/pyproject.toml +++ b/actuator/bindings/pyproject.toml @@ -5,6 +5,3 @@ build-backend = "maturin" [project] name = "bindings" requires-python = ">=3.9" - -[project.optional-dependencies] -test = ["pytest", "pyright", "ruff"] diff --git a/setup.py b/setup.py index ddca7a9..537a72f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,9 @@ #!/usr/bin/env python """Setup script for the project.""" +import os import re +import shutil import subprocess from setuptools import find_packages, setup @@ -29,9 +31,19 @@ class RustBuildExt(build_ext): def run(self) -> None: - # Run the stub generator + # Generate the stub file subprocess.run(["cargo", "run", "--bin", "stub_gen"], check=True) - # Call the original build_ext command + + # Move the generated stub file to parent directory + src_file = "actuator/bindings/bindings.pyi" + dst_file = "actuator/bindings.pyi" + if os.path.exists(src_file) and not os.path.exists(dst_file): + shutil.move(src_file, dst_file) + if not os.path.exists(dst_file): + raise RuntimeError(f"Failed to generate {dst_file}") + if os.path.exists(src_file): + os.remove(src_file) + super().run()