Skip to content

Commit

Permalink
Version fixes (#41)
Browse files Browse the repository at this point in the history
* version fixes

* update version
  • Loading branch information
codekansas authored Nov 1, 2024
1 parent c85edca commit dfcaafb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 165 deletions.
5 changes: 3 additions & 2 deletions actuator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Defines the top-level API for the actuator package."""

__version__ = "0.0.25"

from .bindings import (
PyRobstrideMotorConfig as RobstrideMotorConfig,
PyRobstrideMotorControlParams as RobstrideMotorControlParams,
PyRobstrideMotorFeedback as RobstrideMotorFeedback,
PyRobstrideMotors as RobstrideMotors,
PyRobstrideMotorsSupervisor as RobstrideMotorsSupervisor,
PyRobstrideMotorType as RobstrideMotorType,
get_version,
)

__version__ = get_version()
3 changes: 3 additions & 0 deletions actuator/bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .gitignore

*.pyi
152 changes: 0 additions & 152 deletions actuator/bindings/bindings.pyi

This file was deleted.

9 changes: 8 additions & 1 deletion actuator/bindings/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pyo3::prelude::*;
use pyo3_stub_gen::define_stub_info_gatherer;
use pyo3_stub_gen::derive::{gen_stub_pyclass, gen_stub_pymethods};
use pyo3_stub_gen::derive::{gen_stub_pyclass, gen_stub_pyfunction, gen_stub_pymethods};
use robstride::{
motor_mode_from_str as robstride_motor_mode_from_str,
motor_type_from_str as robstride_motor_type_from_str, MotorConfig as RobstrideMotorConfig,
Expand All @@ -11,6 +11,12 @@ use robstride::{
use std::collections::HashMap;
use std::hash::{Hash, Hasher};

#[pyfunction]
#[gen_stub_pyfunction]
fn get_version() -> String {
env!("CARGO_PKG_VERSION").to_string()
}

#[gen_stub_pyclass]
#[pyclass]
struct PyRobstrideMotors {
Expand Down Expand Up @@ -542,6 +548,7 @@ impl From<PyRobstrideMotorType> for RobstrideMotorType {

#[pymodule]
fn bindings(m: &Bound<PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(get_version, m)?)?;
m.add_class::<PyRobstrideMotors>()?;
m.add_class::<PyRobstrideMotorFeedback>()?;
m.add_class::<PyRobstrideMotorsSupervisor>()?;
Expand Down
13 changes: 3 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#!/usr/bin/env python
"""Setup script for the project."""

import glob
import re
import subprocess

Expand All @@ -22,16 +21,11 @@
requirements_dev: list[str] = f.read().splitlines()


with open("actuator/__init__.py", "r", encoding="utf-8") as fh:
version_re = re.search(r"^__version__ = \"([^\"]*)\"", fh.read(), re.MULTILINE)
assert version_re is not None, "Could not find version in actuator/__init__.py"
with open("Cargo.toml", "r", encoding="utf-8") as fh:
version_re = re.search(r"^version = \"([^\"]*)\"", fh.read(), re.MULTILINE)
assert version_re is not None, "Could not find version in Cargo.toml"
version: str = version_re.group(1)

package_data = [f"actuator/{name}" for name in ("py.typed", "requirements.txt", "requirements-dev.txt")]
package_data.append("Cargo.toml")
for ext in ("pyi", "rs", "toml", "so"):
package_data.extend(glob.iglob(f"actuator/**/*.{ext}", recursive=True))


class RustBuildExt(build_ext):
def run(self) -> None:
Expand Down Expand Up @@ -62,7 +56,6 @@ def run(self) -> None:
install_requires=requirements,
extras_require={"dev": requirements_dev},
include_package_data=True,
package_data={"actuator": package_data},
packages=find_packages(include=["actuator"]),
cmdclass={"build_ext": RustBuildExt},
)

0 comments on commit dfcaafb

Please sign in to comment.