Skip to content

Commit bd3fd2a

Browse files
committed
PyPI: simple binary runner
1 parent 3872fed commit bd3fd2a

File tree

7 files changed

+77
-192
lines changed

7 files changed

+77
-192
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
workflow_dispatch:
66
permissions:
77
contents: write
8-
id-token: write
98
jobs:
109
main:
1110
runs-on: ${{ matrix.os }}
@@ -62,42 +61,6 @@ jobs:
6261
files: ${{ matrix.binary_name }}
6362
env:
6463
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
- name: Set up Python for wheel building
66-
if: github.event_name == 'release'
67-
uses: actions/setup-python@v5
68-
with:
69-
python-version: '3.x'
70-
- name: Install wheel building dependencies
71-
if: github.event_name == 'release'
72-
run: |
73-
python -m pip install --upgrade pip
74-
pip install build wheel
75-
- name: Copy binary for wheel building
76-
if: github.event_name == 'release'
77-
run: |
78-
cp ${{ matrix.binary_name }} auto-editor
79-
- name: Build wheel
80-
if: github.event_name == 'release'
81-
run: |
82-
python -m build --wheel
83-
# Rename wheel to include platform tag
84-
wheel_file=$(ls dist/*.whl)
85-
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
86-
platform_tag="linux_x86_64"
87-
elif [[ "${{ matrix.os }}" == "macos-13" ]]; then
88-
platform_tag="macosx_13_0_x86_64"
89-
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
90-
platform_tag="macosx_14_0_arm64"
91-
fi
92-
new_wheel_name=$(echo $wheel_file | sed "s/py3-none-any.whl/py3-none-${platform_tag}.whl/")
93-
mv "$wheel_file" "$new_wheel_name"
94-
echo "WHEEL_FILE=$new_wheel_name" >> $GITHUB_ENV
95-
- name: Upload wheel as artifact
96-
if: github.event_name == 'release'
97-
uses: actions/upload-artifact@v4
98-
with:
99-
name: wheel-${{ matrix.arch }}-${{ matrix.os }}
100-
path: ${{ env.WHEEL_FILE }}
10164

10265
windows:
10366
runs-on: ubuntu-latest
@@ -128,53 +91,5 @@ jobs:
12891
files: auto-editor-windows-amd64.exe
12992
env:
13093
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131-
- name: Set up Python for wheel building
132-
if: github.event_name == 'release'
133-
uses: actions/setup-python@v5
134-
with:
135-
python-version: '3.x'
136-
- name: Install wheel building dependencies
137-
if: github.event_name == 'release'
138-
run: |
139-
python -m pip install --upgrade pip
140-
pip install build wheel
141-
- name: Copy binary for wheel building
142-
if: github.event_name == 'release'
143-
run: |
144-
cp auto-editor-windows-amd64.exe auto-editor.exe
145-
- name: Build wheel
146-
if: github.event_name == 'release'
147-
run: |
148-
python -m build --wheel
149-
# Rename wheel to include platform tag
150-
wheel_file=$(ls dist/*.whl)
151-
new_wheel_name=$(echo $wheel_file | sed "s/py3-none-any.whl/py3-none-win_amd64.whl/")
152-
mv "$wheel_file" "$new_wheel_name"
153-
echo "WHEEL_FILE=$new_wheel_name" >> $GITHUB_ENV
154-
- name: Upload wheel as artifact
155-
if: github.event_name == 'release'
156-
uses: actions/upload-artifact@v4
157-
with:
158-
name: wheel-windows-amd64
159-
path: ${{ env.WHEEL_FILE }}
16094

161-
publish-to-pypi:
162-
if: github.event_name == 'release'
163-
needs: [main, windows]
164-
runs-on: ubuntu-latest
165-
permissions:
166-
id-token: write
167-
steps:
168-
- name: Download all wheel artifacts
169-
uses: actions/download-artifact@v4
170-
with:
171-
pattern: wheel-*
172-
merge-multiple: true
173-
path: dist/
174-
- name: List downloaded wheels
175-
run: ls -la dist/
176-
- name: Publish wheels to PyPI
177-
uses: pypa/gh-action-pypi-publish@release/v1
178-
with:
179-
packages-dir: dist/
18095

.github/workflows/python-publish.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Upload Auto-Editor Package
22
on:
33
release:
44
types: [published]
5+
workflow_dispatch:
56
jobs:
67
deploy:
78
runs-on: ubuntu-latest
@@ -16,8 +17,9 @@ jobs:
1617
- name: Install dependencies
1718
run: |
1819
python -m pip install --upgrade pip
19-
pip install setuptools build wheel twine
20-
python -m build
20+
pip install build wheel
21+
- name: Build package
22+
run: python -m build
2123

2224
- name: Publish to PyPI
2325
uses: pypa/gh-action-pypi-publish@release/v1

auto_editor/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"""Auto-Editor: Effort free video editing!"""
2-
3-
__version__ = "29.0.1"
1+
__version__ = "29.0.2"

auto_editor/__main__.py

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,81 @@
11
"""Main entry point for auto-editor when run as a module."""
22

3-
import os
4-
import sys
3+
import platform
54
import subprocess
5+
import sys
6+
import urllib.request
67
from pathlib import Path
78

9+
from . import __version__
10+
11+
if __version__.startswith("29.0."):
12+
version = "29.0.0"
13+
else:
14+
version = __version__
15+
16+
17+
def get_binary_info():
18+
"""Get the appropriate binary name and download URL for this platform."""
19+
system = platform.system().lower()
20+
machine = platform.machine().lower()
21+
22+
if system == "windows":
23+
binary_name = "auto-editor-windows-amd64.exe"
24+
local_name = "auto-editor.exe"
25+
elif system == "darwin":
26+
if machine == "arm64":
27+
binary_name = "auto-editor-macos-arm64"
28+
else:
29+
binary_name = "auto-editor-macos-x86_64"
30+
local_name = "auto-editor"
31+
elif system == "linux":
32+
binary_name = "auto-editor-linux-x86_64"
33+
local_name = "auto-editor"
34+
else:
35+
raise RuntimeError(f"Unsupported platform: {system} {machine}")
36+
37+
# Use the package version to construct the download URL
38+
url = f"https://github.com/WyattBlue/auto-editor/releases/download/{version}/{binary_name}"
39+
return binary_name, local_name, url
40+
41+
42+
def download_binary():
43+
"""Download the appropriate binary from GitHub releases."""
44+
package_dir = Path(__file__).parent
45+
bin_dir = package_dir / "bin"
46+
bin_dir.mkdir(parents=True, exist_ok=True)
47+
48+
binary_name, local_name, url = get_binary_info()
49+
binary_path = bin_dir / local_name
50+
51+
if binary_path.exists():
52+
return binary_path
53+
54+
print("Downloading auto-editor binary for your platform...")
55+
print(f"URL: {url}")
56+
57+
try:
58+
urllib.request.urlretrieve(url, binary_path)
59+
binary_path.chmod(0o755) # Make executable on Unix systems
60+
print("Download completed successfully!")
61+
return binary_path
62+
except Exception as e:
63+
print(f"Error downloading binary: {e}", file=sys.stderr)
64+
print(f"Please download manually from: {url}", file=sys.stderr)
65+
sys.exit(1)
66+
867

968
def main():
10-
"""Run the auto-editor binary."""
11-
# Find the binary in the package directory
1269
package_dir = Path(__file__).parent
13-
70+
1471
# Determine the binary name based on platform
15-
if sys.platform.startswith('win'):
16-
binary_name = 'auto-editor.exe'
17-
else:
18-
binary_name = 'auto-editor'
19-
20-
binary_path = package_dir / 'bin' / binary_name
21-
72+
_, local_name, _ = get_binary_info()
73+
binary_path = package_dir / "bin" / local_name
74+
75+
# Download binary if it doesn't exist
2276
if not binary_path.exists():
23-
print(f"Error: auto-editor binary not found at {binary_path}", file=sys.stderr)
24-
sys.exit(1)
25-
77+
binary_path = download_binary()
78+
2679
# Execute the binary with all arguments
2780
try:
2881
result = subprocess.run([str(binary_path)] + sys.argv[1:])
@@ -34,5 +87,5 @@ def main():
3487
sys.exit(1)
3588

3689

37-
if __name__ == '__main__':
38-
main()
90+
if __name__ == "__main__":
91+
main()

auto_editor/cli.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
"""Command line interface for auto-editor."""
2-
31
from auto_editor.__main__ import main
42

5-
6-
def cli():
7-
"""Entry point for console script."""
3+
if __name__ == "__main__":
84
main()
9-
10-
11-
if __name__ == '__main__':
12-
cli()

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "auto-editor"
7-
version = "29.0.1"
7+
version = "29.0.2"
88
description = "Auto-Editor: Effort free video editing!"
99
readme = "README.md"
1010
license = "Unlicense"
@@ -23,9 +23,6 @@ auto-editor = "auto_editor.cli:cli"
2323
[tool.setuptools.packages.find]
2424
include = ["auto_editor*"]
2525

26-
[tool.setuptools.package-data]
27-
auto_editor = ["bin/*"]
28-
2926
[project.urls]
3027
"Bug Tracker" = "https://github.com/WyattBlue/auto-editor/issues"
3128
"Source Code" = "https://github.com/WyattBlue/auto-editor"

setup.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)