Skip to content

Commit 564b4fb

Browse files
committed
DRAFT: Update build tools
Let's use pyproject.toml TICO-DCO-1.0-Signed-off-by: Dayoung Lee <dayoung.lee@samsung.com>
1 parent e49ffdb commit 564b4fb

File tree

9 files changed

+83
-64
lines changed

9 files changed

+83
-64
lines changed

.github/workflows/check-pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
104104
- name: "Build package"
105105
run: |
106-
pip install setuptools
106+
pip install build
107107
./ccex build
108108
109109
- name: "Run install"

.github/workflows/publish-nightly-package.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ jobs:
1515
ubuntu_version: [22.04]
1616
steps:
1717
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Import all commit history and tag
1820

1921
- name: "Build package"
2022
run: |
21-
NIGHTLY_VERSION=$(date '+%y%m%d')
22-
export NIGHTLY_VERSION
23-
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> "$GITHUB_ENV"
2423
./ccex build
2524
2625
- name: "Upload artifact"

.github/workflows/publish-official-package.yaml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,42 @@ jobs:
1313
runs-on: ubuntu-22.04
1414

1515
steps:
16-
- name: Checkout the specified ref
16+
- name: "Checkout the specified ref"
1717
uses: actions/checkout@v4
1818
with:
1919
ref: ${{ inputs.ref_name }}
20+
fetch-depth: 0 # Import all commit history and tag
2021

21-
# Verify version consistency between tag and version.py
22-
- name: Check version.py matches ref_name
22+
- name: "Build package"
23+
run: |
24+
./ccex build
25+
26+
- name: "Check requested version (ref_name)"
2327
run: |
24-
FILE_VERSION=$(python -c 'exec(open("version.py").read()); print(VERSION)')
2528
INPUT_REF="${{ inputs.ref_name }}"
2629
TAG_VERSION="${INPUT_REF#v}" # Strip leading 'v' from ref_name
2730
28-
echo "VERSION in version.py: $FILE_VERSION"
31+
VERSION="$(versioningit)"
32+
CLEAN_VERSION="$(echo "$VERSION" | cut -d'.' -f1-3)"
33+
34+
echo "$CLEAN_VERSION"
35+
36+
echo "VERSION from prepared package: $CLEAN_VERSION"
2937
echo "VERSION from ref_name: $TAG_VERSION"
3038
31-
if [ "$FILE_VERSION" != "$TAG_VERSION" ]; then
32-
echo "::error::VERSION in version.py ($FILE_VERSION) does not match ref_name ($INPUT_REF)"
39+
if [ "$CLEAN_VERSION" != "$TAG_VERSION" ]; then
40+
echo "::error::VERSION($CLEAN_VERSION) of current package does not match your requested ref_name ($INPUT_REF)"
3341
exit 1
3442
fi
3543
36-
- name: "Build package"
37-
run: |
38-
./ccex build
39-
4044
- name: "Upload artifact"
4145
uses: actions/upload-artifact@v4
4246
with:
4347
name: "wheel"
4448
path: "./dist/"
4549

4650
publish-to-pypi:
51+
4752
needs:
4853
- build-and-upload
4954
runs-on: ubuntu-22.04

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ __pycache__/
55
# Distribution
66
build/
77
dist/
8+
*/_version.py
89
*.egg-info/
910
.eggs/
1011

infra/scripts/build.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
python3 setup.py bdist_wheel --dist-dir dist
1+
#!/bin/bash
2+
3+
# Install Required Package
4+
#
5+
# NOTE To add additional build dependencies, append to `requires` field of [build-system] in pyproject.toml
6+
python3 -m pip install build
7+
8+
# Build
9+
python3 -m build

pyproject.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "versioningit"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "tico"
7+
dynamic = ["version"] # To use 'versioningit' to obtain version details
8+
description = "Convert Exported Torch Module To Circle"
9+
readme = "README.md"
10+
requires-python = ">=3.10.0"
11+
license = {file = "LICENSE"}
12+
dependencies = [
13+
"circle-schema",
14+
"packaging",
15+
"cffi",
16+
"torch",
17+
"pyyaml",
18+
"tqdm",
19+
]
20+
21+
[project.scripts]
22+
pt2-to-circle = "tico.pt2_to_circle:main"
23+
24+
[tool.setuptools]
25+
# Automatic package discovery (replaces the old find_packages role)
26+
packages = {find = {include = ["tico*"]}}
27+
28+
# ==========================================
29+
# versioningit
30+
# ==========================================
31+
[tool.versioningit]
32+
default-version = "0.1.0"
33+
34+
[tool.versioningit.vcs]
35+
method = "git"
36+
match = ["v*"] # Only recognize tags starting with 'v' (e.g., v0.1.0)
37+
38+
[tool.versioningit.next-version]
39+
# 태그 이후 커밋이 발생하면 무조건 Minor 버전을 올림 (0.1.0 -> 0.2.0)
40+
method = "minor"
41+
42+
[tool.versioningit.format]
43+
# 1. 정식 태그가 찍힌 경우: 0.1.0
44+
# 2. 태그 이후 커밋이 있는 경우: 0.2.0.dev260112 (다음버전 + .dev + 날짜)
45+
distance = "{next_version}.dev{committer_date:%y%m%d}"
46+
# 3. 로컬에서 수정 중인 파일이 있는 경우 (+dirty 추가)
47+
dirty = "{next_version}.dev{committer_date:%y%m%d}+dirty"
48+
distance-dirty = "{next_version}.dev{committer_date:%y%m%d}+dirty"
49+
50+
[tool.versioningit.write]
51+
# 빌드 시 버전을 기록할 파일 (tico/__init__.py에서 참조 가능)
52+
file = "tico/_version.py"

setup.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

tico/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"convert_from_pt2",
2929
]
3030

31-
# THIS LINE IS AUTOMATICALLY GENERATED BY setup.py
32-
__version__ = "0.1.0"
31+
# THIS LINE IS AUTOMATICALLY GENERATED
32+
__version__ = "0.2.0"
3333

3434
MINIMUM_SUPPORTED_VERSION = "2.5.0"
3535
SECURE_TORCH_VERSION = "2.6.0"

version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)