Skip to content

Commit

Permalink
adjusted workflow, moved python docs to si-units (#31)
Browse files Browse the repository at this point in the history
* adjusted workflow, moved python docs to si-units

* fixed wrong path and maturin argument in test_documentation workflow

* renamed quantity in documentation

* changed workflows

* add numpy installation

* removed pymodule from root crate

* Removed extension-module and cdylib from quantity

* Changed module wrap to function call
  • Loading branch information
g-bauer authored Nov 8, 2021
1 parent a76177c commit ec51af1
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 42 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
manylinux: auto
command: build
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand All @@ -60,11 +60,11 @@ jobs:
uses: messense/maturin-action@v1
with:
target: x86_64
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Build wheels - universal2
uses: messense/maturin-action@v1
with:
args: --release --universal2 --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --universal2 --out dist --no-sdist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -135,12 +135,12 @@ jobs:
with:
manylinux: auto
command: build
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Install module
run: |
pip install quantity --no-index --find-links dist --force-reinstall
pip install si-units --no-index --find-links dist --force-reinstall
- name: Build documentation
run: sphinx-build docs/ public/ -b html
run: sphinx-build si-units/docs/ public/ -b html
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
with:
manylinux: auto
command: build
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Install module
run: |
pip install quantity --no-index --find-links dist --force-reinstall
pip install si-units --no-index --find-links dist --force-reinstall
- name: Run doctests
run: sphinx-build docs/ public/ -b doctest
run: sphinx-build si-units/docs/ public/ -b doctest
8 changes: 4 additions & 4 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
manylinux: auto
command: build
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand All @@ -41,11 +41,11 @@ jobs:
uses: messense/maturin-action@main
with:
target: x86_64
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Build wheels - universal2
uses: messense/maturin-action@main
with:
args: --release --universal2 --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --universal2 --out dist --no-sdist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand All @@ -72,7 +72,7 @@ jobs:
uses: messense/maturin-action@main
with:
target: ${{ matrix.target }}
args: --release --out dist --no-sdist --cargo-extra-args="--features python"
args: --release --out dist --no-sdist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
**/target
Cargo.lock
*.so
docs/_build
docs/api/generated
quantity/__pycache__/
si-units/docs/_build
si-units/docs/api/generated
/venv
.ipynb_checkpoints
*.ipynb
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ exclude = ["/.github/*", "*.ipynb", "/docs"]
[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "./src/docs-header.html" ]

[lib]
crate-type = ["rlib", "cdylib"]

[dependencies]
ndarray = { version = "0.15", features = ["serde", "approx"] }
approx = "0.4"
Expand All @@ -32,7 +29,7 @@ numpy = { version = "0.14", optional = true }

[dependencies.pyo3]
version = "0.14"
features = ["extension-module", "abi3", "abi3-py36", "multiple-pymethods"]
features = ["multiple-pymethods"]
optional = true

[features]
Expand Down
9 changes: 3 additions & 6 deletions si-units/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ authors = ["Philipp Rehner <[email protected]>",
"Gernot Bauer <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
description = "Representation of quantites, i.e. of unit valued scalars and arrays."
homepage = "https://github.com/itt-ustutt/quantity"
description = "Representation of SI unit valued scalars and arrays."
homepage = "https://github.com/itt-ustutt/quantity/tree/master/si-units"
readme = "README.md"
repository = "https://github.com/itt-ustutt/quantity"
keywords = ["physics", "units", "SI"]
categories = ["data-structures", "science"]
exclude = ["/.github/*", "*.ipynb", "/docs"]

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "./src/docs-header.html" ]
exclude = ["*.ipynb", "/docs"]

[lib]
name = "si_units"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/api.rst → si-units/docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
API
---

.. currentmodule:: quantity
.. currentmodule:: si_units

.. contents:: Table of Contents
:depth: 3
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py → si-units/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
#
import os
import sys
import quantity
import si_units

sys.path.append(os.path.abspath(os.path.join(__file__, "../..")))
sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'quantity'
project = 'si_units'
copyright = '2021, Philipp Rehner, Gernot Bauer'
author = 'Philipp Rehner, Gernot Bauer'

# The full version, including alpha/beta/rc tags
release = quantity.__version__
release = si_units.__version__


# -- General configuration ---------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions docs/examples.rst → si-units/docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Examples
Pressure of an ideal gas
~~~~~~~~~~~~~~~~~~~~~~~~

>>> from quantity import *
>>> from si_units import *
>>> temperature = 298.15 * KELVIN
>>> volume = 1.5 * METER**3
>>> moles = 75.0 * MOL
Expand All @@ -14,7 +14,7 @@ Pressure of an ideal gas

You can use division to perform unit conversions.

>>> from quantity import *
>>> from si_units import *
>>> temperature = 298.15 * KELVIN
>>> volume = 1.5 * METER**3
>>> moles = 75.0 * MOL
Expand All @@ -29,7 +29,7 @@ You can use division to perform unit conversions.
Gravitational pull of the moon on the earth
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>>> from quantity import *
>>> from si_units import *
>>> mass_earth = 5.9724e24 * KILOGRAM
>>> mass_moon = 7.346e22 * KILOGRAM
>>> distance = 383.398 * KILO * METER
Expand All @@ -45,7 +45,7 @@ This example demonstrates how dimensioned arrays can be constructed using numpy.

.. code-block:: python
>>> from quantity import *
>>> from si_units import *
>>> import numpy as np
>>> z = np.linspace(1.0, 70.0e3, 10) * METER
Expand Down Expand Up @@ -76,7 +76,7 @@ Using `numpy` Functions

Functions such as `exp`, `sqrt` and `cbrt` work with methods or the equivalent numpy functions.

>>> from quantity import *
>>> from si_units import *
>>> import numpy as np
>>> sqm = METER**2
>>> np.sqrt(sqm)
Expand All @@ -86,7 +86,7 @@ Functions such as `exp`, `sqrt` and `cbrt` work with methods or the equivalent n

This also works with numpy.ndarray's.

>>> from quantity import *
>>> from si_units import *
>>> import numpy as np
>>> ms = np.array([2.0, 3.0, 4.0]) * METER
>>> sqms = ms**2
Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst → si-units/docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Welcome to quantity
Welcome to si-units
===================

This package enables calculation with dimensioned values.

Installation
------------

You can install `quantity` from pypi using `pip`:
You can install `si-units` from pypi using `pip`:

```
pip install quantity
pip install si-units
```

Build from source
Expand Down
2 changes: 1 addition & 1 deletion si-units/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pyo3::prelude::*;
use quantity::python::*;
use quantity::python::quantity;

/// Implementation of SI numbers.
#[pymodule]
Expand Down
1 change: 0 additions & 1 deletion src/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const RADIANS: PyAngle = PyAngle(crate::si::RADIANS);
const G: PySINumber = PySINumber(crate::si::G);
const RGAS: PySINumber = PySINumber(crate::si::RGAS);

/// Implementation of SI numbers.
#[pymodule]
pub fn quantity(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
Expand Down

0 comments on commit ec51af1

Please sign in to comment.