-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 新增自动打包windows下的环境依赖 --------- Co-authored-by: binary-husky <qingxu.fu@outlook.com>
- Loading branch information
1 parent
a88b119
commit ed5fc84
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Create Conda Environment Package | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Miniconda | ||
uses: conda-incubator/setup-miniconda@v3 | ||
with: | ||
auto-activate-base: true | ||
activate-environment: "" | ||
|
||
- name: Create new Conda environment | ||
shell: bash -l {0} | ||
run: | | ||
conda create -n gpt python=3.11 -y | ||
conda activate gpt | ||
- name: Install requirements | ||
shell: bash -l {0} | ||
run: | | ||
conda activate gpt | ||
pip install -r requirements.txt | ||
- name: Install conda-pack | ||
shell: bash -l {0} | ||
run: | | ||
conda activate gpt | ||
conda install conda-pack -y | ||
- name: Pack conda environment | ||
shell: bash -l {0} | ||
run: | | ||
conda activate gpt | ||
conda pack -n gpt -o gpt.tar.gz | ||
- name: Create workspace zip | ||
shell: pwsh | ||
run: | | ||
mkdir workspace | ||
Get-ChildItem -Exclude "workspace" | Copy-Item -Destination workspace -Recurse | ||
Remove-Item -Path workspace/.git* -Recurse -Force -ErrorAction SilentlyContinue | ||
Copy-Item gpt.tar.gz workspace/ -Force | ||
- name: Upload packed files | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: gpt-academic-package | ||
path: workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@echo off | ||
setlocal | ||
|
||
:: 设置环境变量 | ||
set ENV_NAME=gpt | ||
set ENV_PATH=%~dp0%ENV_NAME% | ||
set SCRIPT_PATH=%~dp0main.py | ||
|
||
:: 判断环境是否已解压 | ||
if not exist "%ENV_PATH%" ( | ||
echo Extracting environment... | ||
mkdir "%ENV_PATH%" | ||
tar -xzf gpt.tar.gz -C "%ENV_PATH%" | ||
|
||
:: 运行conda环境激活脚本 | ||
call "%ENV_PATH%\Scripts\activate.bat" | ||
) else ( | ||
:: 如果环境已存在,直接激活 | ||
call "%ENV_PATH%\Scripts\activate.bat" | ||
) | ||
echo Start to run program: | ||
:: 运行Python脚本 | ||
python "%SCRIPT_PATH%" | ||
|
||
endlocal | ||
pause |