Skip to content

Commit d07b21b

Browse files
authored
Wraps as a package and publish to PyPI (#16)
* add `__version__` * add torch related packages * add `pyproject.toml` * add shortcuts * add workflows * use python `3.10` for cicd * add quotes * fix incorrect cli of `ruff` * change condition to trigger CD
1 parent 036739a commit d07b21b

File tree

5 files changed

+202
-1
lines changed

5 files changed

+202
-1
lines changed

.github/workflows/cd.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
name: Build distribution
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.10"
19+
- name: Install pypa/build
20+
run: >-
21+
python3 -m
22+
pip install
23+
build
24+
--user
25+
- name: Build a binary wheel and a source tarball
26+
run: python3 -m build
27+
- name: Store the distribution packages
28+
uses: actions/upload-artifact@v3
29+
with:
30+
name: python-package-distributions
31+
path: dist/
32+
33+
publish-to-pypi:
34+
name: >-
35+
Publish Python distribution 📦 to PyPI
36+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
37+
needs:
38+
- build
39+
runs-on: ubuntu-latest
40+
environment:
41+
name: pypi
42+
url: https://pypi.org/p/wpodnet-pytorch
43+
permissions:
44+
id-token: write # IMPORTANT: mandatory for trusted publishing
45+
46+
steps:
47+
- name: Download all the dists
48+
uses: actions/download-artifact@v3
49+
with:
50+
name: python-package-distributions
51+
path: dist/
52+
- name: Publish distribution to PyPI
53+
uses: pypa/gh-action-pypi-publish@release/v1
54+
55+
github-release:
56+
name: >-
57+
Sign the Python distribution with Sigstore
58+
and upload them to GitHub Release
59+
needs:
60+
- publish-to-pypi
61+
runs-on: ubuntu-latest
62+
63+
permissions:
64+
contents: write # IMPORTANT: mandatory for making GitHub Releases
65+
id-token: write # IMPORTANT: mandatory for sigstore
66+
67+
steps:
68+
- name: Download all the dists
69+
uses: actions/download-artifact@v3
70+
with:
71+
name: python-package-distributions
72+
path: dist/
73+
- name: Sign the dists with Sigstore
74+
uses: sigstore/[email protected]
75+
with:
76+
inputs: >-
77+
./dist/*.tar.gz
78+
./dist/*.whl
79+
- name: Create GitHub Release
80+
env:
81+
GITHUB_TOKEN: ${{ github.token }}
82+
run: >-
83+
gh release create
84+
'${{ github.ref_name }}'
85+
--repo '${{ github.repository }}'
86+
--notes ""
87+
- name: Upload artifact signatures to GitHub Release
88+
env:
89+
GITHUB_TOKEN: ${{ github.token }}
90+
# Upload to GitHub Release using the `gh` CLI.
91+
# `dist/` contains the built packages, and the
92+
# sigstore-produced signatures and certificates.
93+
run: >-
94+
gh release upload
95+
'${{ github.ref_name }}' dist/**
96+
--repo '${{ github.repository }}'

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Set up Python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: "3.10"
14+
- name: Install dependencies
15+
run: |
16+
pip install --upgrade pip
17+
pip install -r requirements.txt
18+
- name: Lint with Ruff
19+
run: |
20+
pip install ruff
21+
ruff -- --format=github .
22+
continue-on-error: true
23+
test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Set up Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: "3.10"
31+
- name: Install dependencies
32+
run: |
33+
pip install --upgrade pip
34+
pip install -r requirements.txt
35+
- name: Test with pytest
36+
run: |
37+
pip install pytest pytest-cov pytest-mock
38+
python -m pytest --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html

pyproject.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "wpodnet-pytorch"
7+
dynamic = ["dependencies", "version"]
8+
description = "The implementation of ECCV 2018 paper \"License Plate Detection and Recognition in Unconstrained Scenarios\" in PyTorch"
9+
readme = "README.md"
10+
requires-python = ">=3.7"
11+
keywords = [
12+
"python",
13+
"ai",
14+
"computer-vision",
15+
"deep-learning",
16+
"torch",
17+
"object-detection",
18+
"license-plate-recognition",
19+
"wpod",
20+
"wpod-net",
21+
]
22+
authors = [{ name = "Pandede" }]
23+
maintainers = [{ name = "Pandede" }]
24+
classifiers = [
25+
"Development Status :: 4 - Beta",
26+
"Intended Audience :: Developers",
27+
"Intended Audience :: Education",
28+
"Intended Audience :: Science/Research",
29+
"Programming Language :: Python :: 3",
30+
"Programming Language :: Python :: 3.6",
31+
"Programming Language :: Python :: 3.7",
32+
"Programming Language :: Python :: 3.8",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Topic :: Software Development",
37+
"Topic :: Scientific/Engineering",
38+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
39+
"Topic :: Scientific/Engineering :: Image Recognition",
40+
"Operating System :: POSIX :: Linux",
41+
"Operating System :: MacOS",
42+
"Operating System :: Microsoft :: Windows",
43+
]
44+
45+
[tool.setuptools]
46+
packages = { find = { where = ["."], include = ["wpodnet", "wpodnet.*"] } }
47+
48+
[tool.setuptools.dynamic]
49+
dependencies = { file = "requirements.txt" }
50+
version = { attr = "wpodnet.__version__" }
51+
52+
[project.optional-dependencies]
53+
dev = [
54+
"pytest"
55+
]
56+
57+
[project.urls]
58+
"Source" = "https://github.com/Pandede/WPODNet-Pytorch"

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
numpy
2-
Pillow
2+
Pillow
3+
torch
4+
torchvision

wpodnet/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__version__ = '1.0.2'
2+
3+
from .backend import Prediction, Predictor
4+
5+
__all__ = [
6+
'Prediction', 'Predictor'
7+
]

0 commit comments

Comments
 (0)