Skip to content

Conversation

@zephyr-sh
Copy link
Contributor

摘要

本 PR 將 PyFace 的發佈流程全面更新,採用現代化的建置方式(cibuildwheel),並同步清理舊有設定,確保套件能正確地在 PyPI 上發佈並支援新版依賴(如 NumPy 2)。


主要變更

🛠️ GitHub Actions Workflow

  • 工作名稱從 Release 改為 release(符合命名慣例)。

  • 移除 Python 版本矩陣,改由 cibuildwheel 控制建置:

    • CIBW_BUILD: cp310-* cp311-* cp312-*
    • CIBW_SKIP: 跳過 PyPy 與 musllinux
    • CIBW_ARCHS: 限定 x86_64
    • CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
  • 安裝建置工具:buildtwinecibuildwheel

  • 流程調整:

    • 版本號更新建立 sdist建置 wheels檢查並上傳 PyPI
  • 發佈至 GitHub Release 時,會同時附上 .tar.gz.whl

  • 新增檔案清理步驟,確保 dist/wheelhouse/*.egg-info 不殘留。


📦 套件與中繼資料

  • 專案名稱由 pyface 改為 pyface-docsaid(避免 PyPI 命名衝突)。

  • 新增 MANIFEST.in

    • 包含 README.mdLICENSE
    • 收錄 Sim3DR 相關 Cython 檔案(*.pyx*.pxd*.h*.cpp
  • 更新 pyproject.toml

    • 依賴調整:

      • setuptools>=69
      • Cython>=3.0.10
      • numpy>=2(建置與執行期都支援 NumPy 2)
    • 依賴名稱統一:capybara-docsaid(與 setup.cfg 對齊)

    • metadata 格式修正(license、authors 等)。

    • 明確包含 pyface* 套件。

  • 移除舊有 setup.cfg

  • 版本號更新:0.1.00.1.2


⚙️ 建置系統(setup.py)

  • 移除過去在建置時動態安裝套件的 hack。

  • 新增 include paths:NumPy header、Python header、Sim3DR。

  • 使用 cythonize 時設定 language_level=3

  • 編譯目標調整為:

    pyface.components.face_depth.Sim3DR.sim3dr_cython
    
  • 確保相容於新版 Cython 與 NumPy。


🧹 其他修正

  • .gitignore:忽略 Sim3DR 產生的 C/C++ 檔案。
  • CI 中版本號 commit 步驟更明確。
  • 發佈流程中的清理步驟保證環境乾淨。

動機

  • 確保 PyPI 套件能正確建置與發佈(含 sdist + wheels)。
  • 正式支援 NumPy 2
  • 提供 manylinux 預建 wheels,減少使用者本地編譯負擔。
  • 移除重複、過時的設定檔,簡化維護。

預期影響

  • 使用者能直接 pip install pyface-docsaid 並獲得預建 wheels。
  • PyPI 發佈品包含完整的 sdist 與 wheels。
  • 套件命名與相依套件更一致,不會造成混淆。
  • 建置流程更穩定、可重現。

Checklist

  • 使用 cibuildwheel 成功建置 Linux wheels
  • 透過 twine check 驗證發佈檔案
  • PyPI artifacts 包含 .tar.gz + .whl
  • 移除舊有 setup.cfg
  • 版本更新至 0.1.2

@zephyr-sh zephyr-sh requested review from Copilot and kunkunlin1221 and removed request for Copilot August 26, 2025 02:40
@zephyr-sh zephyr-sh self-assigned this Aug 26, 2025
Copilot AI review requested due to automatic review settings August 26, 2025 02:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes PyFace's packaging and PyPI release workflow by adopting cibuildwheel for cross-platform wheel building, updating dependencies to support NumPy 2, and renaming the package to avoid PyPI conflicts. The changes ensure proper PyPI distribution with both source distributions and pre-built wheels.

  • Migrated from manual wheel building to cibuildwheel for standardized Linux wheel generation
  • Updated package dependencies to support NumPy 2 and modern Python tooling
  • Renamed package from "pyface" to "pyface-docsaid" to avoid PyPI naming conflicts

Reviewed Changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
setup.py Refactored build system to handle NumPy 2 compatibility and proper include paths
setup.cfg Removed legacy configuration file in favor of pyproject.toml
pyproject.toml Updated package metadata, dependencies, and build requirements
pyface/init.py Bumped version from 0.1.0 to 0.1.2
MANIFEST.in Added manifest to include necessary files in source distribution
.github/workflows/release.yml Modernized CI workflow to use cibuildwheel and proper PyPI publishing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

setup.py Outdated
import subprocess
import sys

subprocess.check_call([sys.executable, "-m", "pip", "install", "numpy>2.0"])
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version constraint 'numpy>2.0' excludes NumPy 2.0.x versions. This should be 'numpy>=2.0' to include NumPy 2.0 and later versions, consistent with the pyproject.toml dependency specification.

Suggested change
subprocess.check_call([sys.executable, "-m", "pip", "install", "numpy>2.0"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "numpy>=2.0"])

Copilot uses AI. Check for mistakes.
"pyface/components/face_depth/Sim3DR",
np.get_include(),
]
# 有些 runner 只放其中一個,把能拿到的全加進去
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment is in Chinese but the codebase appears to use English comments elsewhere. Consider translating to English: '# Some runners only have one of these, add all available paths'

Suggested change
# 有些 runner 只放其中一個,把能拿到的全加進去
# Some runners only have one of these, add all available paths

Copilot uses AI. Check for mistakes.
pyproject.toml Outdated
"setuptools>=69",
"wheel",
"Cython>=3.0.10",
"numpy>=2" # 建置時使用 NumPy 2 的 header
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment is in Chinese. Consider translating to English: '# Use NumPy 2 headers during build'

Suggested change
"numpy>=2" # 建置時使用 NumPy 2 的 header
"numpy>=2" # Use NumPy 2 headers during build

Copilot uses AI. Check for mistakes.
"Topic :: Software Development :: Libraries :: Python Modules"
]
dependencies = [
"numpy>=2", # 執行期也支援 NumPy 2
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment is in Chinese. Consider translating to English: '# Runtime also supports NumPy 2'

Suggested change
"numpy>=2", # 執行期也支援 NumPy 2
"numpy>=2", # Runtime also supports NumPy 2

Copilot uses AI. Check for mistakes.
pyproject.toml Outdated
"numpy>=2", # 執行期也支援 NumPy 2
"scikit-image",
"capybara_docsaid",
"capybara-docsaid", # ← 與 setup.cfg 統一,使用連字號
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment is in Chinese and references the now-deleted setup.cfg file. Consider updating to English: '# Use hyphen for consistency'

Suggested change
"capybara-docsaid", # ← 與 setup.cfg 統一,使用連字號
"capybara-docsaid", # Use hyphen for consistency

Copilot uses AI. Check for mistakes.
@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch 3 times, most recently from a42cb78 to 854c838 Compare August 26, 2025 02:51
@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch from 854c838 to 5410158 Compare August 26, 2025 02:53
@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch 4 times, most recently from 06b56b5 to 3f2d4f8 Compare August 26, 2025 11:07
@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
pyface
   __init__.py50100% 
   face_service.py1038686 17%
   object.py1639494 42%
   utils.py2677 73%
pyface/components
   __init__.py70100% 
   enums.py260100% 
   face_gender.py755656 25%
   face_normalization.py533737 30%
   utils.py442727 39%
pyface/components/face_depth
   __init__.py733 57%
   tddfav2.py228192192 16%
pyface/components/face_detection
   __init__.py711 86%
   draw.py422727 36%
   nms.py250100% 
   scrfd.py11888 93%
pyface/components/face_landmark
   __init__.py733 57%
   coordinate_reg.py1127979 29%
   utils.py362525 31%
pyface/components/face_recognition
   __init__.py933 67%
   arcface.py674646 31%
   compare.py412121 49%
   utils.py251212 52%
TOTAL122672741% 

Tests Skipped Failures Errors Time
4 0 💤 0 ❌ 0 🔥 11.150s ⏱️

@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch 12 times, most recently from 10fcc64 to 6a177f0 Compare August 26, 2025 12:12
@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch 6 times, most recently from bf3e097 to 1fe7814 Compare August 26, 2025 14:16
@kunkunlin1221 kunkunlin1221 self-assigned this Aug 26, 2025
@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch 3 times, most recently from e81d6ce to 05f5723 Compare August 26, 2025 14:44
@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch 10 times, most recently from 07e4b8c to d485e94 Compare August 26, 2025 17:14
@kunkunlin1221 kunkunlin1221 force-pushed the feat/add_pypi_release_and_fix_rasterize_error branch from d485e94 to d10f16b Compare August 26, 2025 17:17
@kunkunlin1221
Copy link
Collaborator

This pull request refactors the CI/CD workflows to improve platform support, modularity, and maintainability. It splits the previous monolithic CI workflow into separate CPU and CUDA workflows, updates the release workflow to build and publish wheels for multiple platforms, and makes supporting code changes for consistency and usability. Additionally, it updates model class initializers for clarity and improves packaging.

Workflow and CI/CD Improvements:

  • Split CI into two workflows: cpu-ci.yml for multi-platform CPU builds (Ubuntu, macOS) and cuda-ci.yml for GPU builds on self-hosted runners. Both workflows cover Python 3.10 and 3.12, run linting and tests, and clean up artifacts. (.github/workflows/cpu-ci.yml, .github/workflows/cuda-ci.yml) [1] [2]
  • Removed the old monolithic pull_request.yml workflow, which previously handled Docker-based CI and testing.

Release Process Modernization:

  • Refactored release.yml to build wheels for multiple platforms using cibuildwheel, upload them as artifacts, and publish them to GitHub Releases and PyPI. The workflow now uses a matrix for OS, always builds with Python 3.12, and attaches all wheel artifacts to the release. [1] [2] [3]

Packaging and Build Improvements:

  • Updated MANIFEST.in to include the license, README, and necessary Cython source files for proper packaging of the Sim3DR component.
  • Simplified Dockerfile by removing direct package build/install steps and preloading, making it more flexible for CI/CD.

Codebase Consistency and Usability:

  • Changed all model class initializers to use the argument name model_name instead of model_version for clarity, and updated internal logic to match. (pyface/components/face_depth/tddfav2.py, pyface/components/face_detection/scrfd.py, pyface/components/face_gender.py, pyface/components/face_landmark/coordinate_reg.py, pyface/components/face_recognition/arcface.py) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Updated imports in pyface/__init__.py and component modules for consistency and to expose all utilities. [1] [2]
  • Added docstrings and improved type hints for functions in tddfav2.py for better usability and documentation. [1] [2] [3]

These changes together modernize the project's CI/CD pipeline, improve release reliability, and make the codebase easier to maintain and use.

@kunkunlin1221 kunkunlin1221 added the enhancement New feature or request label Aug 26, 2025
Copy link
Collaborator

@kunkunlin1221 kunkunlin1221 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kunkunlin1221 kunkunlin1221 merged commit 29ab5d0 into main Aug 26, 2025
8 checks passed
@kunkunlin1221 kunkunlin1221 deleted the feat/add_pypi_release_and_fix_rasterize_error branch August 26, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants