Skip to content

Commit

Permalink
Use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverbear committed Nov 1, 2024
1 parent 52d3766 commit 9e0a3a9
Show file tree
Hide file tree
Showing 7 changed files with 602 additions and 589 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,17 @@ jobs:
steps:
- uses: actions/checkout@v4

# Some Ferrocene builders require the use of Python 3.9. Use that on CI
# to make sure there are no surprises when we import into Ferrocene.
- uses: actions/setup-python@v3
with:
python-version: "3.9.x"
- name: Install `uv`
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Check that the requirements are installable
run: python3 -m pip install -r requirements.txt

- name: Install linting dependencies
run: python3 -m pip install reuse black flake8
run: uv pip install -r pyproject.toml

- name: Verify licensing metadata
run: reuse lint
run: uvx reuse lint

- name: Verify Python code formatting
run: black . --check --diff --color
run: uvx black . --check --diff --color

- name: Lint Python code with flake8
run: flake8 .
run: uvx flake8 .
33 changes: 0 additions & 33 deletions make_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,38 +111,6 @@ def current_git_commit(root):
return


class VirtualEnv:
def __init__(self, root, path):
self.path = path
self.requirements = root / "shared" / "requirements.txt"
self.installed_requirements = path / "installed-requirements.txt"

if not self.up_to_date():
self.create()

def bin(self, name):
if sys.platform == "win32":
return self.path / "scripts" / name
else:
return self.path / "bin" / name

def up_to_date(self):
if self.installed_requirements.exists():
expected = self.requirements.read_bytes()
installed = self.installed_requirements.read_bytes()
if expected == installed:
return True
return False

def create(self):
venv.EnvBuilder(clear=True, symlinks=True, with_pip=True).create(self.path)
subprocess.run(
[self.bin("pip"), "install", "-r", self.requirements, "--require-hashes"],
check=True,
)
self.installed_requirements.write_bytes(self.requirements.read_bytes())


def main(root):
root = Path(root)

Expand Down Expand Up @@ -170,7 +138,6 @@ def main(root):
)
args = parser.parse_args()

env = VirtualEnv(root, root / ".venv")
rendered = build_docs(
root, env, "xml" if args.xml else "html", args.clear, args.serve, args.debug
)
Expand Down
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: The Ferrocene Developers
# SPDX-License-Identifier: MIT OR Apache-2.0
[project]
name = "sphinx-shared-resources"
version = "0.0.1"
requires-python = ">=3.12"
dependencies = [
"sphinx",
"sphinx-autobuild",
"tomli",
"myst_parser",
"pyyaml",
"semver",

# For compatibility with Python < 3.10, as Sphinx has a conditional dependency
# on importlib-metadata on older Python versions.
"importlib-metadata"
]
13 changes: 0 additions & 13 deletions requirements.in

This file was deleted.

529 changes: 0 additions & 529 deletions requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt.license

This file was deleted.

578 changes: 578 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 9e0a3a9

Please sign in to comment.