Skip to content

Commit

Permalink
Use uv over pip
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <[email protected]>
  • Loading branch information
gaborbernat committed Sep 17, 2024
1 parent 35d8269 commit ec7c66d
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 76 deletions.
64 changes: 30 additions & 34 deletions .github/workflows/check.yml → .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,21 @@ jobs:
done
exit 1
shell: bash
- name: Setup python for tox
uses: actions/setup-python@v5
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Add .local/bin to Windows PATH
if: runner.os == 'Windows'
shell: bash
run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Setup brew python for test ${{ matrix.py }}
if: startsWith(matrix.py,'brew@')
run: |
Expand All @@ -74,37 +85,18 @@ jobs:
brew cleanup && brew upgrade python@$PY || brew install python@$PY
echo "/usr/local/opt/python@$PY/libexec/bin" >>"${GITHUB_PATH}"
shell: bash
- name: Install tox-uv
run: python -m pip install tox-uv pip -U
if: "!(startsWith(matrix.py,'pypy') || matrix.py == '3.7' || matrix.py == '[email protected]' || matrix.py == '[email protected]')"
- name: Install tox
run: python -m pip install tox pip -U
if: "(startsWith(matrix.py,'pypy') || matrix.py == '3.7' || matrix.py == '[email protected]' || matrix.py == '[email protected]')"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use local virtualenv for tox
run: python -m pip install .
- name: Setup python for test ${{ matrix.py }}
if: "!( startsWith(matrix.py,'brew@') || endsWith(matrix.py, '-dev') )"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
allow-prereleases: true
- name: Pick environment to run
run: |
import os; import platform; import sys; from pathlib import Path
plat = platform.python_implementation()
e = f"3.{sys.version_info.minor}" if plat == "CPython" else f"pypy3{sys.version_info.minor}"
env = f"TOXENV={e}"
print(f"Picked: {env} for {sys.version} based of {sys.executable}")
with Path(os.environ["GITHUB_ENV"]).open("ta") as file_handler:
file_handler.write(env)
shell: python
run: python tasks/pick_tox_env.py ${{ matrix.py }}
- name: Setup test suite
run: tox -vv --notest --skip-missing-interpreters false
run: tox run -vv --notest --skip-missing-interpreters false
- name: Run test suite
run: tox --skip-pkg-install
run: tox run --skip-pkg-install
timeout-minutes: 20
env:
PYTEST_ADDOPTS: "-vv --durations=20"
Expand Down Expand Up @@ -134,15 +126,19 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python "3.12"
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Add .local/bin to Windows PATH
if: runner.os == 'Windows'
shell: bash
run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH
- name: Install tox
run: python -m pip install tox-uv
- name: Setup check
run: python -m tox --skip-missing-interpreters false -e ${{ matrix.tox_env }} --notest
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Setup check suite
run: tox r -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
- name: Run check for ${{ matrix.tox_env }}
run: python -m tox --skip-pkg-install -e ${{ matrix.tox_env }}
env:
UPGRADE_ADVISORY: "yes"
run: tox r --skip-pkg-install -e ${{ matrix.tox_env }}
48 changes: 48 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release to PyPI
on:
push:
tags: ["*"]

