Skip to content
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
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ write-changes =
count = true
quiet-level = 3
ignore-words-list = aks,aml,requestors
skip = *.drawio,dist,pdm.lock
skip = *.drawio,dist,uv.lock
1 change: 0 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ENV HOROVOD_GPU_ALLREDUCE=NCCL

RUN apt-get -qq update \
&& apt-get -qq install --no-install-recommends \
python3-minimal python3-dev python3-pip python3-venv python-is-python3 pipx \
apt-transport-https ca-certificates curl wget gnupg lsb-release sudo git zsh \
openssh-server openssh-client tmux fzf direnv neovim \
&& apt-get -qq clean \
Expand Down
30 changes: 22 additions & 8 deletions .devcontainer/direnvrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
layout_uv() {
if [[ ! -f pyproject.toml ]]; then
log_status 'No pyproject.toml found. Will initialize uv'
uv init --quiet
fi

VIRTUAL_ENV=$(dirname $(dirname $(uv run which python)))

PATH_add "$VIRTUAL_ENV/bin"
export UV_ACTIVE=1 # or VENV_ACTIVE=1
export VIRTUAL_ENV
}

layout_poetry() {
if [[ ! -f pyproject.toml ]]; then
log_status 'No pyproject.toml found. Will initialize poetry in no-interactive mode'
poetry init -n -q
poetry run pip install -U pip wheel setuptools
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to create one first.'
exit 2
fi
poetry run echo >> /dev/null
local VENV=$(dirname $(poetry run which python))
export VIRTUAL_ENV=$(echo "$VENV" | rev | cut -d'/' -f2- | rev)

# create venv if it doesn't exist
poetry run true

PATH_add "$VIRTUAL_ENV/bin"
export VIRTUAL_ENV=$(poetry env info --path)
export POETRY_ACTIVE=1
PATH_add "$VENV"
}

