Skip to content

Commit

Permalink
build fixes (#42)
Browse files Browse the repository at this point in the history
* build fixes

* add back symlink

* improve build script

* stuff

* remove .pyi

* stuff

* stubgen
  • Loading branch information
codekansas authored Nov 1, 2024
1 parent dfcaafb commit 7bb2f08
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,4 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cd actuator/robstride
cargo publish
cargo publish -p robstride
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
.pytest_cache/
.ruff_cache/
.dmypy.json
*.pyi

# Databases
*.db
Expand Down
1 change: 0 additions & 1 deletion actuator/bindings.pyi

This file was deleted.

3 changes: 0 additions & 3 deletions actuator/bindings/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions actuator/bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
3 changes: 0 additions & 3 deletions actuator/bindings/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ build-backend = "maturin"
[project]
name = "bindings"
requires-python = ">=3.9"

[project.optional-dependencies]
test = ["pytest", "pyright", "ruff"]
16 changes: 14 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()


Expand Down

0 comments on commit 7bb2f08

Please sign in to comment.