mirror of
https://github.com/visioncortex/vtracer.git
synced 2025-12-06 17:15:41 -08:00
Python Bindings. Again. No, really! (#55)
* - Cargo.toml: add `crate-type = ["cdylib"] to [lib]; lacking this is what was causing the executable to be put in wheels - pyproject.toml: add "python-binding" to features for conditional compilation - main.rs: `cargo build` was failing for the vtracer executable; I think the previous import scheme had an implicit dependency on the library being built and called 'vtracer'. The other way to do this would have been to add an explicit dependency to the [[bin]], but making explicit imports here solves things directly * re-enable linux builds; features are defined in the pyproject.toml now rather than in the workflow arguments * And publish Linux, too!
This commit is contained in:
50
.github/workflows/python.yml
vendored
50
.github/workflows/python.yml
vendored
@@ -16,28 +16,28 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# linux:
|
linux:
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# strategy:
|
strategy:
|
||||||
# matrix:
|
matrix:
|
||||||
# target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
|
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
|
||||||
# steps:
|
steps:
|
||||||
# - uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
# - uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
# with:
|
with:
|
||||||
# python-version: '3.10'
|
python-version: '3.10'
|
||||||
# - name: Build wheels
|
- name: Build wheels
|
||||||
# uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
# with:
|
with:
|
||||||
# target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
# args: -m cmdapp/Cargo.toml --release --features=python-binding --out dist --find-interpreter
|
args: -m cmdapp/Cargo.toml --release --out dist --find-interpreter
|
||||||
# sccache: 'true'
|
sccache: 'true'
|
||||||
# manylinux: auto
|
manylinux: auto
|
||||||
# - name: Upload wheels
|
- name: Upload wheels
|
||||||
# uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
# with:
|
with:
|
||||||
# name: wheels
|
name: wheels
|
||||||
# path: dist
|
path: dist
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
args: -m cmdapp/Cargo.toml --release --features=python-binding --out dist --find-interpreter
|
args: -m cmdapp/Cargo.toml --release --out dist --find-interpreter
|
||||||
sccache: 'true'
|
sccache: 'true'
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@@ -76,7 +76,7 @@ jobs:
|
|||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
args: -m cmdapp/Cargo.toml --release --features=python-binding --out dist --find-interpreter
|
args: -m cmdapp/Cargo.toml --release --out dist --find-interpreter
|
||||||
sccache: 'true'
|
sccache: 'true'
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@@ -108,7 +108,7 @@ jobs:
|
|||||||
# IMPORTANT: this permission is mandatory for trusted publishing
|
# IMPORTANT: this permission is mandatory for trusted publishing
|
||||||
id-token: write
|
id-token: write
|
||||||
if: "startsWith(github.ref, 'refs/tags/')"
|
if: "startsWith(github.ref, 'refs/tags/')"
|
||||||
needs: [windows, macos, sdist] # linux
|
needs: [windows, macos, sdist, linux]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -18,4 +18,8 @@ fastrand = "1.8"
|
|||||||
pyo3 = { version = "0.19.0", optional = true }
|
pyo3 = { version = "0.19.0", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
python-binding = ["pyo3"]
|
python-binding = ["pyo3"]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "vtracer"
|
||||||
|
crate-type = ["cdylib"]
|
||||||
@@ -23,6 +23,6 @@ requires = ["maturin>=1.2,<2.0"]
|
|||||||
build-backend = "maturin"
|
build-backend = "maturin"
|
||||||
|
|
||||||
[tool.maturin]
|
[tool.maturin]
|
||||||
features = ["pyo3/extension-module"]
|
features = ["pyo3/extension-module", "python-binding"]
|
||||||
compatibility = "manylinux2014"
|
compatibility = "manylinux2014"
|
||||||
sdist-include = ["LICENSE-MIT", "vtracer/README.md"]
|
sdist-include = ["LICENSE-MIT", "vtracer/README.md"]
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
use vtracer::{Config, convert_image_to_svg};
|
mod config;
|
||||||
|
mod converter;
|
||||||
|
mod svg;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config = Config::from_args();
|
let config = config::Config::from_args();
|
||||||
let result = convert_image_to_svg(config);
|
let result = converter::convert_image_to_svg(config);
|
||||||
match result {
|
match result {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
println!("Conversion successful.");
|
println!("Conversion successful.");
|
||||||
|
|||||||
Reference in New Issue
Block a user