layout_pdm() {
Expand All @@ -26,7 +40,7 @@ layout_pdm() {
VIRTUAL_ENV=$(pdm venv list | grep "^\*" | awk -F" " '{print $3}')
fi

PATH_add "$VIRTUAL_ENV/bin"
export PDM_ACTIVE=1
export VIRTUAL_ENV
PATH_add "$VIRTUAL_ENV/bin"
}
20 changes: 10 additions & 10 deletions .devcontainer/on-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
eval "$(direnv hook bash)"
mkdir -p ~/.config/direnv/
cp /workspaces/$(basename "$(pwd)")/.devcontainer/direnvrc ~/.config/direnv/direnvrc
pipx ensurepath

echo "UPDATE PIP"
pip3 install -U pip

echo "PDM INSTALL"
pipx install pdm
pdm completion bash > ~/.bash_completion
mkdir $ZSH_CUSTOM/plugins/pdm
pdm completion zsh > ~/.zfunc/_pdm
sed -i 's/plugins=(git)/plugins=(git pdm)/' ~/.zshrc
pdm config virtualenvs.in-project true
echo "UV INSTALL"
curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'eval "$(uv generate-shell-completion bash)"' >> ~/.bashrc
echo 'eval "$(uvx --generate-shell-completion bash)"' >> ~/.bashrc
mkdir $ZSH_CUSTOM/plugins/uv
echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc
echo 'eval "$(uvx --generate-shell-completion zsh)"' >> ~/.zshrc

echo "INSTALLING PACKAGES"
uv sync
direnv allow .
pdm env remove --all
pdm install
5 changes: 2 additions & 3 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ git config --global alias.mt mergetool
git config --global alias.pl pull --rebase

echo "INSTALLING COMMITIZEN"
pipx install commitizen
pipx inject commitizen cz-conventional-gitmoji
uv tool install commitizen --with cz-conventional-gitmoji
echo 'eval "$(register-python-argcomplete3 cz)"' >> ~/.bashrc
echo 'eval "$(register-python-argcomplete3 cz)"' >> ~/.zshrc

Expand All @@ -22,5 +21,5 @@ if [ ! -d .git ]; then
echo "Initializing Git..."
git init
fi
pipx install pre-commit
uv tool install pre-commit --with pre-commit-uv
pre-commit install --install-hooks
5 changes: 2 additions & 3 deletions .devcontainer/post-create.sh.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ git config --global alias.pl pull --rebase

{% if commitizen -%}
echo "INSTALLING COMMITIZEN"
pipx install commitizen
pipx inject commitizen cz-conventional-gitmoji
uv tool install commitizen --with cz-conventional-gitmoji
echo 'eval "$(register-python-argcomplete3 cz)"' >> ~/.bashrc
echo 'eval "$(register-python-argcomplete3 cz)"' >> ~/.zshrc
{%- endif %}
Expand All @@ -25,6 +24,6 @@ if [ ! -d .git ]; then
echo "Initializing Git..."
git init
fi
pipx install pre-commit
uv tool install pre-commit --with pre-commit-uv
pre-commit install --install-hooks
{%- endif %}
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
layout_pdm
layout_uv

# get path to the root of the project even if deep into the path
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.0"

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U pdm
pdm install --group docs
uv sync --only-group docs

- name: build-docs
run: |
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.0"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U pre-commit
pre-commit install --install-hooks

- name: pre-commit
run: |
pre-commit run --all-files
run: uvx --with pre-commit-uv -- pre-commit run --all-files
env:
SKIP: "ruff,ruff-format,pyright,codespell"
21 changes: 12 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,40 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.0"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U pdm
pdm install
uv sync --no-group docs

- name: ruff-check
run: |
pdm run ruff check --no-fix --output-format=github
uv run ruff check --no-fix --output-format=github

- name: ruff-format
run: |
pdm run ruff format --check
uv run ruff format --check

- name: pyright
run: |
pdm run pyright
uv run pyright

- name: codespell
run: |
pdm run codespell
uv run codespell

- name: pytest
run: |
pdm run coverage run -m pytest
uv run coverage run -m pytest

- name: coverage
run: |
pdm run coverage xml -o .tmp/reports/coverage.xml
uv run coverage xml -o .tmp/reports/coverage.xml
13 changes: 6 additions & 7 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.0"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U pdm

- name: build-wheel
run: |
pdm build
run: uv build

- name: upload-artifacts
uses: actions/upload-artifact@v4
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
.coverage
.tmp
.cache
.pdm-python
.pdm.toml
.pdm-build

**/*.pyc
**/*.egg-info
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ repos:
name: Run codespell to check for common misspellings in files
language: python
types: [text]
exclude: "pdm.lock|CHANGELOG.md"
exclude: "uv.lock|CHANGELOG.md"
32 changes: 19 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,33 @@ ENV PATH=/root/.local/bin:${PATH}
ENV PATH=$PROJECT_PATH/bin:$PATH
ENV PATH=$PROJECT_PATH/.venv/bin:$PATH

WORKDIR $PROJECT_PATH
# Silence uv complaining about not being able to use hard links,
# tell uv to byte-compile packages for faster application startups,
# prevent uv from accidentally downloading isolated Python builds,
# declare `$PROJECT_PATH` as the target for `uv sync`.
ENV UV_LINK_MODE=copy
ENV UV_COMPILE_BYTECODE=1
ENV UV_PYTHON_DOWNLOADS=never
ENV UV_PROJECT_ENVIRONMENT=$PROJECT_PATH

WORKDIR $PROJECT_PATH

RUN apt-get -qq update && \
apt-get -qq install --no-install-recommends \
python3-minimal python3-dev python3-pip python3-venv python-is-python3 pipx && \
pipx ensurepath && \
python3.12 libpython3.12 && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*

RUN pipx install pdm && \
rm -rf ~/.cache

RUN mkdir -p $PROJECT_PATH/src/cookie && \
touch $PROJECT_PATH/src/cookie/__init__.py && \
touch $PROJECT_PATH/README.md
COPY --from=ghcr.io/astral-sh/uv:0.5.31 /uv /usr/local/bin/uv

COPY pyproject.toml pdm.lock $PROJECT_PATH/

RUN pdm install --prod && \
rm -rf /root/.cache
RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=.python-version,target=.python-version \
uv sync --locked --no-default-groups --no-install-project

COPY src $PROJECT_PATH/src

RUN --mount=type=cache,target=/root/.cache \
uv sync --locked --no-default-groups
Loading
Loading