Skip to content

Commit

Permalink
ci: change python build tool with pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
NtskwK committed Jun 25, 2024
1 parent 4f656ad commit f87479f
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 72 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
key: ${{ runner.os }}-otb-${{ hashFiles('**/main.py') }}
restore-keys: |
${{ runner.os }}-otb-
- if: steps.otb-cache.outputs.cache-hit != 'true'
- if: ${{ steps.otb-cache.outputs.cache-hit != 'true'}}
name: download OTB-9.0.0-Win64.zip
uses: gamedev-thingy/Download-Extract@done
with:
Expand Down Expand Up @@ -74,17 +74,20 @@ jobs:
- name: building and pack
run: |
mkdir "dist/win-unpacked/bin/OTB-9.0.0-Win64"
pip install -r requirements.txt
pip install nuitka
nuitka main.py
pip install pyinstaller
pyinstaller main.py
npm install
npm run pack
cp -r "data" "dist/main"
cp -r "dist/main" "."
ren "main" "bin"
cp -r "data" "main.dist"
ren "main.dist" "bin"
cp -r "bin" "dist/win-unpacked/"
cp -r "bin" "dist/win-unpacked"
cp -r "OTB-9.0.0-Win64" "dist/win-unpacked/bin"
cp -r "data" "dist/win-unpacked/bin"
dir
dir dist
dir "dist/win-unpacked"
dir "dist/win-unpacked/bin"
Expand Down
41 changes: 28 additions & 13 deletions .github/workflows/build_parallel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ jobs:
- name: building
run: |
pip install -r requirements.txt
pip install nuitka
nuitka main.py
pip install pyinstaller
pyinstaller main.py
cp -r "data" "main.dist"
ren "main.dist" "bin"
cp -r "data" "dist/main"
cp -r "dist/main" "."
ren "main" "bin"
7z a -tzip bin.zip bin/*
Expand Down Expand Up @@ -115,21 +116,22 @@ jobs:
run: |
npm install
npm run pack
tree
- name: Upload
uses: actions/upload-artifact@v4
with:
# Artifact name
name: electron_app
# A file, directory or wildcard pattern that describes what to upload
path: "build/win-unpacke/*"
path: "dist/win-unpacked"

pack_app:
needs: [download_otb, build_python_app, build_electron_app]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download0artifact@v4
- uses: actions/download-artifact@v4
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
Expand Down Expand Up @@ -166,23 +168,36 @@ jobs:
# Optional. Default is ${{ github.run_id }}
# run-id:

- uses: actions/download0artifact@v4
- uses: actions/download-artifact@v4
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name: OTB-9.0.0-Win64
name: bin

- uses: actions/download0artifact@v4
- uses: actions/download-artifact@v4
with:
# Name of the artifact to download.
# If unspecified, all artifacts for the run are downloaded.
# Optional.
name: electron_app
path: win_64

- run: |
7z x -o"win_64" "bin.zip"
7z x -o"win_64/bin" "OTB-9.0.0-Win64.zip"
dir
dir bin
dir electron_app
dir OTB-9.0.0-Win64
dir "win_64"
dir "win_64/bin"
dir "win_64/bin/OTB-9.0.0-Win64"
7z a -tzip win_64.zip win_64/*
- name: Upload
uses: actions/upload-artifact@v4
with:
# Artifact name
name: GFB_2.0_win_64
# A file, directory or wildcard pattern that describes what to upload
path: "win_64"

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ main.build/
main.dist/
main.onefile-build
main.exe
main.spec

# venv
venv/

# vscode
.vscode/


build.bat
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@

```bash
pip install nuitka
nuitka main.py --standalone
pyinstaller main.py
```

编译完成后会在目录中生成`main.dist`文件夹, 请`main.dist`文件夹重命名为`bin`
编译完成后会在`dist`目录中生成`main`目录, 请`main`重命名为`bin`

5. 配置Orfeo Toolbox

下载[Orfeo Toolbox](https://www.orfeo-toolbox.org/download/),并解压。

并将解压好的`OTB-*-Win64`文件夹与本项目附带的`data`文件夹一起放入上一步制作的`bin`文件夹中。
并将解压好的`OTB-*-Win64`文件夹与本项目附带的`data`文件夹一起放入上一步的`bin`文件夹中。

6. 将`bin`文件夹放入打包好的Electron文件夹中

Expand All @@ -87,7 +87,9 @@

2. 我看不懂编译说明

请移步 `Github Action`查看具体执行流程 ,本项目的自动编译由Github Action驱动。
~~请移步 `Github Action`查看具体执行流程 ,本项目的自动编译由Github Action驱动。~~ 还没调试好。

**请不要在生产环境使用action内编译的版本,他们不一定是稳定的!**

3. 有关跨平台支持

Expand All @@ -96,3 +98,11 @@
可以自行安装对应平台的OTB并修改源码进行尝试。

欢迎提交PR!

## TODO

- [ ] 解决action编译版无法使用的问题

- [ ] Linux支持

- [ ] 支持高分系列15米级数据正射校正
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,8 @@ def get_rasters_name(dataPath):
elif glob(join(appPath, 'OTB-*-Win64')):
otbPath = glob(join(appPath, 'OTB-*-Win64'))[0]
else:
logger.error(f"OTB not found in{os.path.abspath('.')},\n please downl oadfrom https://www.orfeo-toolbox.org/")
logger.error(f"OTB not found in:{appPath},\n please downl oadfrom https://www.orfeo-toolbox.org/")
assert False,f"OTB not found in:{appPath},\n please downl oadfrom https://www.orfeo-toolbox.org/"
logger.error(f"OTB is not found !")
assert False,f"OTB not found in:{appPath},\n please download from https://www.orfeo-toolbox.org"


os.environ['GDAL_DATA'] = join(otbPath, r"share\data")
Expand Down
43 changes: 0 additions & 43 deletions main.spec

This file was deleted.

7 changes: 5 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f87479f

Please sign in to comment.