rft: devcontainer 从 conda 迁移至 mise/uv (#15251)

Co-authored-by: Lucien Shaw <myxlc55@outlook.com>
This commit is contained in:
SherkeyXD
2026-01-02 21:45:14 +08:00
committed by GitHub
parent 8fc0e56556
commit c396c95b31
5 changed files with 47 additions and 54 deletions

View File

@@ -2,29 +2,25 @@ FROM mcr.microsoft.com/devcontainers/base:ubuntu
USER vscode
ENV CONDA_DIR=/home/vscode/miniconda
ENV PATH="$CONDA_DIR/bin:$PATH"
ENV PATH="/home/vscode/.local/bin:${PATH}"
ARG PYTHON_VERSION=3.12
ARG PYTHON_VERSION=3.12.11
ARG NODEJS_VERSION=24
# Install Miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \
&& bash ~/miniconda.sh -b -p $CONDA_DIR \
&& rm ~/miniconda.sh \
&& conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main \
&& conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
# Install and setup mise and uv
RUN curl https://mise.run | sh
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Configure conda environment
RUN eval "$(conda shell.bash hook)" \
&& conda create -n maa \
&& conda activate maa \
&& conda install -y \
python=$PYTHON_VERSION \
conda-forge::nodejs=$NODEJS_VERSION \
&& pip install pre-commit
# Activate mise
RUN echo 'eval "$(mise activate bash)"' >> ~/.bashrc
# Finalize conda setup
RUN conda init \
&& conda config --set auto_activate false \
&& echo "conda activate maa" >> ~/.bashrc
# Setup Python and Node.js
RUN mise use -g node@$NODEJS_VERSION
RUN uv python install $PYTHON_VERSION
# Create and activate venv
RUN uv venv --clear ~/.venv/maa
RUN echo "source ~/.venv/maa/bin/activate" >> ~/.bashrc
# Install tools
RUN uv tool install prek

View File

@@ -1,8 +1,6 @@
#!/bin/bash
WORKSPACE=$(pwd)
# conda activate maa
echo "===================="
cd "$WORKSPACE"
echo "Setting up git safe.directory..."

View File

@@ -2,36 +2,40 @@ FROM mcr.microsoft.com/devcontainers/base:ubuntu
USER vscode
ENV CONDA_DIR=/home/vscode/miniconda
ENV PATH="$CONDA_DIR/bin:$PATH"
ENV PATH="/home/vscode/.local/bin:${PATH}"
ARG CLANGD_VERSION=20
ARG PYTHON_VERSION=3.12
ARG PYTHON_VERSION=3.12.11
ARG NODEJS_VERSION=24
# Install system dependencies
RUN sudo apt update \
&& sudo apt upgrade -y \
&& sudo apt install -y \
cmake
cmake \
fish \
&& sudo rm -rf /var/lib/apt/lists/*
# Install Miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \
&& bash ~/miniconda.sh -b -p ${CONDA_DIR} \
&& rm ~/miniconda.sh \
&& conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main \
&& conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
# Initialize fish
RUN fish -c exit
# Configure conda environment
RUN eval "$(conda shell.bash hook)" \
&& conda create -n maa \
&& conda activate maa \
&& conda install -y \
python=${PYTHON_VERSION} \
conda-forge::nodejs=${NODEJS_VERSION} \
&& pip install pre-commit ruff
# Install and setup mise and uv
RUN curl https://mise.run | sh
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Finalize conda setup
RUN conda init \
&& conda config --set auto_activate false \
&& echo "conda activate maa" >> ~/.bashrc
# Activate mise
RUN echo 'eval "$(mise activate bash)"' >> ~/.bashrc
RUN echo 'mise activate fish | source' >> ~/.config/fish/config.fish
# Setup Python and Node.js
RUN mise use -g node@$NODEJS_VERSION
RUN uv python install $PYTHON_VERSION
# Create and activate venv
RUN uv venv --clear ~/.venv/maa
RUN echo "source ~/.venv/maa/bin/activate" >> ~/.bashrc
RUN echo "source ~/.venv/maa/bin/activate.fish" >> ~/.config/fish/config.fish
# Install tools
RUN uv tool install prek
RUN uv tool install ruff

View File

@@ -42,7 +42,7 @@
// Language-specific formatting
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
@@ -54,12 +54,9 @@
"editor.defaultFormatter": "xaver.clang-format"
},
// Python formatting and linting
"isort.args": ["--profile", "black"],
// Python runtime
"python.terminal.launchArgs": ["-u"],
"python.defaultInterpreterPath": "/home/vscode/miniconda/envs/maa/bin/python",
"python.defaultInterpreterPath": "/home/vscode/.venv/maa/bin/python",
"python.terminal.activateEnvironment": false,
// CMake settings

View File

@@ -1,8 +1,6 @@
#!/bin/bash
WORKSPACE=$(pwd)
# conda activate maa
echo "===================="
cd "$WORKSPACE"
echo "Setting up git safe.directory..."
@@ -27,14 +25,14 @@ echo "Installing Python dependencies..."
for req_file in tools/*/requirements.txt; do
if [ -f "$req_file" ]; then
echo "Installing from $req_file"
pip install -r "$req_file"
uv pip install -r "$req_file"
fi
done
for req_file in tools/*/requirements-dev.txt; do
if [ -f "$req_file" ]; then
echo "Installing from $req_file"
pip install -r "$req_file"
uv pip install -r "$req_file"
fi
done