generated from njzjz/python-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jinzhe Zeng <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d0b3209
commit 0d51c62
Showing
5 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,49 @@ jobs: | |
with: | ||
name: release-dists | ||
path: dist/ | ||
release-wheel: | ||
name: Build wheels for cp${{ matrix.python }}-${{ matrix.platform_id }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
# linux-64 | ||
- os: ubuntu-latest | ||
python: 312 | ||
platform_id: manylinux_x86_64 | ||
# macos-x86-64 | ||
- os: macos-13 | ||
python: 312 | ||
platform_id: macosx_x86_64 | ||
# macos-arm64 | ||
- os: macos-14 | ||
python: 312 | ||
platform_id: macosx_arm64 | ||
# win-64 | ||
- os: windows-2019 | ||
python: 312 | ||
platform_id: win_amd64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up uv | ||
uses: astral-sh/setup-uv@v3 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: | | ||
**/requirements*.txt | ||
**/pyproject.toml | ||
if: runner.os != 'Linux' | ||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_ARCHS: all | ||
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} | ||
CIBW_BUILD_FRONTEND: "build[uv]" | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: release-cibw-cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ strategy.job-index }} | ||
path: ./wheelhouse/*.whl | ||
pypi-publish: | ||
name: Release to pypi | ||
runs-on: ubuntu-latest | ||
|
@@ -37,13 +80,15 @@ jobs: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
needs: | ||
- release-build | ||
- release-wheel | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Retrieve release distributions | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: release-dists | ||
merge-multiple: true | ||
pattern: release-* | ||
path: dist/ | ||
- name: Publish release distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Customized PEP-517 build backend.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
"""A PEP-517 backend to add customized dependencies.""" | ||
|
||
import os | ||
|
||
from scikit_build_core import build as _orig | ||
|
||
__all__ = [ | ||
"build_sdist", | ||
"build_wheel", | ||
"get_requires_for_build_sdist", | ||
"get_requires_for_build_wheel", | ||
"prepare_metadata_for_build_wheel", | ||
"prepare_metadata_for_build_editable", | ||
"build_editable", | ||
"get_requires_for_build_editable", | ||
] | ||
|
||
|
||
def __dir__() -> list[str]: | ||
return __all__ | ||
|
||
|
||
prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel | ||
build_wheel = _orig.build_wheel | ||
build_sdist = _orig.build_sdist | ||
get_requires_for_build_sdist = _orig.get_requires_for_build_sdist | ||
prepare_metadata_for_build_editable = _orig.prepare_metadata_for_build_editable | ||
build_editable = _orig.build_editable | ||
get_requires_for_build_editable = _orig.get_requires_for_build_editable | ||
|
||
|
||
def cibuildwheel_dependencies() -> list[str]: | ||
if os.environ.get("CIBUILDWHEEL", "0") == "1": | ||
return [ | ||
"deepmd-kit[torch]>=3.0.0b2", | ||
] | ||
return [] | ||
|
||
|
||
def get_requires_for_build_wheel( | ||
config_settings: dict, | ||
) -> list[str]: | ||
"""Return the dependencies for building a wheel.""" | ||
return ( | ||
_orig.get_requires_for_build_wheel(config_settings) | ||
+ cibuildwheel_dependencies() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters