Skip to content

Commit

Permalink
Submodules cannot be found in Python project
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Jan 16, 2024
1 parent e1b0d3b commit 8029975
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
21 changes: 5 additions & 16 deletions crates/lox_py/src/bodies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use lox_core::bodies::*;
use crate::LoxPyError;

#[pyclass(name = "Sun")]
struct PySun;
pub struct PySun;

#[pymethods]
impl PySun {
Expand Down Expand Up @@ -56,7 +56,7 @@ impl PySun {
}

#[pyclass(name = "Barycenter")]
struct PyBarycenter(Box<dyn PointMass + Send>);
pub struct PyBarycenter(Box<dyn PointMass + Send>);

#[pymethods]
impl PyBarycenter {
Expand Down Expand Up @@ -105,7 +105,7 @@ impl PyBarycenter {
}

#[pyclass(name = "Planet")]
struct PyPlanet(Box<dyn Planet + Send>);
pub struct PyPlanet(Box<dyn Planet + Send>);

#[pymethods]
impl PyPlanet {
Expand Down Expand Up @@ -163,7 +163,7 @@ impl PyPlanet {
}

#[pyclass(name = "Satellite")]
struct PySatellite(Box<dyn Satellite + Send>);
pub struct PySatellite(Box<dyn Satellite + Send>);

#[pymethods]
impl PySatellite {
Expand Down Expand Up @@ -256,7 +256,7 @@ impl PySatellite {
}

#[pyclass(name = "MinorBody")]
struct PyMinorBody(Box<dyn MinorBody + Send>);
pub struct PyMinorBody(Box<dyn MinorBody + Send>);

#[pymethods]
impl PyMinorBody {
Expand Down Expand Up @@ -312,14 +312,3 @@ impl PyMinorBody {
self.0.along_orbit_radius()
}
}

#[pymodule]
#[pyo3(name = "bodies")]
pub fn module(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<PySun>()?;
m.add_class::<PyBarycenter>()?;
m.add_class::<PyPlanet>()?;
m.add_class::<PySatellite>()?;
m.add_class::<PyMinorBody>()?;
Ok(())
}
9 changes: 7 additions & 2 deletions crates/lox_py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
use pyo3::wrap_pymodule;
use thiserror::Error;

use lox_core::errors::LoxError;
use lox_core::time::dates::{Date, Time};
use lox_core::time::epochs::Epoch;
use lox_core::time::epochs::TimeScale;

use crate::bodies::{PyBarycenter, PyMinorBody, PyPlanet, PySatellite, PySun};

mod bodies;

#[derive(Error, Debug)]
Expand Down Expand Up @@ -145,8 +146,12 @@ impl PyEpoch {
/// A Python module implemented in Rust.
#[pymodule]
fn lox_space(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pymodule!(bodies::module))?;
m.add_class::<PyTimeScale>()?;
m.add_class::<PyEpoch>()?;
m.add_class::<PySun>()?;
m.add_class::<PyBarycenter>()?;
m.add_class::<PyPlanet>()?;
m.add_class::<PySatellite>()?;
m.add_class::<PyMinorBody>()?;
Ok(())
}

0 comments on commit 8029975

Please sign in to comment.