Skip to content

Commit

Permalink
修复打包
Browse files Browse the repository at this point in the history
  • Loading branch information
Wulian233 committed Aug 3, 2024
1 parent 6f40151 commit 07d61a8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text eol=lf
*.png binary
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
**/__pycache__
**/.vscode
*.exe
**/.idea
*.zip
/__main__.build
Expand Down
6 changes: 0 additions & 6 deletions PyBuild/unix_build.sh

This file was deleted.

5 changes: 0 additions & 5 deletions PyBuild/win_build.bat

This file was deleted.

28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WIP

## Develop and Build
### Requirements
- **Git**: 3.8+
- **Git**
- **Python Version**: 3.8+
- **Supported Operating Systems**: Windows 10 or later, macOS, Linux

Expand All @@ -29,28 +29,22 @@ WIP
pip install -r requirements.txt
```

2. **Run**:
- After installing the dependencies, run `__main__.py`
2. **Run the Application**:
- **Windows**: Use the command `python __main__.py`
- **macOS and Linux**: Use the command `python3 __main__.py`

### Building Executable for Windows
### Building Executable

1. **Package as Executable**:
- To package the application as an executable for Windows, run the following script:
- Windows
```bash
cd PyBuild
win_build.bat
pip install pyinstaller
pyinstaller main.spec
```
- Unix
```bash
cd PyBuild
unix_build.sh
```
2. **Locate the Executable**:
- The resulting `.exe` file will be located in the `dist` folder.
3. **Locate the Executable**:
- For **Windows**, the executable will be a `.exe` file located in the `dist` folder.
- For **macOS**, the application will be packaged as a `.app` bundle, also found in the `dist` folder.
- For **Linux**, the executable will be a standalone file in the `dist` folder.

3. **Additional Steps**:
- Copy the `feedtheforge/lang` folder to the `dist` directory

## LICENSE
[GNU General Public License v3.0](.LICENSE)
16 changes: 10 additions & 6 deletions feedtheforge/i18n.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import json
import sys
from pathlib import Path
import json
from string import Template


class Locale:
def __init__(self, lang: str):
self.lang = lang
self.path = Path(f"./feedtheforge/lang/{lang}.json")
if getattr(sys, 'frozen', False):
# If running in a bundle
self.path = Path(sys._MEIPASS) / f"feedtheforge/lang/{lang}.json"
else:
# If running in a normal Python environment
self.path = Path(f"./feedtheforge/lang/{lang}.py")
self.data = {}
self.load()

Expand All @@ -20,7 +25,6 @@ def load(self):
with open(self.path, "r", encoding="utf-8") as f:
d = f.read()
self.data = json.loads(d)
f.close()

def get_string(self, key: str, failed_prompt):
n = self.data.get(key, None)
Expand All @@ -36,5 +40,5 @@ def t(self, key: str, failed_prompt=True, *args, **kwargs):

def get_language(self):
return self.lang
lang = Locale("zh_CN")

lang = Locale("zh_CN")
7 changes: 5 additions & 2 deletions main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ a = Analysis(
['__main__.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=['aiohttp','pick'],
datas=[
('feedtheforge/lang/zh_CN.json', 'feedtheforge/lang'),
('feedtheforge/lang/en_US.json', 'feedtheforge/lang')
],
hiddenimports=['aiohttp', 'pick'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
Expand Down

0 comments on commit 07d61a8

Please sign in to comment.