env:
dists-artifact-name: python-package-distributions

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
path: dist/*

release:
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/virtualenv/${{ github.ref_name }}
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: ${{ env.dists-artifact-name }}
path: dist/
- name: Publish to PyPI
uses: pypa/[email protected]
with:
attestations: true
27 changes: 0 additions & 27 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Discord](https://img.shields.io/discord/803025117553754132)](https://discord.gg/pypa)
[![Downloads](https://static.pepy.tech/badge/virtualenv/month)](https://pepy.tech/project/virtualenv)
[![PyPI - License](https://img.shields.io/pypi/l/virtualenv?style=flat-square)](https://opensource.org/licenses/MIT)
[![check](https://github.com/pypa/virtualenv/actions/workflows/check.yml/badge.svg)](https://github.com/pypa/virtualenv/actions/workflows/check.yml)
[![check](https://github.com/pypa/virtualenv/actions/workflows/check.yaml/badge.svg)](https://github.com/pypa/virtualenv/actions/workflows/check.yaml)

A tool for creating isolated `virtual` python environments.

Expand Down
1 change: 1 addition & 0 deletions docs/changelog/2765.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade embedded wheels: setuptools to ``75.1.0`` from ``74.1.2`` - by :user:`gaborbernat`.
14 changes: 7 additions & 7 deletions src/virtualenv/seed/wheels/embed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@
},
"3.8": {
"pip": "pip-24.2-py3-none-any.whl",
"setuptools": "setuptools-74.1.2-py3-none-any.whl",
"setuptools": "setuptools-75.1.0-py3-none-any.whl",
"wheel": "wheel-0.44.0-py3-none-any.whl",
},
"3.9": {
"pip": "pip-24.2-py3-none-any.whl",
"setuptools": "setuptools-74.1.2-py3-none-any.whl",
"setuptools": "setuptools-75.1.0-py3-none-any.whl",
"wheel": "wheel-0.44.0-py3-none-any.whl",
},
"3.10": {
"pip": "pip-24.2-py3-none-any.whl",
"setuptools": "setuptools-74.1.2-py3-none-any.whl",
"setuptools": "setuptools-75.1.0-py3-none-any.whl",
"wheel": "wheel-0.44.0-py3-none-any.whl",
},
"3.11": {
"pip": "pip-24.2-py3-none-any.whl",
"setuptools": "setuptools-74.1.2-py3-none-any.whl",
"setuptools": "setuptools-75.1.0-py3-none-any.whl",
"wheel": "wheel-0.44.0-py3-none-any.whl",
},
"3.12": {
"pip": "pip-24.2-py3-none-any.whl",
"setuptools": "setuptools-74.1.2-py3-none-any.whl",
"setuptools": "setuptools-75.1.0-py3-none-any.whl",
"wheel": "wheel-0.44.0-py3-none-any.whl",
},
"3.13": {
"pip": "pip-24.2-py3-none-any.whl",
"setuptools": "setuptools-74.1.2-py3-none-any.whl",
"setuptools": "setuptools-75.1.0-py3-none-any.whl",
"wheel": "wheel-0.44.0-py3-none-any.whl",
},
"3.14": {
"pip": "pip-24.2-py3-none-any.whl",
"setuptools": "setuptools-74.1.2-py3-none-any.whl",
"setuptools": "setuptools-75.1.0-py3-none-any.whl",
"wheel": "wheel-0.44.0-py3-none-any.whl",
},
}
Expand Down
Binary file not shown.
12 changes: 12 additions & 0 deletions tasks/pick_tox_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations

import os
import sys
from pathlib import Path

py = sys.argv[1]
if py.startswith("brew@"):
py = py[len("brew@") :]
env = f"TOXENV={py}"
with Path(os.environ["GITHUB_ENV"]).open("ta", encoding="utf-8") as file_handler:
file_handler.write(env)
15 changes: 8 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,21 @@ uv_seed = true
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
skip_install = true
deps =
pre-commit-uv>=4.1
pre-commit-uv>=4.1.1
commands =
pre-commit run --all-files --show-diff-on-failure

[testenv:readme]
description = check that the long description is valid (need for PyPI)
description = check that the long description is valid
skip_install = true
deps =
build[uv]>=1.2.2
check-wheel-contents>=0.6
twine>=5.1.1
extras =
uv>=0.4.10
commands =
python -m build -o {envtmpdir} --installer uv --wheel --sdist .
twine check {envtmpdir}/*
uv build --sdist --wheel --out-dir {envtmpdir} .
twine check {envtmpdir}{/}*
check-wheel-contents --no-config {envtmpdir}

[testenv:docs]
description = build documentation
Expand All @@ -71,7 +72,7 @@ commands =
description = upgrade pip/wheels/setuptools to latest
skip_install = true
deps =
ruff>=0.6.4
ruff>=0.6.5
pass_env =
UPGRADE_ADVISORY
change_dir = {toxinidir}/tasks
Expand Down

0 comments on commit ec7c66d

Please sign in to comment.