Skip to content

Commit 5c6bf60

Browse files
author
Gal Ben David
committed
upload source distribution to support more platforms. update dependencies. update github actions workflows
1 parent ca360cd commit 5c6bf60

File tree

6 files changed

+51
-30
lines changed

6 files changed

+51
-30
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
name: Build
2-
on: [push, pull_request]
2+
on:
3+
- push
4+
- pull_request
35
jobs:
46
lint:
57
if: github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags')
68
runs-on: ubuntu-latest
79
steps:
810
- name: Checkout
9-
uses: actions/checkout@v2
11+
uses: actions/checkout@v3
1012
- name: Install latest rust
1113
uses: actions-rs/toolchain@v1
1214
with:
1315
toolchain: stable
16+
profile: minimal
1417
override: true
1518
components: clippy
1619
- name: Lint with clippy
@@ -24,25 +27,33 @@ jobs:
2427
strategy:
2528
fail-fast: false
2629
matrix:
27-
python-version: ['3.7', '3.8', '3.9', '3.10']
28-
os: [ubuntu-latest , macos-latest, windows-latest]
30+
python-version:
31+
- '3.7'
32+
- '3.8'
33+
- '3.9'
34+
- '3.10'
35+
os:
36+
- ubuntu-latest
37+
- macos-latest
38+
- windows-latest
2939
steps:
3040
- name: Checkout
31-
uses: actions/checkout@v2
41+
uses: actions/checkout@v3
3242
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v2
43+
uses: actions/setup-python@v3
3444
with:
3545
python-version: ${{ matrix.python-version }}
36-
- name: Run image
37-
uses: abatilo/actions-poetry@v2.0.0
38-
- name: Install latest rust
46+
- name: Install Poetry
47+
uses: abatilo/actions-poetry@v2.1.3
48+
- name: Install Rust
3949
uses: actions-rs/toolchain@v1
4050
with:
51+
profile: minimal
4152
toolchain: stable
4253
override: true
4354
- name: Install dependencies
4455
run: poetry install
4556
- name: Build Python package
4657
run: poetry run maturin develop
4758
- name: Test
48-
run: poetry run pytest tests
59+
run: poetry run pytest -Werror tests

.github/workflows/deploy.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
11
name: Deploy
22
on:
33
release:
4-
types: [published]
5-
workflow_dispatch:
4+
types:
5+
- released
66
jobs:
77
deploy:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ['3.7', '3.8', '3.9', '3.10']
13-
os: [ubuntu-latest, macos-latest, windows-latest]
12+
python-version:
13+
- '3.7'
14+
- '3.8'
15+
- '3.9'
16+
- '3.10'
17+
os:
18+
- ubuntu-latest
19+
- macos-latest
20+
- windows-latest
1421
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions/setup-python@v2
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v3
1726
with:
1827
python-version: ${{ matrix.python-version }}
19-
- name: Install latest rust
28+
- name: Install Rust
2029
uses: actions-rs/toolchain@v1
2130
with:
31+
profile: minimal
2232
toolchain: stable
2333
override: true
24-
- name: Build & Publish to PyPi
34+
- name: Publish Package
2535
uses: messense/maturin-action@v1
2636
with:
27-
maturin-version: latest
2837
command: publish
29-
args: --username __token__ --no-sdist --interpreter python
38+
args: --username=__token__ ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.7' && '--no-sdist' || '' }} --interpreter=python${{ !startsWith(matrix.os, 'windows') && matrix.python-version || '' }}
3039
env:
3140
MATURIN_PASSWORD: ${{ secrets.pypi_password }}

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pywordsegment"
3-
version = "0.2.1"
3+
version = "0.3.0"
44
authors = ["Gal Ben David <[email protected]>"]
55
edition = "2021"
66
description = "Concatenated-word segmentation Python library written in Rust"
@@ -35,10 +35,10 @@ crate-type = ["cdylib"]
3535

3636
[dependencies]
3737
ahash = "0.7"
38-
rmp-serde = "0.15"
38+
rmp-serde = "1"
3939

4040
[dependencies.pyo3]
41-
version = "0.15.1"
41+
version = "0.16.5"
4242
features = ["extension-module"]
4343

4444
[profile.release]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Gal Ben David
3+
Copyright (c) 2022 Gal Ben David
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
[build-system]
2-
requires = ["maturin>=0.11,<0.12"]
2+
requires = ["maturin>=0.12,<0.13"]
33
build-backend = "maturin"
44

55
[tool.maturin]
66
sdist-include = [
7-
"src/*",
87
"Cargo.toml",
8+
"pyproject.toml",
9+
"pywordsegment/*.gz",
910
"pywordsegment/*.py",
1011
"pywordsegment/*.pyi",
11-
"pywordsegment/*.txt"
12+
"src/*",
1213
]
1314

1415
[tool.poetry]
1516
name = "pywordsegment"
16-
version = "0.2.1"
17+
version = "0.3.0"
1718
authors = ["Gal Ben David <[email protected]>"]
1819
description = "Concatenated-word segmentation Python library written in Rust"
1920
readme = "README.md"

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ impl WordSegmenter {
1818
unigrams_serialized: &[u8],
1919
bigrams_serialized: &[u8],
2020
) -> Self {
21-
let unigrams: HashMap<String, f64, RandomState> = rmp_serde::from_read_ref(unigrams_serialized).unwrap();
22-
let bigrams = rmp_serde::from_read_ref(bigrams_serialized).unwrap();
21+
let unigrams: HashMap<String, f64, RandomState> = rmp_serde::from_slice(unigrams_serialized).unwrap();
22+
let bigrams = rmp_serde::from_slice(bigrams_serialized).unwrap();
2323

2424
let total_unigrams_frequency = unigrams.get("unigrams_total_count").unwrap();
2525
let mut unknown_unigrams = [0.0; MAX_WORD_LEN + 1];

0 commit comments

Comments
 (0)