Skip to content
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 Astral uv #12402

Merged
merged 6 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/project_euler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 2 additions & 2 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Comment on lines -15 to +16
Copy link
Member

Choose a reason for hiding this comment

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

This is unrelated to this PR but maybe we should combine the "ruff.yml" workflow into a more general "lint.yml" where there are other linters as well in addition to Ruff and they can utilize the "lint" dependency group.

Copy link
Member Author

@cclauss cclauss Dec 3, 2024

Choose a reason for hiding this comment

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

So... This is a good question. Ruff is run both here and in pre-commit.ci with the other "lint" jobs. Here it is run with --output-format=github to give contributors clear GH annotations and in pre-commit without --output-format. Is there a way to run it just once on each PR but give GitHub Annotations on the GitHub UI but not on localhost?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, that's a good point. Does pre-commit support the GitHub annotation output format? If it does, we could just utilize that otherwise I'm not sure what to do. You might be interested in the new astral-sh/ruff-action@v2 which is a complete rewrite.

6 changes: 3 additions & 3 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: auto-walrus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
rev: v0.8.1
hooks:
- id: ruff
- id: ruff-format
Expand Down
48 changes: 38 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,43 @@ requires-python = ">=3.13"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.13",
]
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",
]
optional-dependencies.docs = [
"myst-parser",
"sphinx-autoapi",
"sphinx-pyproject",

docs = [
"myst-parser>=4",
"sphinx-autoapi>=3.4",
"sphinx-pyproject>=0.3",
]
euler-validate = [
"numpy>=2.1.3",
"requests>=2.32.3",
]

[tool.ruff]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = [
Expand Down
6 changes: 0 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading
Loading