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

Move from venvstarter to only using uv #60

Merged
merged 5 commits into from
Sep 19, 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
13 changes: 5 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,17 @@ jobs:
- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install deps
shell: bash
env:
VENVSTARTER_ONLY_MAKE_VENV: "1"
run: python ./tools/venv
- name: Install venv
run: ./tools/uv sync --extra tools --locked

- name: Run tests without cache
shell: bash
run: ./test.sh -v --typing-strategy MYPY_NO_INCREMENTAL
run: ./tools/ci tests -v --typing-strategy MYPY_NO_INCREMENTAL

- name: Run tests incremental
shell: bash
run: ./test.sh -v --typing-strategy MYPY_INCREMENTAL
run: ./tools/ci tests -v --typing-strategy MYPY_INCREMENTAL

- name: Run tests daemon
shell: bash
run: ./test.sh -v --typing-strategy MYPY_DAEMON
run: ./tools/ci tests -v --typing-strategy MYPY_DAEMON
19 changes: 5 additions & 14 deletions .github/workflows/ciold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,17 @@ jobs:
- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install patch to make this use old versions of things
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git am ./scripts/make_old.patch

- name: Install deps
shell: bash
env:
VENVSTARTER_ONLY_MAKE_VENV: "1"
run: python ./tools/venv
- name: Install venv
run: ./tools/uv sync --extra tools --locked

- name: Run tests without cache
shell: bash
run: ./test.sh -v --typing-strategy MYPY_NO_INCREMENTAL
run: ./tools/ci tests --old -v --typing-strategy MYPY_NO_INCREMENTAL

- name: Run tests incremental
shell: bash
run: ./test.sh -v --typing-strategy MYPY_INCREMENTAL
run: ./tools/ci tests --old -v --typing-strategy MYPY_INCREMENTAL

- name: Run tests daemon
shell: bash
run: ./test.sh -v --typing-strategy MYPY_DAEMON
run: ./tools/ci tests --old -v --typing-strategy MYPY_DAEMON
45 changes: 27 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ jobs:
with:
python-version: "3.10"

- name: Install deps
shell: bash
env:
VENVSTARTER_ONLY_MAKE_VENV: "1"
run: python ./tools/venv
- name: Install venv
run: ./tools/uv sync --extra tools --locked

- name: Ensure linter is happy
run: ./lint
run: ./tools/ci lint

types:
runs-on: ubuntu-latest
Expand All @@ -46,14 +43,27 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install deps
shell: bash
env:
VENVSTARTER_ONLY_MAKE_VENV: "1"
run: python ./tools/venv
- name: Install venv
run: ./tools/uv sync --extra tools --locked

- name: Ensure mypy is happy
run: ./types
run: ./tools/ci types

types-old:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install venv
run: ./tools/uv sync --extra tools --locked

- name: Ensure mypy is happy
run: ./tools/ci types --old

format:
runs-on: ubuntu-latest
Expand All @@ -65,15 +75,14 @@ jobs:
with:
python-version: "3.10"

- name: Install deps
shell: bash
env:
VENVSTARTER_ONLY_MAKE_VENV: "1"
run: python ./tools/venv
- name: Install venv
run: ./tools/uv sync --extra tools --locked

- name: Ensure code is formatted
run: |
./format
./tools/ci format

git status --porcelain

# Complain if there were changes
if [[ ! -z "$(git status --porcelain)" ]]; then
Expand Down
64 changes: 0 additions & 64 deletions .github/workflows/lintold.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: "3.10"

- id: build
run: pip install hatch==1.7.0 && hatch build
run: uv build

- id: version
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.egg-info/
.venv/
.dmypy.json
__pycache__/
*.pyc
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ sphinx:

python:
install:
- requirements: tools/requirements.docs.txt
- requirements: ./tools/.requirements.readthedocs.txt
- method: pip
path: .[stubs-latest]
path: .
8 changes: 3 additions & 5 deletions DEVELOPMENT.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Development
===========

This project uses `venvstarter`_ to manage a ``virtualenv``.
This project uses `uv` to manage a ``virtualenv``.

All the commands will only install things locally to this repository.

Expand All @@ -27,10 +27,8 @@ To run tests such that breakpoints work::

To activate the ``virtualenv`` in your current shell::

> source run.sh activate
> source dev activate

To build the docs locally::

> ./run.sh docs view

