Skip to content

Commit

Permalink
[Feature] Change the build method from pyinstaller to cx_Freeze.
Browse files Browse the repository at this point in the history
将pyinstaller构建方式更改为cx_Freeze
  • Loading branch information
Physton committed Dec 7, 2023
1 parent 6ea6b78 commit 0f213a4
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
/venv
/release
/.idea
/venv.*
/bookmark.html
/bookmark.json
24 changes: 18 additions & 6 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,27 @@

### Using the executable file (no Python environment required)

1. Go to [Releases](https://github.com/Physton/arc-bookmarks/releases) and download [arc-bookmarks](https://github.com/Physton/arc-bookmarks/releases/latest/download/arc-bookmarks).
2. Open the system `Terminal` application.
3. Add executable permission to the `arc-bookmarks` file.
> For versions prior to v0.0.4, please refer to this document: [README](https://github.com/Physton/arc-bookmarks/tree/6ea6b782665f7c790511c3c0a3034809bd504d89#usage)
1. Go to [Releases](https://github.com/Physton/arc-bookmarks/releases) and download according to your system version.
- [M1/M../arm64 (Apple Silicon)](https://github.com/Physton/arc-bookmarks/releases/latest/download/arc-bookmarks.macos.arm64.zip)
- [x86_64 (Intel)](https://github.com/Physton/arc-bookmarks/releases/latest/download/arc-bookmarks.macos.x86_64.zip)
2. Unzip the `arc-bookmarks.macos.*.zip` file.
3. Open the `Terminal` application on your system.
4. Navigate to the `arc-bookmarks.macos.*` folder.
```bash
chmod +x ~/Downloads/arc-bookmarks
# Apple Silicon
cd ~/Downloads/arc-bookmarks.macos.arm64
# Intel
cd ~/Downloads/arc-bookmarks.macos.x86_64
```
4. Execute the `arc-bookmarks` file.
5. Add execution permissions to the `arc-bookmarks` file.
```bash
~/Downloads/arc-bookmarks --save-html=~/Downloads/bookmark.html
chmod +x ./arc-bookmarks
```
6. Run the `arc-bookmarks` file.
```bash
./arc-bookmarks --save-html=~/Downloads/bookmark.html
```

### Using Python to run
Expand Down
24 changes: 18 additions & 6 deletions README_CN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,27 @@

### 使用可执行文件(无需 python 环境)

1. 前往 [Releases](https://github.com/Physton/arc-bookmarks/releases),下载 [arc-bookmarks](https://github.com/Physton/arc-bookmarks/releases/latest/download/arc-bookmarks)
2. 打开系统 `终端` 应用程序。
3.`arc-bookmarks` 文件添加可执行权限。
> v0.0.4 之前的版本,请查看此文档:[README](https://github.com/Physton/arc-bookmarks/blob/6ea6b782665f7c790511c3c0a3034809bd504d89/README_CN.MD#%E4%BD%BF%E7%94%A8)
1. 前往 [Releases](https://github.com/Physton/arc-bookmarks/releases),根据自己的系统版本下载。
- [M1/M../arm64 (Apple Silicon)](https://github.com/Physton/arc-bookmarks/releases/latest/download/arc-bookmarks.macos.arm64.zip)
- [x86_64 (Intel)](https://github.com/Physton/arc-bookmarks/releases/latest/download/arc-bookmarks.macos.x86_64.zip)
2. 解压缩 `arc-bookmarks.macos.*.zip` 文件。
3. 打开系统 `终端` 应用程序。
4. 进入 `arc-bookmarks.macos.*` 文件夹。
```bash
chmod +x ~/Downloads/arc-bookmarks
# Apple Silicon
cd ~/Downloads/arc-bookmarks.macos.arm64
# Intel
cd ~/Downloads/arc-bookmarks.macos.x86_64
```
4. 执行 `arc-bookmarks` 文件
5. `arc-bookmarks` 文件添加可执行权限
```bash
~/Downloads/arc-bookmarks --save-html=~/Downloads/bookmark.html
chmod +x ./arc-bookmarks
```
6. 执行 `arc-bookmarks` 文件。
```bash
./arc-bookmarks --save-html=~/Downloads/bookmark.html
```

### 使用 python 运行
Expand Down
57 changes: 55 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
#!/bin/bash
./venv/bin/pyinstaller main.py -F -n arc-bookmarks
chmod +x dist/arc-bookmarks

set -e

echo_success() {
echo -e "\033[32m$1\033[0m"
}

echo_error() {
echo -e "\033[31m$1\033[0m"
}

build() {
platform=$1
echo_success "========= Building for $platform ========="

if [ "$platform" = "x86_64" ]; then
arch_prefix="arch -x86_64"
brew_prefix="/usr/local"
elif [ "$platform" = "arm64" ]; then
arch_prefix="arch -arm64"
brew_prefix="/opt/homebrew"
else
echo_error "Invalid platform"
exit 1
fi

eval "$($arch_prefix $brew_prefix/bin/brew shellenv)"

if [ ! -d ./venv.$platform ]; then
echo_success "Creating venv.$platform"
${brew_prefix}/bin/python3 -m venv ./venv.$platform
fi

# echo "Activating venv.$platform"
# source ./venv.$platform/bin/activate

echo_success "Installing requirements"
$arch_prefix ./venv.$platform/bin/pip3 install -r requirements.txt

echo_success "Building arc-bookmarks"
build_name="arc-bookmarks.macos.$platform"
$arch_prefix ./venv.$platform/bin/cxfreeze -c main.py --target-name=arc-bookmarks --target-dir=build/$build_name
chmod +x build/$build_name/arc-bookmarks
cd build
zip -r $build_name.zip $build_name -9
rm -rf $build_name
cd ..

echo_success "Build successful"
}

rm -rf build

build x86_64
build arm64
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import requests

VERSION = 'v0.0.3'
VERSION = 'v0.0.4'
REPO = 'Physton/arc-bookmarks'
GITHUB = f'https://github.com/{REPO}'

Expand Down
9 changes: 7 additions & 2 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@
release = repo.create_git_release(tag_name, release_title, release_body)

# 上传文件到发布
file_name = 'arc-bookmarks'
file_path = os.path.join(main_path, 'dist', file_name)
file_name = 'arc-bookmarks.macos.arm64.zip'
file_path = os.path.join(main_path, 'build', file_name)
file_path = os.path.abspath(file_path)
release.upload_asset(file_path, content_type='application/octet-stream', label=file_name)

file_name = 'arc-bookmarks.macos.x86_64.zip'
file_path = os.path.join(main_path, 'build', file_name)
file_path = os.path.abspath(file_path)
release.upload_asset(file_path, content_type='application/octet-stream', label=file_name)

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests
cx_Freeze

0 comments on commit 0f213a4

Please sign in to comment.