Skip to content

Commit cf76f39

Browse files
authored
Merge pull request #1 from toyfer/copilot/fix-2c878947-f307-4b41-bf5c-037c33ec15a0
整備README.md - プロジェクト説明とGitHub Actionsワークフローの詳細文書化
2 parents 132a270 + fcb5b86 commit cf76f39

File tree

1 file changed

+165
-1
lines changed

1 file changed

+165
-1
lines changed

README.md

Lines changed: 165 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,165 @@
1-
# embeddable_python_init
1+
# Embeddable Python Init
2+
3+
GitHub Actionsを使用してオフライン・スタンドアロンで動作するPythonパッケージを自動構築・配布するプロジェクトです。
4+
5+
## 🎯 プロジェクトの目的
6+
7+
このプロジェクトは以下の目的で作成されています:
8+
9+
- **オフライン環境**でのPython利用を可能にする
10+
- **スタンドアロン**で動作する実行可能なPythonパッケージを配布
11+
- **GitHub Actions**による自動化されたビルドプロセス
12+
- **カスタマイズ可能**なパッケージ依存関係の管理
13+
14+
## 📦 配布されるパッケージについて
15+
16+
このプロジェクトでは、以下が含まれたPythonパッケージを配布します:
17+
18+
- **Python 3.13.7 (Embeddable版)**
19+
- **pip** パッケージマネージャー
20+
- **pandas** (デフォルト依存パッケージ)
21+
22+
配布されるパッケージは`Python_Embeddable.zip`として[Releases](https://github.com/toyfer/embeddable_python_init/releases/latest)からダウンロードできます。
23+
24+
## 🚀 使用方法
25+
26+
### 1. 配布パッケージのダウンロード
27+
28+
```bash
29+
# 最新リリースから Python_Embeddable.zip をダウンロード
30+
curl -L -o Python_Embeddable.zip https://github.com/toyfer/embeddable_python_init/releases/latest/download/Python_Embeddable.zip
31+
```
32+
33+
### 2. パッケージの展開と実行
34+
35+
```bash
36+
# Windows環境での例
37+
unzip Python_Embeddable.zip -d Python/
38+
cd Python/
39+
python.exe -c "import pandas; print('Pandas version:', pandas.__version__)"
40+
```
41+
42+
## 🔧 カスタマイズ方法
43+
44+
### 依存パッケージの追加・変更
45+
46+
`.github/workflows/init-python.yml`の以下の部分を編集してください:
47+
48+
```yaml
49+
- name: Python Embeddable Setup Dependencies
50+
run: |
51+
.\Python\Python.exe -m pip install pandas
52+
# 追加したいパッケージをここに記載
53+
# .\Python\Python.exe -m pip install numpy matplotlib requests
54+
```
55+
56+
### Pythonバージョンの変更
57+
58+
```yaml
59+
- name: Python Embeddable Download
60+
run: Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.13.7/python-3.13.7-embed-amd64.zip -Outfile Python.zip
61+
# ↑ URLを変更してバージョンを調整
62+
```
63+
64+
## 🔄 GitHub Actions ワークフローの詳細
65+
66+
### ワークフローの概要
67+
68+
このプロジェクトのGitHub Actionsワークフロー(`.github/workflows/init-python.yml`)は以下の流れで動作します:
69+
70+
```mermaid
71+
graph TD
72+
A[Push イベント] --> B[Windows環境でジョブ開始]
73+
B --> C[リポジトリをチェックアウト]
74+
C --> D[Python Embeddableをダウンロード]
75+
D --> E[Pythonのセットアップ]
76+
E --> F[依存パッケージのインストール]
77+
F --> G[Pythonパッケージの圧縮]
78+
G --> H[GitHubリリースの更新]
79+
```
80+
81+
### 各ステップの詳細
82+
83+
#### 1. Check out code
84+
```yaml
85+
- name: Check out code
86+
uses: actions/checkout@v5
87+
```
88+
**役割**: リポジトリのソースコードをワークフロー実行環境にチェックアウトします。
89+
- `actions/checkout@v5`: GitHub公式のアクションでリポジトリのコンテンツを取得
90+
91+
#### 2. Python Embeddable Download
92+
```yaml
93+
- name: Python Embeddable Download
94+
run: Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.13.7/python-3.13.7-embed-amd64.zip -Outfile Python.zip
95+
```
96+
**役割**: Python.orgからPython 3.13.7のEmbeddable版をダウンロードします。
97+
- Embeddable版は軽量でスタンドアロン実行に適した形式
98+
99+
#### 3. Python Embeddable Setup
100+
```yaml
101+
- name: Python Embeddable Setup
102+
run: |
103+
Expand-Archive .\Python.zip -DestinationPath .\Python\
104+
(Get-Content .\Python\Python313._pth) -replace '#import site', 'import site' | Set-Content .\Python\Python313._pth
105+
Invoke-WebRequest -Uri https://bootstrap.pypa.io/get-pip.py -Outfile .\Python\get-pip.py
106+
.\Python\Python.exe .\Python\get-pip.py
107+
.\Python\Python.exe -m pip install -U pip
108+
```
109+
**役割**: ダウンロードしたPythonの初期セットアップを実行します。
110+
- ZIPファイルの展開
111+
- `site`モジュールの有効化(サードパーティパッケージのインストールに必要)
112+
- pipのインストール
113+
- pipのアップグレード
114+
115+
#### 4. Python Embeddable Setup Dependencies
116+
```yaml
117+
- name: Python Embeddable Setup Dependencies
118+
run: |
119+
.\Python\Python.exe -m pip install pandas
120+
```
121+
**役割**: 指定した依存パッケージをインストールします。
122+
- ここでパッケージを追加・変更することで、配布パッケージの内容をカスタマイズ可能
123+
124+
#### 5. Compress Python
125+
```yaml
126+
- name: Compress Python
127+
run: Compress-Archive -Path .\Python\* -DestinationPath .\Python_Embeddable.zip
128+
```
129+
**役割**: セットアップ完了したPythonを配布用にZIP圧縮します。
130+
131+
#### 6. Update Release
132+
```yaml
133+
- name: Update Release (always update latest release)
134+
uses: softprops/action-gh-release@v2
135+
with:
136+
tag_name: latest
137+
name: Python Embeddable with UV
138+
# ... その他の設定
139+
```
140+
**役割**: GitHubリリースを作成・更新し、配布パッケージを公開します。
141+
- `softprops/action-gh-release@v2`: GitHub Releasesを作成・更新するためのサードパーティアクション
142+
- `tag_name: latest`で常に最新版として更新
143+
- `make_latest: true`で最新リリースとしてマーク
144+
145+
## 🔐 必要な権限
146+
147+
ワークフローには以下の権限が設定されています:
148+
149+
```yaml
150+
permissions:
151+
contents: write # Release作成に必要
152+
```
153+
154+
## 📝 ライセンス
155+
156+
このプロジェクトはMITライセンスのもとで公開されています。詳細は[LICENSE](LICENSE)ファイルをご確認ください。
157+
158+
## 🤝 コントリビューション
159+
160+
プルリクエストやIssueでのフィードバックを歓迎します。
161+
162+
## 📚 関連リンク
163+
164+
- [Python Embeddable Package](https://docs.python.org/3/using/windows.html#embedded-distribution)
165+
- [GitHub Actions Documentation](https://docs.github.com/en/actions)

0 commit comments

Comments
 (0)