Skip to content
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

Add python support #9

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f5247be
Add static linkage for linuxathena targets, primarily for Grapple-Hook
JaciBrunning Dec 24, 2023
c1ea16d
Update dep json
JaciBrunning Dec 24, 2023
0234b75
Update CAN bridge to, well, work
JaciBrunning Dec 24, 2023
6ab76dc
Update deps
JaciBrunning Dec 25, 2023
b5dfefe
Update grapple-frc-msgs
JaciBrunning Dec 25, 2023
13ad25a
Add Test Projects, update to Beta 2
JaciBrunning Dec 26, 2023
602fbfc
Fix build.rs to work on newer versions of Clang on Windows
JaciBrunning Dec 27, 2023
b1ceee6
Update to streaming CAN API for CAN bridge
JaciBrunning Dec 27, 2023
22d373e
Update to newest messaging
JaciBrunning Jan 5, 2024
6df6936
Update to new release
JaciBrunning Jan 6, 2024
21053f8
Update to 2024 WPILib
JaciBrunning Jan 7, 2024
089c491
Update libs - only use what's necessary
JaciBrunning Jan 14, 2024
039798d
Include buildlibs in the vendored release of libgrapplefrc - preparin…
JaciBrunning Jan 14, 2024
066f761
Make Java exceptions distinct, ensure user program catches any errors…
JaciBrunning Jan 21, 2024
3fe2c1c
Update error handling to fix #11
JaciBrunning Jan 21, 2024
393afed
Renamespace a lot of the lasercan, hide behind C and JNI features
JaciBrunning Jan 21, 2024
ec6f57a
Bump Version
JaciBrunning Jan 21, 2024
de0581e
Update to fix build issues
JaciBrunning Jan 21, 2024
86ef3d9
Make conv_result not constexpr
JaciBrunning Jan 21, 2024
6c6c00a
Setup pyo3 and begin working on python implementation
spacey-sooty Dec 20, 2023
2a36c7a
fix actions
spacey-sooty Dec 20, 2023
4e7e01b
Finished python implementation
spacey-sooty Dec 20, 2023
dbf33a6
remove allow dead code
spacey-sooty Dec 20, 2023
42437ff
fix actions
spacey-sooty Dec 20, 2023
3b161b1
add basic tests
spacey-sooty Dec 22, 2023
fbcafe8
ran cargo fmt
spacey-sooty Dec 23, 2023
1f601ff
use native rust types
spacey-sooty Dec 23, 2023
2f81f6c
fix version of grapplefrc messages in grpl-py
spacey-sooty Dec 28, 2023
f28ffe3
fix some issues with ci
spacey-sooty Dec 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 79 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,82 @@ jobs:
with:
path: "depjson"
destination: "grapple-frc-maven"
parent: false
parent: false

linux-py:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Clang
run: sudo apt-get update && sudo apt-get install -y libclang1-15 clang llvm gcc-multilib
- name: Prepare Rust Libs
run: ./gradlew updateRustLibs --max-workers 1
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release -m grpl-py/Cargo.toml -i 3.12
sccache: 'true'
manylinux: auto

windows-py:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
with:
rust-version: stable
- name: Setup Rust Toolchain (Windows Arm64)
run: rustup target add aarch64-pc-windows-msvc
- name: Prepare Rust Libs
run: ./gradlew updateRustLibs --max-workers 1
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release -m grpl-py/Cargo.toml -i 3.12
sccache: 'true'

# macos-py:
# runs-on: macos-latest
# strategy:
# matrix:
# target: [x86_64, aarch64]
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-java@v3
# with:
# distribution: 'zulu'
# java-version: 17
# - uses: actions/setup-python@v4
# with:
# python-version: '3.12'
# - name: Prepare Rust Libs
# run: ./gradlew updateRustLibs --max-workers 1
# - name: Build wheels
# uses: PyO3/maturin-action@v1
# with:
# target: ${{ matrix.target }}
# args: --release -m grpl-py/Cargo.toml
# sccache: 'true'
77 changes: 77 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,80 @@ bin/


# End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode

#pyo3
/target

# env
.env

# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
.venv/
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
include/
man/
venv/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
pip-selfcheck.json

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

.DS_Store

# Sphinx documentation
docs/_build/

# PyCharm
.idea/

# VSCode
.vscode/

# Pyenv
.python-version
92 changes: 91 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,96 @@
"system_error": "cpp",
"*.tcc": "cpp",
"optional": "cpp",
"ranges": "cpp"
"ranges": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"scoped_allocator": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"charconv": "cpp",
"expected": "cpp",
"filesystem": "cpp",
"format": "cpp",
"ios": "cpp",
"locale": "cpp",
"queue": "cpp",
"stack": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
84 changes: 45 additions & 39 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ nativeUtils {

nativeDependencyContainer {
libgrapplefrcdriver(getNativeDependencyTypeClass('WPISharedMavenDependency')) {
version = "2024.0.0-beta3"
version = "2024.2.1"
groupId = "au.grapplerobotics"
artifactId = "libgrapplefrcdriver"
ext = "zip"
Expand Down Expand Up @@ -114,44 +114,29 @@ model {
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

def sets = [
"hal_shared", "wpiutil_shared"
]

task updateRustLibs() {
doLast {
nativeUtils.nativeDependencyContainer.getByName("driver_shared", libset -> {
def debugBuildType = nativeUtils.buildTypes.named('debug').get()
def releaseBuildType = nativeUtils.buildTypes.named('release').get()
for (targetPlatform in nativeUtils.platforms) {
def resolved = libset.resolveNativeDependency(targetPlatform, releaseBuildType, java.util.Optional.empty()).get()
def resolvedDebug = libset.resolveNativeDependency(targetPlatform, debugBuildType, java.util.Optional.empty()).get()

def headers = []
def libs = []

resolved.getLinkFiles().forEach({ f -> libs += f })
resolvedDebug.getLinkFiles().forEach({ f -> libs += f })
resolved.getIncludeRoots().forEach({ f -> headers += f })

def triple = rust_triple(targetPlatform)
def outdir = project.file("grapplefrcdriver/buildlibs/${triple}")
new File(outdir, "libs").mkdirs()
new File(outdir, "headers").mkdirs()

libs.forEach({ lf ->
copy {
from lf
into "${outdir}/libs"
}
})

headers.forEach({ hd ->
copy {
from hd
into "${outdir}/headers"
}
})

if (targetPlatform.name == "osxuniversal") {
// 2nd copy needed for arm
outdir = project.file("grapplefrcdriver/buildlibs/aarch64-apple-darwin")
sets.each { set -> {
nativeUtils.nativeDependencyContainer.getByName(set, libset -> {
def debugBuildType = nativeUtils.buildTypes.named('debug').get()
def releaseBuildType = nativeUtils.buildTypes.named('release').get()
for (targetPlatform in nativeUtils.platforms) {
def resolved = libset.resolveNativeDependency(targetPlatform, releaseBuildType, java.util.Optional.empty()).get()
def resolvedDebug = libset.resolveNativeDependency(targetPlatform, debugBuildType, java.util.Optional.empty()).get()

def headers = []
def libs = []

resolved.getLinkFiles().forEach({ f -> libs += f })
resolvedDebug.getLinkFiles().forEach({ f -> libs += f })
resolved.getIncludeRoots().forEach({ f -> headers += f })

def triple = rust_triple(targetPlatform)
def outdir = project.file("grapplefrcdriver/buildlibs/${triple}")
new File(outdir, "libs").mkdirs()
new File(outdir, "headers").mkdirs()

Expand All @@ -168,9 +153,30 @@ task updateRustLibs() {
into "${outdir}/headers"
}
})

if (targetPlatform.name == "osxuniversal") {
// 2nd copy needed for arm
outdir = project.file("grapplefrcdriver/buildlibs/aarch64-apple-darwin")
new File(outdir, "libs").mkdirs()
new File(outdir, "headers").mkdirs()

libs.forEach({ lf ->
copy {
from lf
into "${outdir}/libs"
}
})

headers.forEach({ hd ->
copy {
from hd
into "${outdir}/headers"
}
})
}
}
}
})
})
}}
}
}

Expand Down
Loading