下载镜像
# 创建目录
mkdir my-python-deps && cd my-python-deps
# 下载主依赖 + requirements.txt 中的依赖(推荐合并处理)
pip download \
--no-binary=:all: \ # 或保留为 --only-binary=:all: 如果目标环境无编译工具
--dest ./ \
fastapi uvicorn pandas scikit-learn numpy -r requirements.txt
下载 可以上传格式的依赖文件 ,版本分为windows 和linux
# 创建文件夹
mkdir my-pip-deps
cd my-pip-deps
# 下载主依赖 + requirements.txt(如果有)
pip download ^
--platform win_amd64 ^
--python-version 311 ^
--only-binary=:all: ^
--dest ./ ^
fastapi uvicorn pandas scikit-learn numpy -r ..\requirements.txt
#linux
pip download ^
--platform manylinux_2_17_x86_64 ^
--python-version 311 ^
--only-binary=:all: ^
--dest ./my-pip-deps ^
fastapi uvicorn pandas scikit-learn numpy -r ..\requirements.txt
nexus上传脚本
@echo off
setlocal enabledelayedexpansion
REM =============== 配置区 ===============
set "UPLOAD_URL=http://127.0.0.1:8091/service/rest/internal/ui/upload/pypi"
set "CSRF_TOKEN=0.7999332641936825"
set "COOKIE=NXSESSIONID=35fb4f2f-35d2-4448-9251-e980a0f8a6ca; NX-ANTI-CSRF-TOKEN=%CSRF_TOKEN%; sid=00afc891329c265ed22cfd8e3c77fa7f"
echo 正在上传当前目录中的 .whl 文件到 PyPI 仓库...
echo.
for %%f in (*.whl) do (
echo [+] 尝试上传: %%~nxf
for /f "delims=" %%r in ('curl -s -X POST "%UPLOAD_URL%" ^
-b "%COOKIE%" ^
-F "NX-ANTI-CSRF-TOKEN=%CSRF_TOKEN%" ^
-F "asset3=@%%f;type=application/octet-stream" ^
-H "Referer: http://config.zhgw.cnpc:8091/" ^
-H "Origin: http://config.zhgw.cnpc:8091"' ) do (
set "RESPONSE=%%r"
)
REM 检查响应是否包含 "success":true
echo !RESPONSE! | findstr /C:"\"success\":true" >nul
if !errorlevel! equ 0 (
echo ? 上传成功
) else (
echo ?? 已存在或上传失败(仓库禁止覆盖)
)
echo --------------------------------------------------
)
echo.
echo [*] 所有文件处理完毕。
pause
759

被折叠的 条评论
为什么被折叠?



