使用uv下载并上传到私有仓库(支持python版本修改)

1. 安装uv

curl -LsSf https://astral.sh/uv/install.sh | sh

2.安装twine和

uv run --python 3.9 -m pip install twine==3.8.0 setuptools==50.0.0

  

3.上传shell脚本

package_dir="/opt/python_packages/packages"                            # 包的下载路径
requirement_path="/opt/python_packages/requirements.txt"               # 依赖的路径
python_version=3.8                                                     # python版本
download_url=https://pypi.tuna.tsinghua.edu.cn/simple                  # 下载源地址
upload_url=http://127.0.0.1:8080                                       # 私有仓库地址
upload_user=admin                                                      # 私有仓库账号
upload_password=admin                                                  # 私有仓库密码

uv run --python $python_version python3 -m pip download -d $package_dir -r $requirement_path
# shellcheck disable=SC2010
for item in $(ls $package_dir |grep -E  'whl|tar.gz'); do
        file_path=$package_dir/$item
        echo "$file_path"
        if [ -f "$file_path" ]; then
            uv run --python 3.9  python3 -m twine upload "$file_path" --repository-url $upload_url -u $upload_user -p $upload_password || true
        fi
done

4.添加依赖包并执行脚本

 

posted @ 2026-03-19 15:16  NAVYSUMMER  阅读(6)  评论(0)    收藏  举报
交流群 编程书籍