Use Astral uv (#12402)

* Use Astral uv

* uvx vs uv run

* uv sync --group=euler-validate,test

* uv sync --group=euler-validate --group=test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* --group=test

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Christian Clauss 2024-12-05 05:34:48 +01:00 committed by GitHub
parent b22fab0ea4
commit 0bcdfbdb34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 1302 additions and 41 deletions

View File

@ -10,21 +10,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: uv.lock
- uses: actions/setup-python@v5
with:
python-version: 3.13
allow-prereleases: true
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest-cov -r requirements.txt
- run: uv sync --group=test
- name: Run tests
# TODO: #8818 Re-enable quantum tests
run: pytest
run: uv run pytest
--ignore=computer_vision/cnn_classification.py
--ignore=docs/conf.py
--ignore=dynamic_programming/k_means_clustering_tensorflow.py

View File

@ -15,25 +15,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install pytest and pytest-cov
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade numpy pytest pytest-cov
- run: pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
- run: uv sync --group=euler-validate --group=test
- run: uv run pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
validate-solutions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install pytest and requests
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade numpy pytest requests
- run: pytest scripts/validate_solutions.py
- run: uv sync --group=euler-validate --group=test
- run: uv run pytest scripts/validate_solutions.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -12,5 +12,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install --user ruff
- run: ruff check --output-format=github .
- uses: astral-sh/setup-uv@v4
- run: uvx ruff check --output-format=github .

View File

@ -26,14 +26,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
- uses: actions/setup-python@v5
with:
python-version: 3.13
allow-prereleases: true
- run: pip install --upgrade pip
- run: pip install myst-parser sphinx-autoapi sphinx-pyproject
- run: uv sync --group=docs
- uses: actions/configure-pages@v5
- run: sphinx-build -c docs . docs/_build/html
- run: uv run sphinx-build -c docs . docs/_build/html
- uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html

View File

@ -7,12 +7,43 @@ requires-python = ">=3.13"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.13",
]
optional-dependencies.docs = [
"myst-parser",
"sphinx-autoapi",
"sphinx-pyproject",
dependencies = [
"beautifulsoup4>=4.12.3",
"fake-useragent>=1.5.1",
"imageio>=2.36.1",
"keras>=3.7",
"lxml>=5.3",
"matplotlib>=3.9.3",
"numpy>=2.1.3",
"opencv-python>=4.10.0.84",
"pandas>=2.2.3",
"pillow>=11",
"requests>=2.32.3",
"rich>=13.9.4",
"scikit-learn>=1.5.2",
"sphinx-pyproject>=0.3",
"statsmodels>=0.14.4",
"sympy>=1.13.3",
"tweepy>=4.14",
"typing-extensions>=4.12.2",
"xgboost>=2.1.3",
]
[dependency-groups]
test = [
"pytest>=8.3.4",
"pytest-cov>=6",
]
docs = [
"myst-parser>=4",
"sphinx-autoapi>=3.4",
"sphinx-pyproject>=0.3",
]
euler-validate = [
"numpy>=2.1.3",
"requests>=2.32.3",
]
[tool.ruff]
@ -61,8 +92,8 @@ lint.select = [
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
# "ANN", # flake8-annotations # FIX ME?
# "COM", # flake8-commas
# "ANN", # flake8-annotations -- FIX ME?
# "COM", # flake8-commas -- DO NOT FIX
# "D", # pydocstyle -- FIX ME?
# "ERA", # eradicate -- DO NOT FIX
# "FBT", # flake8-boolean-trap # FIX ME
@ -129,10 +160,7 @@ lint.pylint.max-statements = 88 # default: 50
[tool.codespell]
ignore-words-list = "3rt,ans,bitap,crate,damon,fo,followings,hist,iff,kwanza,manuel,mater,secant,som,sur,tim,toi,zar"
skip = "./.*,*.json,ciphers/prehistoric_men.txt,project_euler/problem_022/p022_names.txt,pyproject.toml,strings/dictionary.txt,strings/words.txt"
[tool.pyproject-fmt]
max_supported_python = "3.13"
skip = "./.*,*.json,*.lock,ciphers/prehistoric_men.txt,project_euler/problem_022/p022_names.txt,pyproject.toml,strings/dictionary.txt,strings/words.txt"
[tool.pytest.ini_options]
markers = [

View File

@ -8,18 +8,12 @@ numpy
opencv-python
pandas
pillow
# projectq # uncomment once quantum/quantum_random.py is fixed
qiskit ; python_version < '3.12'
qiskit-aer ; python_version < '3.12'
requests
rich
# scikit-fuzzy # uncomment once fuzzy_logic/fuzzy_operations.py is fixed
scikit-learn
sphinx_pyproject
statsmodels
sympy
tensorflow ; python_version < '3.13'
tweepy
# yulewalker # uncomment once audio_filters/equal_loudness_filter.py is fixed
typing_extensions
xgboost

1246
uv.lock Normal file

File diff suppressed because it is too large Load Diff