-
-
Notifications
You must be signed in to change notification settings - Fork 630
Use uv #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use uv #361
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,4 +163,3 @@ workflows: | |
| - python3.5 | ||
| - python3.4 | ||
| - python2.7 | ||
| - pypy2 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| * GitHub: https://github.com/mozillazg/python-pinyin | ||
| * License: MIT license | ||
| * PyPI: https://pypi.org/project/pypinyin | ||
| * Python version: 2.7, pypy, pypy3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 | ||
| * Python version: 2.7, pypy3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for Python 2.7 references in CI and test configurations
rg -n "python.*2\.7|py27" -g "*.{yml,yaml,ini,cfg,toml}" -C2Repository: mozillazg/python-pinyin Length of output: 641 🏁 Script executed: # Also check for the CI workflow file mentioned
fd -t f "ci\.yml|\.github.*ci" | head -20Repository: mozillazg/python-pinyin Length of output: 49 🏁 Script executed: # Check the setup.py or pyproject.toml for python_requires
fd -t f "(setup\.py|pyproject\.toml|setup\.cfg)" | xargs ls -laRepository: mozillazg/python-pinyin Length of output: 247 🏁 Script executed: cat -n setup.py | head -50Repository: mozillazg/python-pinyin Length of output: 1648 🏁 Script executed: cat -n tox.iniRepository: mozillazg/python-pinyin Length of output: 1315 🏁 Script executed: # Check if these files were modified in the current PR
git diff HEAD~1 HEAD -- tox.ini setup.py pyproject.toml | head -100Repository: mozillazg/python-pinyin Length of output: 95 🏁 Script executed: # Look for GitHub Actions workflow files
fd -t f -e yml -e yaml ".github" | head -20Repository: mozillazg/python-pinyin Length of output: 49 🏁 Script executed: # Check what Python versions are tested in GitHub Actions
find .github -name "*.yml" -o -name "*.yaml" 2>/dev/null | xargs catRepository: mozillazg/python-pinyin Length of output: 1611 🏁 Script executed: # Check README.rst to see the full context around line 15
cat -n README.rst | sed -n '1,30p'Repository: mozillazg/python-pinyin Length of output: 873 Remove unsupported Python versions from the compatibility list. The README lists Python 2.7, 3.4, 3.5, and 3.6, but the GitHub Actions CI workflow only tests Python 3.7+, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, pypy3.9, and pypy3.10. Remove versions that are not actively tested. 🤖 Prompt for AI Agents |
||
|
|
||
| .. contents:: | ||
|
|
||
|
|
@@ -33,6 +33,12 @@ | |
|
|
||
| pip install pypinyin | ||
|
|
||
| 使用 `uv` 安装: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| uv add pypinyin | ||
|
|
||
|
|
||
| 使用示例 | ||
| -------- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| * GitHub: https://github.com/mozillazg/python-pinyin | ||
| * License: MIT license | ||
| * PyPI: https://pypi.org/project/pypinyin | ||
| * Python version: 2.7, pypy, pypy3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9 | ||
| * Python version: 2.7, pypy3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify consistency with pyproject.toml Python version requirements. The documentation lists specific Python versions (2.7, pypy3, 3.4-3.13), but 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| 特性 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| [build-system] | ||
| requires = ["setuptools>=42", "wheel"] | ||
| build-backend = "setuptools.build_meta" | ||
|
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Setuptools 42.0.0 (released 23 Nov 2019) added explicit support for Python 3.8 (fixed 3.8 Windows ABI handling) and continued to support Python 2.7 (Python‑2 support was removed later in setuptools 45). Source: setuptools changelog v42.0.0. [1] References
🌐 Web query:
💡 Result: No — setuptools 42 is not compatible with Python 2.6. Setuptools dropped Python 2.6 support in v37.0.0 (Nov 20, 2017); later, setuptools v45 (Jan 11, 2020) dropped all Python 2 support (so Python 2.7 only kept on the 44.x branch). Use setuptools <37 if you must run on Python 2.6. [1][2] Sources:
Setuptools 42 does not support Python 2.6; either update supported Python versions or lower the setuptools requirement. Setuptools dropped Python 2.6 support in v37.0.0 (November 2017). The
(Setuptools 42 does support Python 2.7, so this constraint only affects Python 2.6.) 🤖 Prompt for AI Agents |
||
|
|
||
| [project] | ||
| name = "pypinyin" | ||
| description = "汉字拼音转换模块/工具." | ||
| readme = "README.rst" | ||
| dynamic = ["version"] | ||
| requires-python = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <4" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: uv requires Python 3.8 or newer (requires-python >=3.8). It does not support Python 2.6 or 2.7. [1][2] Sources:
🏁 Script executed: # Check if there are CI/test configurations that specify tested Python versions
fd -t f "(\.github|\.gitlab|tox|\.travis)" -x cat {} \; 2>/dev/null | head -100Repository: mozillazg/python-pinyin Length of output: 1007 🏁 Script executed: # Look for any Python 2.6-specific code or comments in the codebase
rg "python.*2\.6|2\.6.*python" -i --max-count=20Repository: mozillazg/python-pinyin Length of output: 5668 🏁 Script executed: # Check pyproject.toml and setup files for more context
git ls-files | grep -E "(pyproject|setup|tox)" | head -20Repository: mozillazg/python-pinyin Length of output: 108 Update The project declares Python 2.6+ support in 🤖 Prompt for AI Agents |
||
| license = {text = "MIT"} | ||
| authors = [{name = "mozillazg, 闲耘", email = "mozillazg101@gmail.com"}] | ||
| classifiers = [ | ||
| "Development Status :: 5 - Production/Stable", | ||
| "Intended Audience :: Developers", | ||
| "License :: OSI Approved :: MIT License", | ||
| "Operating System :: OS Independent", | ||
| "Programming Language :: Python", | ||
| "Programming Language :: Python :: 2", | ||
| "Programming Language :: Python :: 2.7", | ||
| "Programming Language :: Python :: 3", | ||
| "Programming Language :: Python :: 3.4", | ||
| "Programming Language :: Python :: 3.5", | ||
| "Programming Language :: Python :: 3.6", | ||
| "Programming Language :: Python :: 3.7", | ||
| "Programming Language :: Python :: 3.8", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Programming Language :: Python :: Implementation :: CPython", | ||
| "Programming Language :: Python :: Implementation :: PyPy", | ||
| "Topic :: Utilities", | ||
| "Topic :: Text Processing" | ||
| ] | ||
| keywords = ["pinyin", "拼音"] | ||
| dependencies = [ | ||
| "argparse; python_version < '2.7'", | ||
| "enum34; python_version < '3.4'", | ||
| "typing; python_version < '3.5'" | ||
| ] | ||
|
|
||
| [project.urls] | ||
| Documentation = "https://pypinyin.readthedocs.io/" | ||
| Source = "https://github.com/mozillazg/python-pinyin" | ||
| Tracker = "https://github.com/mozillazg/python-pinyin/issues" | ||
|
|
||
| [project.scripts] | ||
| pypinyin = "pypinyin.__main__:main" | ||
|
|
||
| [project.entry-points.pyinstaller40] | ||
| hook-dirs = "pypinyin.__pyinstaller:get_hook_dirs" | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "argparse", | ||
| "mypy; python_version >= '3.5'", | ||
| "pre-commit", | ||
| "pygments>=2.7.4; python_version >= '3.5'", | ||
| "pytest", | ||
| "pytest-cov", | ||
| "pytest-random-order", | ||
| "setuptools", | ||
| "sphinx>=3.0.4; python_version >= '3.5'", | ||
| "tox" | ||
| ] | ||
| release = [ | ||
| "bumpversion", | ||
| "twine", | ||
| "wheel>=0.21" | ||
| ] | ||
|
Comment on lines
+68
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistency: twine included in release group but commented out in requirements_dev.txt. The 🤖 Prompt for AI Agents |
||
|
|
||
| [tool.setuptools] | ||
| packages = ["pypinyin", "pypinyin.contrib", "pypinyin.seg", "pypinyin.style", "pypinyin.tools", "pypinyin.__pyinstaller"] | ||
| include-package-data = true | ||
| zip-safe = false | ||
|
|
||
| [tool.setuptools.dynamic] | ||
| version = {attr = "pypinyin.__version__"} | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,5 +9,5 @@ pytest-random-order | |||||
| setuptools | ||||||
| Sphinx>=3.0.4 | ||||||
| tox | ||||||
| twine | ||||||
| #twine | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Twine is still required by the Makefile. Commenting out 🔎 Proposed fix: restore twine or migrate to UV publishOption 1: Restore twine dependency -#twine
+twineOption 2: Update Makefile to use UV publish (if supported) Check if UV supports publishing and update the Makefile accordingly. If UV doesn't support direct publishing, twine must remain as a dependency. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| wheel>=0.21 | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
uv pip install --system flag GitHub Actions CI best practices💡 Result:
Summary best practices for using uv pip install --system in GitHub Actions CI
Prefer ephemeral virtual environments, not --system
Use --system only in CI/container contexts and with caution
Avoid PEP 668 / “externally managed” failures
Prefer installing CLI tools with uv tool install
If you must use --system, ensure runner permissions and target interpreter
Reproducibility: pin Python and packages
Troubleshooting checklist
a) Check for “externally managed” / PEP 668 message → use venv or distro package. [5][8]
b) Check permissions → use container or writable interpreter. [3]
c) Try uv pip install --python=$(which python) instead of --system. [7]
d) For CLIs, prefer uv tool install. [1]
Selected sources
If you want, I can draft a small GitHub Actions job example showing (a) recommended pattern with uv venv, and (b) a container-based job using uv pip install --system safely.
🌐 Web query:
uv documentation recommended installation method for CI environments💡 Result:
Recommended: install the standalone uv binary (curl https://astral.sh/uv/install.sh | sh) and use uvx for CI/one‑off automation. uvx is the recommended mode for CI/CD; alternatively uv's --system option can be used to target the system Python but is meant for CI with caution. [1][2][3]
Sources:
Consider using
uvxinstead ofuv pip install --systemin CI.The
--systemflag mutates the system Python and is not the recommended CI approach. The uv documentation recommendsuvxas the preferred method for CI/one-off executions. Additionally,--systeminstallations may fail on systems with PEP 668 "externally managed" Python (increasingly common in Linux distributions), where uv will refuse to modify the system Python.If system-wide installation is necessary, ensure the runner environment allows modifications or use a container with a writable Python installation. Otherwise, use virtual environments (uv's default behavior) or
uvxfor better CI portability.🤖 Prompt for AI Agents