Browse Source

Publish rust project on pip to make it simpler to deploy dora node on different machine without requiring installing cargo (#695)

Currently rust node and the cli requires easier to use cargo or wget,
but it would be simpler if we could just pip install them.

This PR do this.

People will be able to do:
```bash
pip install dora-rerun
pip install dora-rs-cli
```

This will make the pull process of nodes simpler for people who only use
python.
tags/v0.3.7rc1
Haixuan Xavier Tao GitHub 1 year ago
parent
commit
af620b4bb1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
5 changed files with 74 additions and 37 deletions
  1. +8
    -3
      .github/workflows/node-hub-ci-cd.yml
  2. +12
    -12
      .github/workflows/node_hub_test.sh
  3. +42
    -22
      .github/workflows/pip-release.yml
  4. +6
    -0
      binaries/cli/pyproject.toml
  5. +6
    -0
      node-hub/dora-rerun/pyproject.toml

+ 8
- 3
.github/workflows/node-hub-ci-cd.yml View File

@@ -104,9 +104,14 @@ jobs:
run: | run: |
for dir in node-hub/*/ ; do for dir in node-hub/*/ ; do
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
if [ -f "$dir/pyproject.toml" ]; then
echo "Publishing $dir using Poetry..."
(cd "$dir" && poetry publish --build)
if [[ -f "$dir/Cargo.toml" && -f "$dir/pyproject.toml" ]]; then
echo "Publishing $dir using maturin..."
(cd "$dir" && poetry publish)
else
if [ -f "$dir/pyproject.toml" ]; then
echo "Publishing $dir using Poetry..."
(cd "$dir" && poetry publish --build)
fi
fi fi
if [ -f "$dir/Cargo.toml" ]; then if [ -f "$dir/Cargo.toml" ]; then


+ 12
- 12
.github/workflows/node_hub_test.sh View File

@@ -15,18 +15,18 @@ for dir in node-hub/*/ ; do
fi fi


if [ -d "$dir" ]; then if [ -d "$dir" ]; then
if [ -f "$dir/pyproject.toml" ]; then
echo "Running linting and tests for Python project in $dir..."
(cd "$dir" && pip install .)
(cd "$dir" && poetry run black --check .)
(cd "$dir" && poetry run pylint --disable=C,R --ignored-modules=cv2 **/*.py)
(cd "$dir" && poetry run pytest)
fi
if [ -f "$dir/Cargo.toml" ]; then if [ -f "$dir/Cargo.toml" ]; then
echo "Running build and tests for Rust project in $dir..."
(cd "$dir" && cargo build)
(cd "$dir" && cargo test)
fi
echo "Running build and tests for Rust project in $dir..."
(cd "$dir" && cargo build)
(cd "$dir" && cargo test)
else
if [ -f "$dir/pyproject.toml" ]; then
echo "Running linting and tests for Python project in $dir..."
(cd "$dir" && pip install .)
(cd "$dir" && poetry run black --check .)
(cd "$dir" && poetry run pylint --disable=C,R --ignored-modules=cv2 **/*.py)
(cd "$dir" && poetry run pytest)
fi
fi
fi fi
done done

+ 42
- 22
.github/workflows/pip-release.yml View File

@@ -39,6 +39,9 @@ jobs:
# target: s390x # target: s390x
# - runner: ubuntu-20.04 # - runner: ubuntu-20.04
# target: ppc64le # target: ppc64le
repository:
- path: apis/python/node
- path: binaries/cli
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
@@ -53,21 +56,21 @@ jobs:
uses: PyO3/maturin-action@v1 uses: PyO3/maturin-action@v1
with: with:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
args: --release --out dist --zig
args: --release --out dist --zig -i 3.8
manylinux: manylinux_2_28 manylinux: manylinux_2_28
working-directory: apis/python/node
working-directory: ${{ matrix.repository.path }}
- name: Upload wheels - name: Upload wheels
if: github.event_name == 'release' if: github.event_name == 'release'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: wheels-linux-${{ matrix.platform.target }} name: wheels-linux-${{ matrix.platform.target }}
path: apis/python/node/dist
path: ${{ matrix.repository.path }}/dist
- name: Upload to release - name: Upload to release
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
file: ${{ matrix.repository.path }}/dist/*
tag: ${{ github.ref }} tag: ${{ github.ref }}
file_glob: true file_glob: true


@@ -82,6 +85,9 @@ jobs:
target: x86 target: x86
- runner: ubuntu-22.04 - runner: ubuntu-22.04
target: aarch64 target: aarch64
repository:
- path: apis/python/node
- path: binaries/cli
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
@@ -91,22 +97,22 @@ jobs:
uses: PyO3/maturin-action@v1 uses: PyO3/maturin-action@v1
with: with:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
args: --release --out dist
args: --release --out dist -i 3.8
sccache: "true" sccache: "true"
manylinux: musllinux_1_2 manylinux: musllinux_1_2
working-directory: apis/python/node
working-directory: ${{ matrix.repository.path }}
- name: Upload wheels - name: Upload wheels
if: github.event_name == 'release' if: github.event_name == 'release'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: wheels-musllinux-${{ matrix.platform.target }} name: wheels-musllinux-${{ matrix.platform.target }}
path: apis/python/node/dist
path: ${{ matrix.repository.path }}/dist
- name: Upload to release - name: Upload to release
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
file: ${{ matrix.repository.path }}/dist/*
tag: ${{ github.ref }} tag: ${{ github.ref }}
file_glob: true file_glob: true


@@ -121,6 +127,9 @@ jobs:
image_tag: "armv7-musleabihf", image_tag: "armv7-musleabihf",
}, },
] ]
repository:
- path: apis/python/node
- path: binaries/cli
container: container:
image: docker://messense/rust-musl-cross:${{ matrix.platform.image_tag }} image: docker://messense/rust-musl-cross:${{ matrix.platform.image_tag }}
env: env:
@@ -136,20 +145,20 @@ jobs:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
manylinux: auto manylinux: auto
container: off container: off
args: --release -o dist
working-directory: apis/python/node
args: --release -o dist -i 3.8
working-directory: ${{ matrix.repository.path }}
- name: Upload wheels - name: Upload wheels
if: github.event_name == 'release' if: github.event_name == 'release'
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: wheels-musllinux-${{ matrix.platform.target }} name: wheels-musllinux-${{ matrix.platform.target }}
path: apis/python/node/dist
path: ${{ matrix.repository.path }}/dist
- name: Upload to release - name: Upload to release
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
file: ${{ matrix.repository.path }}/dist/*
tag: ${{ github.ref }} tag: ${{ github.ref }}
file_glob: true file_glob: true


@@ -160,6 +169,9 @@ jobs:
platform: platform:
- runner: windows-latest - runner: windows-latest
target: x64 target: x64
repository:
- path: apis/python/node
- path: binaries/cli
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
@@ -170,21 +182,21 @@ jobs:
uses: PyO3/maturin-action@v1 uses: PyO3/maturin-action@v1
with: with:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
args: --release --out dist
args: --release --out dist -i 3.8
sccache: "true" sccache: "true"
working-directory: apis/python/node
working-directory: ${{ matrix.repository.path }}
- name: Upload wheels - name: Upload wheels
if: github.event_name == 'release' if: github.event_name == 'release'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: wheels-windows-${{ matrix.platform.target }} name: wheels-windows-${{ matrix.platform.target }}
path: apis/python/node/dist
path: ${{ matrix.repository.path }}/dist
- name: Upload to release - name: Upload to release
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
file: ${{ matrix.repository.path }}/dist/*
tag: ${{ github.ref }} tag: ${{ github.ref }}
file_glob: true file_glob: true


@@ -197,6 +209,9 @@ jobs:
target: x86_64 target: x86_64
- runner: macos-14 - runner: macos-14
target: aarch64 target: aarch64
repository:
- path: apis/python/node
- path: binaries/cli
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
@@ -206,26 +221,31 @@ jobs:
uses: PyO3/maturin-action@v1 uses: PyO3/maturin-action@v1
with: with:
target: ${{ matrix.platform.target }} target: ${{ matrix.platform.target }}
args: --release --out dist
args: --release --out dist -i 3.8
sccache: "true" sccache: "true"
working-directory: apis/python/node
working-directory: ${{ matrix.repository.path }}
- name: Upload wheels - name: Upload wheels
if: github.event_name == 'release' if: github.event_name == 'release'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: wheels-macos-${{ matrix.platform.target }} name: wheels-macos-${{ matrix.platform.target }}
path: apis/python/node/dist
path: ${{ matrix.repository.path }}/dist
- name: Upload to release - name: Upload to release
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
file: ${{ matrix.repository.path }}/dist/*
tag: ${{ github.ref }} tag: ${{ github.ref }}
file_glob: true file_glob: true


sdist: sdist:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
strategy:
matrix:
repository:
- path: apis/python/node
- path: binaries/cli
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Build sdist - name: Build sdist
@@ -233,13 +253,13 @@ jobs:
with: with:
command: sdist command: sdist
args: --out dist args: --out dist
working-directory: apis/python/node
working-directory: ${{ matrix.repository.path }}
- name: Upload sdist - name: Upload sdist
if: github.event_name == 'release' if: github.event_name == 'release'
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: wheels name: wheels
path: apis/python/node/dist
path: ${{ matrix.repository.path }}/dist


release: release:
name: Release name: Release


+ 6
- 0
binaries/cli/pyproject.toml View File

@@ -0,0 +1,6 @@
[build-system]
requires = ["maturin>=0.13.2"]
build-backend = "maturin"

[project]
name = "dora-rs-cli"

+ 6
- 0
node-hub/dora-rerun/pyproject.toml View File

@@ -0,0 +1,6 @@
[build-system]
requires = ["maturin>=0.13.2"]
build-backend = "maturin"

[project]
name = "dora-rerun"

Loading…
Cancel
Save