Skip to content

Commit 3872fed

Browse files
committed
Build wheels for PyPI
1 parent e0ad4de commit 3872fed

File tree

6 files changed

+225
-13
lines changed

6 files changed

+225
-13
lines changed

.github/workflows/build.yml

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
workflow_dispatch:
66
permissions:
77
contents: write
8+
id-token: write
89
jobs:
910
main:
1011
runs-on: ${{ matrix.os }}
@@ -61,6 +62,42 @@ jobs:
6162
files: ${{ matrix.binary_name }}
6263
env:
6364
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 }}
64101

65102
windows:
66103
runs-on: ubuntu-latest
@@ -84,17 +121,60 @@ jobs:
84121
- name: Rename binary
85122
run: |
86123
mv auto-editor.exe auto-editor-windows-amd64.exe
87-
88-
# - name: Upload
89-
# uses: actions/upload-artifact@v4
90-
# with:
91-
# name: dist-${{ matrix.arch }}
92-
# path: auto-editor-windows-amd64.exe
93124
- name: Upload to Release
94125
if: github.event_name == 'release'
95126
uses: softprops/action-gh-release@v1
96127
with:
97128
files: auto-editor-windows-amd64.exe
98129
env:
99130
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 }}
160+
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/
100180

auto_editor/__init__.py

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

auto_editor/__main__.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Main entry point for auto-editor when run as a module."""
2+
3+
import os
4+
import sys
5+
import subprocess
6+
from pathlib import Path
7+
8+
9+
def main():
10+
"""Run the auto-editor binary."""
11+
# Find the binary in the package directory
12+
package_dir = Path(__file__).parent
13+
14+
# 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+
22+
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+
26+
# Execute the binary with all arguments
27+
try:
28+
result = subprocess.run([str(binary_path)] + sys.argv[1:])
29+
sys.exit(result.returncode)
30+
except KeyboardInterrupt:
31+
sys.exit(130)
32+
except Exception as e:
33+
print(f"Error running auto-editor: {e}", file=sys.stderr)
34+
sys.exit(1)
35+
36+
37+
if __name__ == '__main__':
38+
main()

auto_editor/cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Command line interface for auto-editor."""
2+
3+
from auto_editor.__main__ import main
4+
5+
6+
def cli():
7+
"""Entry point for console script."""
8+
main()
9+
10+
11+
if __name__ == '__main__':
12+
cli()

pyproject.toml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
[build-system]
2-
requires = ["setuptools>=77"]
2+
requires = ["setuptools>=77", "wheel"]
3+
build-backend = "setuptools.build_meta"
34

45
[project]
56
name = "auto-editor"
6-
version = "29.0.0"
7+
version = "29.0.1"
78
description = "Auto-Editor: Effort free video editing!"
89
readme = "README.md"
910
license = "Unlicense"
1011
authors = [{ name = "WyattBlue", email = "[email protected]" }]
11-
requires-python = ">=3.10,<3.14"
12-
dependencies = [
13-
"numpy>=2,<3.0",
14-
"av>=15.0,<16",
15-
]
12+
requires-python = ">=3.10"
13+
dependencies = []
1614
keywords = [
1715
"video", "audio", "media", "editor", "editing",
1816
"processing", "nonlinear", "automatic", "silence-detect",
1917
"silence-removal", "silence-speedup", "motion-detection",
2018
]
2119

20+
[project.scripts]
21+
auto-editor = "auto_editor.cli:cli"
22+
23+
[tool.setuptools.packages.find]
24+
include = ["auto_editor*"]
25+
26+
[tool.setuptools.package-data]
27+
auto_editor = ["bin/*"]
28+
2229
[project.urls]
2330
"Bug Tracker" = "https://github.com/WyattBlue/auto-editor/issues"
2431
"Source Code" = "https://github.com/WyattBlue/auto-editor"

setup.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""Setup script for auto-editor binary distribution."""
2+
3+
import os
4+
import sys
5+
import shutil
6+
from pathlib import Path
7+
from setuptools import setup, find_packages
8+
from setuptools.command.build_py import build_py
9+
10+
11+
class BuildPyCommand(build_py):
12+
"""Custom build command to include binary."""
13+
14+
def run(self):
15+
# Run the normal build
16+
super().run()
17+
18+
# Copy the binary to the package
19+
self.copy_binary()
20+
21+
def copy_binary(self):
22+
"""Copy the appropriate binary to the package."""
23+
# Determine binary name and source path
24+
if sys.platform.startswith('win'):
25+
binary_name = 'auto-editor.exe'
26+
else:
27+
binary_name = 'auto-editor'
28+
29+
# Look for binary in current directory (where build places it)
30+
source_binary = Path('.') / binary_name
31+
32+
if not source_binary.exists():
33+
# Try alternative names for cross-compilation
34+
platform_binaries = [
35+
f'auto-editor-linux-x86_64',
36+
f'auto-editor-macos-x86_64',
37+
f'auto-editor-macos-arm64',
38+
f'auto-editor-windows-amd64.exe'
39+
]
40+
41+
for alt_binary in platform_binaries:
42+
alt_path = Path('.') / alt_binary
43+
if alt_path.exists():
44+
source_binary = alt_path
45+
break
46+
47+
if not source_binary.exists():
48+
print(f"Warning: Binary {binary_name} not found, wheel will not include binary")
49+
return
50+
51+
# Create bin directory in the built package
52+
package_dir = Path(self.build_lib) / 'auto_editor'
53+
bin_dir = package_dir / 'bin'
54+
bin_dir.mkdir(parents=True, exist_ok=True)
55+
56+
# Copy binary
57+
dest_binary = bin_dir / binary_name
58+
shutil.copy2(source_binary, dest_binary)
59+
60+
# Make it executable on Unix systems
61+
if not sys.platform.startswith('win'):
62+
dest_binary.chmod(0o755)
63+
64+
print(f"Copied binary {source_binary} to {dest_binary}")
65+
66+
67+
if __name__ == '__main__':
68+
setup(
69+
cmdclass={
70+
'build_py': BuildPyCommand,
71+
}
72+
)

0 commit comments

Comments
 (0)