Skip to content

Build wheels for PyPI #809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 86 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
main:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -61,6 +62,42 @@ jobs:
files: ${{ matrix.binary_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python for wheel building
if: github.event_name == 'release'
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install wheel building dependencies
if: github.event_name == 'release'
run: |
python -m pip install --upgrade pip
pip install build wheel
- name: Copy binary for wheel building
if: github.event_name == 'release'
run: |
cp ${{ matrix.binary_name }} auto-editor
- name: Build wheel
if: github.event_name == 'release'
run: |
python -m build --wheel
# Rename wheel to include platform tag
wheel_file=$(ls dist/*.whl)
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
platform_tag="linux_x86_64"
elif [[ "${{ matrix.os }}" == "macos-13" ]]; then
platform_tag="macosx_13_0_x86_64"
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
platform_tag="macosx_14_0_arm64"
fi
new_wheel_name=$(echo $wheel_file | sed "s/py3-none-any.whl/py3-none-${platform_tag}.whl/")
mv "$wheel_file" "$new_wheel_name"
echo "WHEEL_FILE=$new_wheel_name" >> $GITHUB_ENV
- name: Upload wheel as artifact
if: github.event_name == 'release'
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.arch }}-${{ matrix.os }}
path: ${{ env.WHEEL_FILE }}

windows:
runs-on: ubuntu-latest
Expand All @@ -84,17 +121,60 @@ jobs:
- name: Rename binary
run: |
mv auto-editor.exe auto-editor-windows-amd64.exe

# - name: Upload
# uses: actions/upload-artifact@v4
# with:
# name: dist-${{ matrix.arch }}
# path: auto-editor-windows-amd64.exe
- name: Upload to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: auto-editor-windows-amd64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python for wheel building
if: github.event_name == 'release'
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install wheel building dependencies
if: github.event_name == 'release'
run: |
python -m pip install --upgrade pip
pip install build wheel
- name: Copy binary for wheel building
if: github.event_name == 'release'
run: |
cp auto-editor-windows-amd64.exe auto-editor.exe
- name: Build wheel
if: github.event_name == 'release'
run: |
python -m build --wheel
# Rename wheel to include platform tag
wheel_file=$(ls dist/*.whl)
new_wheel_name=$(echo $wheel_file | sed "s/py3-none-any.whl/py3-none-win_amd64.whl/")
mv "$wheel_file" "$new_wheel_name"
echo "WHEEL_FILE=$new_wheel_name" >> $GITHUB_ENV
- name: Upload wheel as artifact
if: github.event_name == 'release'
uses: actions/upload-artifact@v4
with:
name: wheel-windows-amd64
path: ${{ env.WHEEL_FILE }}

publish-to-pypi:
if: github.event_name == 'release'
needs: [main, windows]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheel-*
merge-multiple: true
path: dist/
- name: List downloaded wheels
run: ls -la dist/
- name: Publish wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/

3 changes: 3 additions & 0 deletions auto_editor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Auto-Editor: Effort free video editing!"""

__version__ = "29.0.1"
38 changes: 38 additions & 0 deletions auto_editor/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Main entry point for auto-editor when run as a module."""

import os
import sys
import subprocess
from pathlib import Path


def main():
"""Run the auto-editor binary."""
# Find the binary in the package directory
package_dir = Path(__file__).parent

# Determine the binary name based on platform
if sys.platform.startswith('win'):
binary_name = 'auto-editor.exe'
else:
binary_name = 'auto-editor'

binary_path = package_dir / 'bin' / binary_name

if not binary_path.exists():
print(f"Error: auto-editor binary not found at {binary_path}", file=sys.stderr)
sys.exit(1)

# Execute the binary with all arguments
try:
result = subprocess.run([str(binary_path)] + sys.argv[1:])
sys.exit(result.returncode)
except KeyboardInterrupt:
sys.exit(130)
except Exception as e:
print(f"Error running auto-editor: {e}", file=sys.stderr)
sys.exit(1)


if __name__ == '__main__':
main()
12 changes: 12 additions & 0 deletions auto_editor/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Command line interface for auto-editor."""

from auto_editor.__main__ import main


def cli():
"""Entry point for console script."""
main()


if __name__ == '__main__':
cli()
21 changes: 14 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
[build-system]
requires = ["setuptools>=77"]
requires = ["setuptools>=77", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "auto-editor"
version = "29.0.0"
version = "29.0.1"
description = "Auto-Editor: Effort free video editing!"
readme = "README.md"
license = "Unlicense"
authors = [{ name = "WyattBlue", email = "[email protected]" }]
requires-python = ">=3.10,<3.14"
dependencies = [
"numpy>=2,<3.0",
"av>=15.0,<16",
]
requires-python = ">=3.10"
dependencies = []
keywords = [
"video", "audio", "media", "editor", "editing",
"processing", "nonlinear", "automatic", "silence-detect",
"silence-removal", "silence-speedup", "motion-detection",
]

[project.scripts]
auto-editor = "auto_editor.cli:cli"

[tool.setuptools.packages.find]
include = ["auto_editor*"]

[tool.setuptools.package-data]
auto_editor = ["bin/*"]

[project.urls]
"Bug Tracker" = "https://github.com/WyattBlue/auto-editor/issues"
"Source Code" = "https://github.com/WyattBlue/auto-editor"
Expand Down
72 changes: 72 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Setup script for auto-editor binary distribution."""

import os
import sys
import shutil
from pathlib import Path
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py


class BuildPyCommand(build_py):
"""Custom build command to include binary."""

def run(self):
# Run the normal build
super().run()

# Copy the binary to the package
self.copy_binary()

def copy_binary(self):
"""Copy the appropriate binary to the package."""
# Determine binary name and source path
if sys.platform.startswith('win'):
binary_name = 'auto-editor.exe'
else:
binary_name = 'auto-editor'

# Look for binary in current directory (where build places it)
source_binary = Path('.') / binary_name

if not source_binary.exists():
# Try alternative names for cross-compilation
platform_binaries = [
f'auto-editor-linux-x86_64',
f'auto-editor-macos-x86_64',
f'auto-editor-macos-arm64',
f'auto-editor-windows-amd64.exe'
]

for alt_binary in platform_binaries:
alt_path = Path('.') / alt_binary
if alt_path.exists():
source_binary = alt_path
break

if not source_binary.exists():
print(f"Warning: Binary {binary_name} not found, wheel will not include binary")
return

# Create bin directory in the built package
package_dir = Path(self.build_lib) / 'auto_editor'
bin_dir = package_dir / 'bin'
bin_dir.mkdir(parents=True, exist_ok=True)

# Copy binary
dest_binary = bin_dir / binary_name
shutil.copy2(source_binary, dest_binary)

# Make it executable on Unix systems
if not sys.platform.startswith('win'):
dest_binary.chmod(0o755)

print(f"Copied binary {source_binary} to {dest_binary}")


if __name__ == '__main__':
setup(
cmdclass={
'build_py': BuildPyCommand,
}
)
Loading