Skip to content

Commit

Permalink
Merge pull request #206 from YuukiToriyama/release/v0.1.0-beta.11
Browse files Browse the repository at this point in the history
release/v0.1.0-beta.11をmainブランチにマージ
  • Loading branch information
YuukiToriyama authored Mar 31, 2024
2 parents 3df1d53 + 52eb740 commit 9432ad4
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 4 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/python-build-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Python module build check

on:
pull_request:

permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: x86_64
args: --release --out dist --zig
working-directory: python
sccache: 'true'
manylinux: auto

windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: x64
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: x64
args: --release --out dist
working-directory: python
sccache: 'true'

macos:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: aarch64
args: --release --out dist
working-directory: python
sccache: 'true'

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: python
1 change: 1 addition & 0 deletions .github/workflows/upload-cratesio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: crates-io
defaults:
run:
working-directory: core
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/upload-npmjs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
environment: npmjs
defaults:
run:
working-directory: wasm
Expand Down Expand Up @@ -49,4 +50,4 @@ jobs:
cd pkg
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_COM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_REGISTRY_TOKEN }}
134 changes: 134 additions & 0 deletions .github/workflows/upload-pypi-org.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Upload artifact to pypi.org

on:
push:
tags:
- 'v*'

permissions:
contents: read

jobs:
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
- runner: ubuntu-latest
target: s390x
- runner: ubuntu-latest
target: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --zig
working-directory: python
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: python/dist

windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist
working-directory: python
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: python/dist

macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist
working-directory: python
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: python/dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: python
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: python/dist

release:
name: Release
runs-on: ubuntu-latest
environment: pypi
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
MATURIN_REPOSITORY: "pypi" # test.pypi.orgにアップロードする際は"testpypi"を設定する
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
members = [
"core",
"wasm",
"tests"
"python",
"tests",
]
resolver = "2"

[workspace.package]
version = "0.1.0-beta.10"
version = "0.1.0-beta.11"
edition = "2021"
description = "A Rust Library to parse japanses addresses."
repository = "https://github.com/YuukiToriyama/japanese-address-parser"
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ init().then(() => {
})
```

## Python support(experimental)

[![PyPI - Version](https://img.shields.io/pypi/v/japanese-address-parser-py)](https://pypi.org/project/japanese-address-parser-py/)

This library can be called from Python world. For more detail, see [python module's README](python/README.md).

## Support

This software is maintained by [YuukiToriyama](https://github.com/yuukitoriyama).
Expand All @@ -78,4 +84,4 @@ by [株式会社Geolonia](https://www.geolonia.com/company/).

## License

This crate is distributed under the terms of the MIT license.
This crate is distributed under the terms of the MIT license.
20 changes: 20 additions & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "python"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
authors.workspace = true
license.workspace = true
readme = "README.md"
keywords.workspace = true
categories.workspace = true

[lib]
name = "japanese_address_parser_py"
path = "src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
japanese-address-parser = { path = "../core" }
pyo3 = { version = "0.21.0", features = ["abi3-py37"] }
94 changes: 94 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# japanese-address-parser-py
A python toolkit for processing japanese addresses

[![PyPI - Version](https://img.shields.io/pypi/v/japanese-address-parser-py)](https://pypi.org/project/japanese-address-parser-py/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/japanese-address-parser-py)](https://pypi.org/project/japanese-address-parser-py/#history)
[![Unit test & Code check](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/code-check.yaml/badge.svg)](https://github.com/YuukiToriyama/japanese-address-parser/actions/workflows/code-check.yaml)

## What is it?
**japanese-address-parser-py** is a Python package for parsing japanese addresses.
Any address can be processed into structured data.

## Installation from PyPI
```bash
pip install japanese-address-parser-py
```

## Usage

```python
import japanese_address_parser_py

address_list = [
"埼玉県さいたま市浦和区高砂3-15-1",
"千葉県千葉市中央区市場町1-1",
"東京都新宿区西新宿2-8-1",
"神奈川県横浜市中区日本大通1"
]
for address in address_list:
parse_result = japanese_address_parser_py.parse(address)
print(parse_result.address)
```

```text
{'prefecture': '埼玉県', 'town': '高砂三丁目', 'rest': '15-1', 'city': 'さいたま市浦和区'}
{'rest': '1-1', 'town': '市場町', 'prefecture': '千葉県', 'city': '千葉市中央区'}
{'prefecture': '東京都', 'rest': '8-1', 'town': '西新宿二丁目', 'city': '新宿区'}
{'town': '日本大通', 'city': '横浜市中区', 'prefecture': '神奈川県', 'rest': '1'}
```


```python
import japanese_address_parser_py

address = "神奈川県横浜市中区本町6丁目50-10"
parse_result = japanese_address_parser_py.parse(address)
print(parse_result.address["prefecture"])
print(parse_result.address["city"])
print(parse_result.address["town"])
print(parse_result.address["rest"])
```

```text
神奈川県
横浜市中区
本町六丁目
50-10
```

## Development
This library is written in Rust language. You need to set up a Rust development environment to build this library.
Also, you need to install `maturin` because this library uses it in order to generate Python bindings.

```bash
# Install maturin
cargo install --locked maturin
# Clone repository
git clone https://github.com/YuukiToriyama/japanese-address-parser.git
# Build python module
cd japanse-address-parser/python
maturin build --release --out dist --find-interpreter
# Install the built library
python3 -m venv .venv
pip3 install dist/japanese_address_parser_py-[version]-cp37-abi3-[arch].whl
```

## Support

This software is maintained by [YuukiToriyama](https://github.com/yuukitoriyama).
If you have questions, please create an issue.

## Where to get source code
The source code is hosted on GitHub at:
https://github.com/YuukiToriyama/japanese-address-parser

## Acknowledgements

This software was developed inspired
by [@geolonia/normalize-japanese-addresses](https://github.com/geolonia/normalize-japanese-addresses).
Also, the parsing process uses [Geolonia 住所データ](https://github.com/geolonia/japanese-addresses) provided
by [株式会社Geolonia](https://www.geolonia.com/company/).

## License

This crate is distributed under the terms of the MIT license.
14 changes: 14 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[build-system]
requires = ["maturin>=1.5,<2.0"]
build-backend = "maturin"

[project]
name = "japanese-address-parser-py"
keywords = ["converter", "utility", "geo", "rust"]
classifiers = [
"Topic :: Text Processing",
"Programming Language :: Rust"
]

[tool.maturin]
features = ["pyo3/extension-module"]
Loading

0 comments on commit 9432ad4

Please sign in to comment.