Skip to content

Commit

Permalink
fix module name
Browse files Browse the repository at this point in the history
  • Loading branch information
lan496 committed Apr 6, 2024
1 parent 2624998 commit e3cc8e4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: |
set -e
pip install moyopy[dev] --find-links dist --force-reinstall
cd moyopy && pytest -v
pytest -v
- name: pytest
if: ${{ !startsWith(matrix.target, 'x86') && matrix.target != 'ppc64' }}
uses: uraimo/[email protected]
Expand All @@ -61,7 +61,7 @@ jobs:
run: |
set -e
pip3 install moyopy --find-links dist --force-reinstall
cd moyopy && pytest -v
pytest -v
windows:
runs-on: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resolver = "2"
authors = ["Kohei Shinohara <[email protected]>"]
description = "Library for Crystal Symmetry in Rust"
edition = "2021"
version = "0.1.0"
version = "0.1.1"
license = "MIT OR Apache-2.0"
repository = "https://github.com/spglib/moyo"

Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-python:
maturin develop --release --manifest-path moyopy/Cargo.toml

install-python:
python -m pip install nv maturin
python -m pip install uv maturin
maturin develop --release --manifest-path moyopy/Cargo.toml
python -m uv pip install -e "moyopy[dev]"
pre-commit install
Expand Down
6 changes: 3 additions & 3 deletions moyopy/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use moyo::base::{Cell, Lattice, MoyoError, Operations};
// Unfortunately, "PyCell" is already reversed by pyo3...
#[derive(Debug, Clone)]
#[pyclass(name = "Cell")]
#[pyo3(module = "moyo")]
#[pyo3(module = "moyopy")]
pub struct PyStructure(Cell);

#[pymethods]
Expand Down Expand Up @@ -106,7 +106,7 @@ impl<'de> Deserialize<'de> for PyStructure {

#[derive(Debug)]
#[pyclass(name = "MoyoError")]
#[pyo3(module = "moyo")]
#[pyo3(module = "moyopy")]
pub struct PyMoyoError(MoyoError);

impl From<PyMoyoError> for PyErr {
Expand All @@ -123,7 +123,7 @@ impl From<MoyoError> for PyMoyoError {

#[derive(Debug)]
#[pyclass(name = "Operations")]
#[pyo3(module = "moyo")]
#[pyo3(module = "moyopy")]
pub struct PyOperations(Operations);

#[pymethods]
Expand Down
2 changes: 1 addition & 1 deletion moyopy/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use moyo::data::Setting;

#[derive(Debug, Clone)]
#[pyclass(name = "Setting")]
#[pyo3(module = "moyo")]
#[pyo3(module = "moyopy")]
pub struct PySetting(Setting);

#[pymethods]
Expand Down
13 changes: 7 additions & 6 deletions moyopy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::data::PySetting;

#[derive(Debug)]
#[pyclass(name = "MoyoDataset")]
#[pyo3(module = "moyo")]
#[pyo3(module = "moyopy")]
pub struct PyMoyoDataset(MoyoDataset);

#[pymethods]
Expand Down Expand Up @@ -115,10 +115,10 @@ impl PyMoyoDataset {
}

// https://github.com/pydantic/pydantic-core/blob/main/src/lib.rs
pub fn moyo_version() -> &'static str {
static MOYO_VERSION: OnceLock<String> = OnceLock::new();
pub fn moyopy_version() -> &'static str {
static MOYOPY_VERSION: OnceLock<String> = OnceLock::new();

MOYO_VERSION.get_or_init(|| {
MOYOPY_VERSION.get_or_init(|| {
let version = env!("CARGO_PKG_VERSION");
// cargo uses "1.0-alpha1" etc. while python uses "1.0.0a1", this is not full compatibility,
// but it's good enough for now
Expand All @@ -131,8 +131,9 @@ pub fn moyo_version() -> &'static str {

/// A Python module implemented in Rust.
#[pymodule]
fn _moyopy(_py: Python, m: &PyModule) -> PyResult<()> {
m.add("__version__", moyo_version())?;
#[pyo3(name = "_moyopy")]
fn moyopy(_py: Python, m: &PyModule) -> PyResult<()> {
m.add("__version__", moyopy_version())?;

// lib
m.add_class::<PyMoyoDataset>()?;
Expand Down

0 comments on commit e3cc8e4

Please sign in to comment.