-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python bindings #48
Closed
Closed
Python bindings #48
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
87ca5f1
Foundations for Python bindings
larsnaesbye 9a2f25d
python-bindings: basics
gwbres 3b6754b
clarify maturin building
larsnaesbye d9e447d
python-bindings: basics
gwbres 0dd07ea
add pip instructions
larsnaesbye 90c1ab5
Merge branch 'main' into python-bindings
larsnaesbye e7fea37
python: correct Cargo.toml
gwbres e925c25
python: basics
gwbres e4dee0c
python: github workflow to generate the python wheel
gwbres b660dee
python.yml: add linux-x86 wheel
gwbres 16e3567
python.yml: linux x86 does not work
gwbres 9da50ce
python.yml: test advanced script, remove publication
gwbres 2b51f9d
python.yml: sanitization
gwbres 4a6ff20
Update python.yml
gwbres fc55030
python: fix wheel compilation on windows
gwbres c234b95
github: fix windows wheel build
gwbres 7c59727
remove unused and outcommented
larsnaesbye cc45bf3
Merge branch 'main' into python-bindings
larsnaesbye 0fcc683
observation: basics
gwbres 2e231cc
python.yml: fix windows-x86 build
gwbres 6690dfe
python.yml
gwbres 60b0489
python: support and supply py3.8
gwbres 105c5ac
python.yml
gwbres a43ff4b
rust.yml
gwbres d68d797
fix testbench: crinex day is 2 digit number
gwbres f7935b1
release.yml: cli binary packaging (#61)
gwbres c1e4b50
Merge branch 'gwbres:main' into python-bindings
larsnaesbye 931bfe8
python.rs: add a few more bindings
gwbres 98d926c
python.rs: add a few more bindings
gwbres 834518f
add topic
larsnaesbye 9de6af2
python.yml: archive, github release
gwbres 1e3f528
python.yml: archive, github release
gwbres 2aab1c7
python.yml
gwbres 0e1376b
python.yml
gwbres 97e1104
python.yml
gwbres 061cff4
python.yml: package and release
gwbres 3504e3e
python.yml
gwbres b25150a
simplify and align a bit with upstream
larsnaesbye 5b0496e
Merge branch 'main' into python-bindings
larsnaesbye 7a420fb
fix a few compile errors due to wrong merge
larsnaesbye 4a69bb7
formatting
larsnaesbye 31a43d5
add the new classes
larsnaesbye c5dbb0e
Merge branch 'main' into python-bindings
larsnaesbye b48bd47
Merge branch 'main' into python-bindings
larsnaesbye 91974cc
Merge branch 'gwbres:main' into python-bindings
larsnaesbye 7e28993
Merge branch 'gwbres:main' into python-bindings
larsnaesbye fb52f5d
update PyO3 to match HiFiTime
larsnaesbye fc26d0f
update to latest branch
gwbres bb5329b
declare ephemeris type
gwbres 665c38b
use latest pyo3
gwbres 381f584
version bindings
gwbres 9951a82
python: correct build instructions
gwbres a86f836
add more bindings
gwbres 71826d9
add more bindings
gwbres 5e0ba37
working on complex cast
gwbres 35e7ee1
Merge branch 'georust:main' into python-bindings
larsnaesbye db34c17
Merge branch 'georust:main' into python-bindings
larsnaesbye ed51e97
Merge branch 'georust:main' into python-bindings
larsnaesbye c9bbf0c
Merge branch 'georust:main' into python-bindings
larsnaesbye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: python | ||
|
||
on: | ||
push: | ||
pull_request: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
macos: | ||
runs-on: macos-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
py_ver: ['3.8', '3.9', '3.10'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.py_ver }} | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: aarch64-apple-darwin | ||
- name: Build | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: x86_64-apple-darwin | ||
args: --release -i python${{ matrix.py_ver }} --all-features -m rinex/Cargo.toml --out dist --sdist | ||
- name: Test wheel | ||
run: | | ||
pip install rinex --no-index --find-links dist --force-reinstall | ||
python -c "import rinex" | ||
- name: Prepare for upload | ||
run: tar czvf rinex.tar.gz dist/*.whl | ||
- name: Github Release | ||
uses: svenstaro/upload-release-action@v2 | ||
if: "startsWith(github.ref, 'refs/tags/')" | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
asset_name: rinex-python${{ matrix.pyver }}-apple-darwin.tar.gz | ||
file: rinex.tar.gz | ||
tag: ${{ github.ref }} | ||
|
||
windows: | ||
runs-on: windows-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
target: [x64, x86] | ||
py_ver: ['3.8', '3.9', '3.10'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.py_ver }} | ||
architecture: ${{ matrix.target }} | ||
- name: Build | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
args: --release --all-features -m rinex/Cargo.toml --out dist | ||
- name: Test wheel | ||
run: | | ||
pip install rinex --no-index --find-links dist --force-reinstall | ||
python -c "import rinex" | ||
- name: Prepare for upload | ||
run: | | ||
Compress-Archive dist/*.whl rinex.zip | ||
dir | ||
- name: Github Release | ||
uses: svenstaro/upload-release-action@v2 | ||
if: "startsWith(github.ref, 'refs/tags/')" | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
asset_name: rinex-python${{ matrix.pyver }}-windows-${{ matrix.target }}.zip | ||
file: rinex.zip | ||
tag: ${{ github.ref }} | ||
|
||
linux: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
target: [x64] | ||
py_ver: ['3.8', '3.9', '3.10'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.py_ver }} | ||
architecture: ${{ matrix.target }} | ||
- name: Build | ||
uses: PyO3/maturin-action@main | ||
with: | ||
target: x64 | ||
manylinux: auto | ||
args: --release -i python${{ matrix.py_ver }} --all-features -m rinex/Cargo.toml -o dist | ||
- name: Build | ||
run: | | ||
pip3 install rinex --no-index --find-links dist --force-reinstall | ||
python -c "import rinex" | ||
- name: Test wheel | ||
run: | | ||
pip install rinex --no-index --find-links dist --force-reinstall | ||
python -c "import rinex" | ||
- name: Prepare for upload | ||
run: | | ||
tar czvf rinex.tar.gz dist/*.whl | ||
ls -lah rinex.tar.gz | ||
- name: Github Release | ||
uses: svenstaro/upload-release-action@v2 | ||
if: "startsWith(github.ref, 'refs/tags/')" | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
asset_name: rinex-python${{ matrix.pyver }}-linux-${{ matrix.target }}.tar.gz | ||
file: rinex.tar.gz | ||
tag: ${{ github.ref }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Python3 wheel | ||
============= | ||
|
||
Install requirements: python3 (>3.8) and maturin | ||
|
||
Then build the python bindings: use `maturin` to build the crate | ||
with the `pyo3` feature | ||
|
||
```bash | ||
cd rinex/ | ||
maturin build -F pyo3 | ||
``` | ||
|
||
A pip3 wheel is generated for your architecture. | ||
Use pip3 to install the library | ||
|
||
```bash | ||
pip3 install --force-reinstall rinex/target/wheels/rinex-xxx.whl | ||
``` | ||
|
||
Now move on to the provided examples, run the basics with | ||
|
||
```bash | ||
python3 rinex/examples/python/basic.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from rinex import * | ||
|
||
# rinex::prelude basic examples, | ||
# This example program depicts how you can interact with | ||
# all the basic structures from the rust crate | ||
|
||
def parser_example(fp): | ||
# parse a RINEX file | ||
rinex = Rinex(fp) | ||
# use header section | ||
print("is_crinex: ", rinex.header.is_crinex()) | ||
print("header : \n{:s}".format(str(rinex.header))) | ||
# use record section | ||
print(rinex.record) | ||
|
||
def rinex_manual_constructor(): | ||
# Manual construction example. | ||
# This is handy in data production contexts | ||
header = Header.basic_obs() | ||
print(header.is_crinex()) | ||
|
||
def sv_example(): | ||
pass | ||
|
||
def constellation_example(): | ||
pass | ||
|
||
def epoch_example(): | ||
print("Epoch.system_now(): ", Epoch.system_now()) | ||
|
||
if __name__ == "__main__": | ||
parser_example("../test_resources/OBS/V3/DUTH0630.22O") | ||
epoch_example() | ||
sv_example() | ||
rinex_manual_constructor() | ||
constellation_example() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from rinex import * | ||
|
||
if __name__ == "__main__": | ||
crinex = Crinex() | ||
assert(crinex.version.major == 3) | ||
assert(crinex.version.minor == 0) | ||
|
||
observation = ObservationData(10.0) | ||
assert(observation.obs == 10.0) | ||
assert(observation.snr == None) | ||
assert(observation.lli == None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[build-system] | ||
requires = ["maturin>=0.14"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "rinex" | ||
requires-python = ">=3.8" | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: Apache Software License", | ||
"License :: OSI Approved :: MIT License", | ||
gwbres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"Topic :: Scientific/Engineering :: Physics", | ||
"Topic :: Scientific/Engineering :: Atmospheric Science", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be awesome to be able to auto generate the wheel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it gets included with the release, and later uploaded to pypi.org ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, like the application binaries
i did not think about going this far, but I don't foresee any reasons that would not be doable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use maturin-action
The wheels are generated for windows and linux.
The generation for macos is currently failing, due to a linking error when the bindings reach "hifitime".
I turned the publication off but it will easily be added.
First we will attach the wheels to the released package, like we do for the compiled -cli.
We can also add a publication to pypi, if you follow the previous link, some people do that.