Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Remove pdm now that every project uses uv (#5715)

Olga Bulatf7d99303fc8e
diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml
index f1381e176..ff2cd16d5 100644
--- a/.github/actions/setup-env/action.yml
+++ b/.github/actions/setup-env/action.yml
@@ -41,13 +41,9 @@ runs:
- name: Setup global Python deps
if: inputs.setup_python == 'true'
shell: bash
- # pdm goes through pipx: `pdm[locked]` pins pdm's dependencies (so a
- # release of one of them cannot break it), and those pins conflict
- # with pipenv's requirements when both share one environment.
run: |
pip install -U pip
pip install pipenv
- pipx install "pdm[locked]"
- name: Setup uv
if: inputs.setup_python == 'true'
diff --git a/.github/renovate.json5 b/.github/renovate.json5
index 5fe7c7d58..f51d771b0 100644
--- a/.github/renovate.json5
+++ b/.github/renovate.json5
@@ -41,10 +41,7 @@
},
{
groupName: "python dev dependencies",
- matchDepTypes: [
- "tool.pdm.dev-dependencies",
- "project.optional-dependencies",
- ],
+ matchDepTypes: ["dependency-groups", "project.optional-dependencies"],
matchFileNames: [
"api/**",
"catalog/**",
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml
index 4f7f1f510..a14d839f1 100644
--- a/.github/workflows/ci_cd.yml
+++ b/.github/workflows/ci_cd.yml
@@ -109,7 +109,7 @@ jobs:
- name: Setup CI env
uses: ./.github/actions/setup-env
with:
- # PDM is needed to run Vale
+ # Python is needed to run pre-commit.
setup_python: "true"
# Node.js is needed by lint actions.
install_recipe: "node-install"
@@ -199,7 +199,6 @@ jobs:
build-contexts: ${{ matrix.build-contexts }}
build-args: |
SEMANTIC_VERSION=${{ needs.get-image-tag.outputs.image_tag }}
- OV_PDM_VERSION=${{ steps.prepare-build-args.outputs.ov_pdm_version }}
OV_UV_VERSION=${{ steps.prepare-build-args.outputs.ov_uv_version }}
CATALOG_PY_VERSION=${{ steps.prepare-build-args.outputs.catalog_py_version }}
CATALOG_AIRFLOW_VERSION=${{ steps.prepare-build-args.outputs.catalog_airflow_version }}
diff --git a/.github/workflows/tag_docker_image_and_trigger_deployment.yml b/.github/workflows/tag_docker_image_and_trigger_deployment.yml
index 4745c4eae..dd1f0b368 100644
--- a/.github/workflows/tag_docker_image_and_trigger_deployment.yml
+++ b/.github/workflows/tag_docker_image_and_trigger_deployment.yml
@@ -92,7 +92,7 @@ jobs:
- name: Setup CI env
uses: ./.github/actions/setup-env
with:
- # PDM is needed to run Vale
+ # Python is needed to run pre-commit.
setup_python: "true"
# Node.js is needed by lint actions.
install_recipe: "node-install"
diff --git a/docker/dev_env/Dockerfile b/docker/dev_env/Dockerfile
index d833ce031..fcc35347b 100644
--- a/docker/dev_env/Dockerfile
+++ b/docker/dev_env/Dockerfile
@@ -14,8 +14,6 @@ FROM docker.io/library/fedora:41
# permissions issues to contend with and as such run the container as root)
ENV HOME="/opt"
-# location where PDM installs Python interpreters
-ENV PDM_PYTHONS="${HOME}/pdm/bin"
# location where `n` installs Node.js versions
ENV N_PREFIX="${HOME}/n"
@@ -27,7 +25,7 @@ ENV PNPM_BIN="${HOME}/pnpm"
ARG PREK_VERSION=0.5.10
# Add tooling installed in custom locations to `PATH`.
-ENV PATH="${PNPM_BIN}:${N_PREFIX}/bin:${PDM_PYTHONS}:${HOME}/.local/bin:${PATH}"
+ENV PATH="${PNPM_BIN}:${N_PREFIX}/bin:${HOME}/.local/bin:${PATH}"
# Dependency explanations:
# - git: required by some python package; contributors should use git on their host
@@ -50,7 +48,7 @@ ENV PATH="${PNPM_BIN}:${N_PREFIX}/bin:${PDM_PYTHONS}:${HOME}/.local/bin:${PATH}"
#
# pipx dependencies:
# - httpie: CLI HTTP client
-# - pdm, pipenv, uv: Python package managers
+# - pipenv, uv: Python package managers
# - prek: Git pre-commit and pre-push hook manager
# - pgcli: PostgreSQL CLI
#
@@ -83,7 +81,7 @@ RUN mkdir -p $HOME/.local/bin \
&& dnf5 clean all \
&& pipx install --global \
httpie \
- pdm pipenv uv \
+ pipenv uv \
pgcli \
prek==${PREK_VERSION} \
&& npm install -g \
@@ -91,8 +89,6 @@ RUN mkdir -p $HOME/.local/bin \
&& corepack enable
-# Avoid overwriting `.venv`'s from the host
-ENV PDM_VENV_IN_PROJECT="False"
# Keep uv's environments apart from the host's `.venv`, and its cache and
# Python builds in the persisted `/opt` volume. The cache and the bind-mounted
# repository are on different filesystems, so uv copies instead of linking.
diff --git a/docker/dev_env/run.sh b/docker/dev_env/run.sh
index 8d1d282f9..ac284650c 100755
--- a/docker/dev_env/run.sh
+++ b/docker/dev_env/run.sh
@@ -14,8 +14,6 @@ shared_args=(
-i
--env "OPENVERSE_PROJECT=$OPENVERSE_PROJECT"
--env "TERM=xterm-256color"
- # Avoid overwriting `.venv`'s from the host
- --env "PDM_VENV_IN_PROJECT=False"
# Install global pipx packages separate from user packages
# Prevents permissions issue with packages installed as root
# when running packages.sh
@@ -104,25 +102,18 @@ if command -v pnpm &>/dev/null; then
fi
fi
-if command -v pdm &>/dev/null; then
- if [ ! -f "$DEV_ENV"/.cache/pdm-cache-path ]; then
- # These commands can be slow, so cache the response
- # Should be safe, it's rare to change this
- if [ "$(pdm config --quiet install.cache)" == "True" ]; then
- pdm config --quiet cache_dir >"$DEV_ENV"/.cache/pdm-cache-path
- else
- echo "" >"$DEV_ENV"/.cache/pdm-cache-path
- fi
+if command -v uv &>/dev/null; then
+ if [ ! -f "$DEV_ENV"/.cache/uv-cache-path ]; then
+ # Cache the response; it's rare for this to change
+ uv cache dir >"$DEV_ENV"/.cache/uv-cache-path
fi
- host_pdm_cache=$(cat "$DEV_ENV"/.cache/pdm-cache-path)
+ host_uv_cache=$(cat "$DEV_ENV"/.cache/uv-cache-path)
- # Share the PDM cache with the container, if it's available locally
- # --quiet so PDM doesn't repeatedly fill the console with update messages
- # if they're enabled
- if [ -n "$host_pdm_cache" ]; then
- shared_args+=(--env "PDM_CACHE_DIR=$host_pdm_cache")
- run_args+=(-v "$host_pdm_cache:$host_pdm_cache:rw,z")
+ # Share the uv cache with the container, if it's available locally
+ if [ -n "$host_uv_cache" ]; then
+ shared_args+=(--env "UV_CACHE_DIR=$host_uv_cache")
+ run_args+=(-v "$host_uv_cache:$host_uv_cache:rw,z")
fi
fi
diff --git a/docker/dev_env/setup_env.sh b/docker/dev_env/setup_env.sh
index 89256fbbc..5431bcb29 100755
--- a/docker/dev_env/setup_env.sh
+++ b/docker/dev_env/setup_env.sh
@@ -22,18 +22,11 @@ if [[ -n $PNPM_HOME && ! -L $PNPM_BIN ]]; then
ln -s "$PNPM_HOME" "$PNPM_BIN"
fi
-pdm config python.install_root "/opt/pdm/python"
-pdm config venv.location "/opt/pdm/venvs"
-
-_python3s=(/opt/pdm/python/[email protected].*/bin/python3)
-
-if [ ! -x "${_python3s[0]}" ]; then
+if ! PYTHON_311=$(uv python find 3.11 2>/dev/null); then
printf "Installing the specific Python version required for pipenv environments\n"
- pdm python install 3.11
- _python3s=(/opt/pdm/python/[email protected].*/bin/python3)
+ uv python install 3.11
+ PYTHON_311=$(uv python find 3.11)
fi
-
-PYTHON_311=${_python3s[0]}
export PYTHON_311
if [ ! -x /usr/local/bin/python3.11 ]; then
@@ -45,7 +38,3 @@ if [ -z "$(command -v pipenv)" ]; then
# still using it, otherwise it gets confused about which dependencies to use
pipx install pipenv --python "$PYTHON_311"
fi
-
-if [ -n "$PDM_CACHE_DIR" ]; then
- pdm config install.cache on
-fi
diff --git a/documentation/general/general_setup.md b/documentation/general/general_setup.md
index 0d68ffe5b..fb5068a31 100644
--- a/documentation/general/general_setup.md
+++ b/documentation/general/general_setup.md
@@ -122,12 +122,10 @@ ones you might see used throughout the documentation:
`ov just` to see all available recipes.
- [`jq`](https://stedolan.github.io/jq/) is a tool for parsing and manipulating
JSON data. Openverse loves `jq`! Try `ov jq --help` for information.
-- [`pdm`](https://pdm-project.org/en/stable/) is a Python package manager. You
- can use it in any Openverse directory to interact with `pyproject.toml` and
- different virtual environments. Try `ov pdm --help` for info.
-- [`uv`](https://docs.astral.sh/uv/) is the Python package manager that is
- replacing `pdm`. Projects with a `uv.lock` file use it: `ov uv sync` installs
- their dependencies and `ov uv run` runs commands in their environment.
+- [`uv`](https://docs.astral.sh/uv/) is a Python package manager. You can use it
+ in any Openverse directory with a `pyproject.toml` and `uv.lock`: `ov uv sync`
+ installs dependencies and `ov uv run` runs commands in the project's
+ environment. Try `ov uv --help` for info.
- [`httpie`](https://httpie.io/docs/cli) is a command line HTTP client. Like
cURL but with a lot of conveniences and easier to remember. Try `http --help`
for info.
diff --git a/justfile b/justfile
index e67feb40d..0c833cc62 100644
--- a/justfile
+++ b/justfile
@@ -220,7 +220,6 @@ env:
DOCKER_FILE := "-f docker-compose.yml"
EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }
-export OV_PDM_VERSION := env_var_or_default("OV_PDM_VERSION", "2.21")
# Keep in sync with the `Setup uv` step in `.github/actions/setup-env/action.yml`.
export OV_UV_VERSION := env_var_or_default("OV_UV_VERSION", "0.13.5")
export CATALOG_PY_VERSION := `just catalog/py-version`
@@ -238,7 +237,6 @@ export HOST_NETWORK_ADDRESS := if os() == "macos" { "host.docker.internal" } els
versions:
#!/usr/bin/env bash
cat <<EOF
- ov_pdm_version=$(echo $OV_PDM_VERSION)
ov_uv_version=$(echo $OV_UV_VERSION)
catalog_py_version=$(just catalog/py-version)
catalog_airflow_version=$(just catalog/airflow-version)
diff --git a/ov b/ov
index c56d5461f..ffd0ee6a2 100755
--- a/ov
+++ b/ov
@@ -71,7 +71,7 @@ COMMANDS
some of the following:
- ov just
- - ov pdm
+ - ov uv
- ov pnpm
- ov python
- ov bash
@@ -112,7 +112,7 @@ doctor)
case "$OSTYPE" in
linux*)
- # For some reason permissions can get mixed up in `/opt` and PDM will fail to create venvs
+ # For some reason permissions can get mixed up in `/opt` and uv will fail to create venvs
# This is only relevant to Linux hosts because macOS hosts run the container as root regardless
printf " - Fixing file permissions in container's /opt\n"
"$_self" sudo chmod -R 0777 /opt