用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/awslabs/aws-glue-libs --skill venv-migration命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | venv-migration |
| description | Migrate an AWS Glue job from --additional-python-modules to --python-virtual-env. |
When the user asks you to migrate a Glue job from --additional-python-modules to
--python-virtual-env, execute the entire migration end to end using your tools. Do not
only describe the steps.
The only thing you should ask the user for is the S3 bucket and path to upload the final tarball to (step 6). Execute everything else yourself.
Create all files in a working directory at ~/glue-venv-migration/, build and run Docker
containers, and produce the final pyspark_venv.tar.gz.
Migrating from --additional-python-modules to --python-virtual-env requires a
requirements file that captures every dependency the job needs. This is not always
straightforward, because dependencies come from several sources and not all of them are
explicitly declared:
--additional-python-modules,
for example pandas==2.0,requests==2.28.--additional-python-modules, the customer might be unaware of the dependency.
b. The version actually running might differ from the version listed in the Glue
documentation, because --additional-python-modules can override the container
version.--python-modules-installer-option: -r with a requirements file in S3. The file might
contain unpinned versions or version ranges, so the venv build could resolve to
different versions than what previously ran on Glue.--python-modules-installer-option: --no-deps --index-url to pull from a self-hosted
repository. The venv build environment must be able to reach the same private index.| Glue version | Python | Base image | base-requirements.txt branch | Glue library |
|---|---|---|---|---|
| 5.0 | 3.11 | public.ecr.aws/amazonlinux/amazonlinux:2023-minimal | glue-5.0 | AWSGlueDataplanePython==5.0.0 |
| 5.1 | 3.11 | public.ecr.aws/amazonlinux/amazonlinux:2023-minimal | glue-5.1 | AWSGlueDataplanePython==5.1.0 |
| 6.0 | 3.13 | public.ecr.aws/amazonlinux/amazonlinux:2023-minimal | main | AWSGlueDataplanePython==6.0.0 |
Substitute the Python version, branch, and library version from this table wherever the
steps below use 3.11, glue-5.0, or AWSGlueDataplanePython==5.0.0.
Execute all of the following steps yourself. Do not ask the user to run commands.
From the user's message, extract:
--additional-python-modules, for example "ephem, awscli"Download base-requirements.txt for the user's Glue version from the branch named in the
table above. For example, for Glue 6.0:
curl -fsSL -o ~/glue-venv-migration/base-requirements.txt \
https://raw.githubusercontent.com/awslabs/aws-glue-libs/main/base-requirements.txt
If that file is unavailable, fall back to the markdown version of the documentation page: https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-python-libraries.md
That endpoint contains the module lists for all Glue versions in plain text. From the fetched content, extract the module list under the heading that matches the user's Glue version, for example "AWS Glue version 5.0".
Create the following files in ~/glue-venv-migration/:
base-requirements.txt - the module list from step 2 for the user's Glue version.
additional-requirements.txt - one package per line from the user's
--additional-python-modules.
my_glue_script/main.py - the user's Glue job script, so that pipreqs can analyze its
imports.
Dockerfile - use the base image and Python version for the user's Glue version. For
Glue 5.0 and 5.1:
FROM --platform=linux/amd64 public.ecr.aws/amazonlinux/amazonlinux:2023-minimal
RUN dnf install -y python3.11 zip && \
dnf clean all
WORKDIR /build
For Glue 6.0, install python3.13 instead of python3.11.
build-venv.sh - the build script that runs inside the container, described in step 5.
In build-venv.sh, pin AWSGlueDataplanePython to the version that matches the user's
Glue version, as listed in the table above.
cd ~/glue-venv-migration && docker build --platform linux/amd64 -t glue-venv-builder .
Run the container non-interactively. Do not use -it, so that the container runs to
completion:
cd ~/glue-venv-migration && docker run --platform linux/amd64 \
-v $(pwd)/base-requirements.txt:/working_dir/base-requirements.txt:ro \
-v $(pwd)/additional-requirements.txt:/working_dir/additional-requirements.txt:ro \
-v $(pwd)/my_glue_script/:/working_dir/my_glue_script/:ro \
-v $(pwd)/build-venv.sh:/working_dir/build-venv.sh:ro \
-v $(pwd):/output \
-w /working_dir \
glue-venv-builder bash build-venv.sh 2>&1
The build-venv.sh script must do the following. Adjust the Python version and the
AWSGlueDataplanePython version to match the user's Glue version.
#!/bin/bash
set -e
python3.11 -m venv temp_venv
source temp_venv/bin/activate
python3.11 -m pip install --upgrade pip
python3.11 -m pip install -r base-requirements.txt
python3.11 -m pip install -r additional-requirements.txt
pip freeze > full-requirements.txt
python3.11 -m pip install pipreqs pip-tools
pipreqs --mode no-pin --savepath discovered-requirements.txt /working_dir/my_glue_script
sed -i '/pyspark/d' discovered-requirements.txt
sed -i '/py4j/d' discovered-requirements.txt
sed -i '/awsglue/d' discovered-requirements.txt
pip-compile discovered-requirements.txt -c full-requirements.txt -o final-requirements.txt
echo "=== Final requirements.txt ==="
cat final-requirements.txt
deactivate
rm -rf temp_venv
python3.11 -m venv pyspark_venv
source pyspark_venv/bin/activate
python3.11 -m pip install --upgrade pip
python3.11 -m pip install -r final-requirements.txt
python3.11 -m pip install AWSGlueDataplanePython==5.0.0
python3.11 -m pip install venv-pack
venv-pack -f -o pyspark_venv.tar.gz
cp pyspark_venv.tar.gz /output/
echo "=== Done. pyspark_venv.tar.gz created ==="
After the tarball is built, ask the user for their S3 bucket and path. Then run:
aws s3 cp ~/glue-venv-migration/pyspark_venv.tar.gz s3://BUCKET/PATH/pyspark_venv.tar.gz
Tell the user to update their Glue job.
Remove:
"--additional-python-modules": "<their old value>"
Add:
"--python-virtual-env": "s3://BUCKET/PATH/pyspark_venv.tar.gz"