.. _venvstarter: https://venvstarter.readthedocs.io
> ./dev docs view
74 changes: 74 additions & 0 deletions dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced
sourced=0
if [ -n "$ZSH_VERSION" ]; then
case $ZSH_EVAL_CONTEXT in *:file) sourced=1;; esac
elif [ -n "$KSH_VERSION" ]; then
# shellcheck disable=SC2296
[ "$(cd -- "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")" != "$(cd -- "$(dirname -- "${.sh.file}")" && pwd -P)/$(basename -- "${.sh.file}")" ] && sourced=1
elif [ -n "$BASH_VERSION" ]; then
(return 0 2>/dev/null) && sourced=1
else
# All other shells: examine $0 for known shell binary filenames.
# Detects `sh` and `dash`; add additional shell filenames as needed.
case ${0##*/} in sh|-sh|dash|-dash)
if [ -z "$PROJECT_ROOT" ]; then
echo "POSIX environments need PROJECT_ROOT in the environment for 'source run.sh activate' to work"
echo "This must be set to the root of this repository"
return 1
fi
;;
esac
fi

# Bash does not make it easy to find where this file is
# Here I'm making it so it doesn't matter what directory you are in
# when you execute this script. And it doesn't matter whether you're
# executing a symlink to this script
# Note the `-h` in the while loop asks if this path is a symlink
pushd . >'/dev/null'
find_here() {
SCRIPT_PATH="${BASH_SOURCE[0]:-$0}"
while [ -h "$SCRIPT_PATH" ]; do
cd "$(dirname -- "$SCRIPT_PATH")" || return 1
SCRIPT_PATH="$(readlink -f -- "$SCRIPT_PATH")"
done
cd "$(dirname -- "$SCRIPT_PATH")" >'/dev/null' || return 1
}

if ! find_here; then
if [ "$sourced" = "1" ]; then
return 1
else
exit 1
fi
fi

PROJECT_ROOT=$(pwd)
export PROJECT_ROOT

if ! ./tools/uv sync --locked -q; then
if [ "$sourced" = "1" ]; then
return 1
else
exit 1
fi
fi

if [ -f ./tools/requirements.local.txt ]; then
if ! ./tools/uv pip install -q -r ./tools/requirements.local.txt; then
if [ "$sourced" = "1" ]; then
return 1
else
exit 1
fi
fi
fi

if [ "$sourced" = "1" ]; then
# shellcheck source=/dev/null
source ./.venv/bin/activate
else
exec uv run ./tools/run.py "$@"
fi
6 changes: 3 additions & 3 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Documentation

From the root of the repo, to build the documentation run::

> ./run.sh docs
> ./dev docs

If you want to build from fresh then say::

> ./run.sh docs fresh
> ./dev docs fresh

Once your documentation is built do something like::

> ./run.sh docs view
> ./dev docs view
1 change: 0 additions & 1 deletion example/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ authors = [
dependencies = [
"django==4.2.9",
"psycopg2-binary==2.9.9",
"extended_mypy_django_plugin",
]

[tool.hatch.version]
Expand Down
25 changes: 14 additions & 11 deletions find
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/bin/bash

set -e

# Helper for searching code base without searching through external code

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

(
cd $DIR
exec ack "$@" \
--ignore-directory .tox \
--ignore-directory .mypy_cache \
--ignore-directory dist \
--ignore-directory build \
--ignore-directory tools \
)
cd "$(git rev-parse --show-toplevel)"

exec ack "$@" \
--ignore-directory .tox \
--ignore-directory .mypy_cache \
--ignore-directory .dmypy.json \
--ignore-directory dist \
--ignore-directory build \
--ignore-directory "*.egg-info" \
--ignore-directory tools \
--ignore-directory docs/.sphinx-build \
--ignore-directory docs/_build
2 changes: 1 addition & 1 deletion format
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

cd "$(git rev-parse --show-toplevel)"

./tools/venv format "$@"
exec ./dev format "$@"
2 changes: 1 addition & 1 deletion lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

cd "$(git rev-parse --show-toplevel)"

exec ./tools/venv lint "$@"
exec ./dev lint "$@"
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ exclude = (?x)(
| ^scripts/leader
| ^scripts/follower
| ^tests/django_analysis/virtual_dependencies/generated_reports
| ^scripts/proper_plugin
)

plugins =
extended_mypy_django_plugin.main,
mypy.plugins.proper_plugin
proper_plugin.plugin

[mypy.plugins.django-stubs]
scratch_path = $MYPY_CONFIG_FILE_DIR/.mypy_django_scratch/main
Expand Down
Loading
Loading