♻️ refactor: hard written target_arch、target_os_info#14
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors how target architecture and OS information is handled, aligning it with the PyPI tag requirements and updating the related build and release configurations.
- Update version in pyproject.toml from "0.16.0-alpha.0" to "0.16.0-alpha.1".
- Refactor target detection in hatch_build.py by using a BUILD_TARGET mapping instead of automated platform detection.
- Update GitHub Actions workflows in release.yaml to utilize the new platform tag and architecture fields.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyproject.toml | Version update for release. |
| hatch_build.py | Refactored target_arch and target_os_info retrieval and validation using BUILD_TARGET mapping. |
| .github/workflows/release.yaml | CI workflow matrix updated to use new platform_tag and arch fields. |
Comment on lines
+43
to
+44
| assert target_arch is not None, f"CIBW_ARCHS not set see: {BUILD_TARGET}" | ||
| assert target_os_info is not None, f"CIBW_PLATFORM not set see: {BUILD_TARGET}" |
There was a problem hiding this comment.
Using 'assert' for checking environment variables may lead to it being bypassed in optimized mode; consider replacing it with an explicit condition that raises a proper exception.
Suggested change
| assert target_arch is not None, f"CIBW_ARCHS not set see: {BUILD_TARGET}" | |
| assert target_os_info is not None, f"CIBW_PLATFORM not set see: {BUILD_TARGET}" | |
| if target_arch is None: | |
| raise RuntimeError(f"CIBW_ARCHS not set. See: {BUILD_TARGET}") | |
| if target_os_info is None: | |
| raise RuntimeError(f"CIBW_PLATFORM not set. See: {BUILD_TARGET}") |
Comment on lines
+43
to
+44
| assert target_arch is not None, f"CIBW_ARCHS not set see: {BUILD_TARGET}" | ||
| assert target_os_info is not None, f"CIBW_PLATFORM not set see: {BUILD_TARGET}" |
There was a problem hiding this comment.
Replace the 'assert' with a direct check and explicit exception to ensure these environment variables are always validated in production builds.
Suggested change
| assert target_arch is not None, f"CIBW_ARCHS not set see: {BUILD_TARGET}" | |
| assert target_os_info is not None, f"CIBW_PLATFORM not set see: {BUILD_TARGET}" | |
| if target_arch is None: | |
| raise RuntimeError(f"Environment variable 'CIBW_ARCHS' is not set. Expected one of: {list(BUILD_TARGET.keys())}") | |
| if target_os_info is None: | |
| raise RuntimeError(f"Environment variable 'CIBW_PLATFORM' is not set. Expected one of: {list(BUILD_TARGET.keys())}") |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
硬编 target_arch、target_os_info,key 是 pypi 发布的 tag