Skip to content

Commit

Permalink
feat: add python package
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Oct 16, 2024
1 parent d1846bd commit 322ff3f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ tmp/
dist/

# Packages
packaging/pypi/lefthook/__pycache__/
packaging/pypi/lefthook/bin/
packaging/pypi/lefthook.egg-info/
packaging/pypi/build/
packaging/rubygems/pkg/
packaging/rubygems/libexec/
packaging/npm-bundled/bin/
Expand Down
16 changes: 16 additions & 0 deletions packaging/pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ def put_binaries
cp(source, dest, verbose: true)
end

{
"#{DIST}/no_self_update_linux_amd64_v1/lefthook" => "pypi/lefthook/bin/lefthook-linux-x86_64/lefthook",
"#{DIST}/no_self_update_linux_arm64/lefthook" => "pypi/lefthook/bin/lefthook-linux-arm64/lefthook",
"#{DIST}/no_self_update_freebsd_amd64_v1/lefthook" => "pypi/lefthook/bin/lefthook-freebsd-x86_64/lefthook",
"#{DIST}/no_self_update_freebsd_arm64/lefthook" => "pypi/lefthook/bin/lefthook-freebsd-arm64/lefthook",
"#{DIST}/no_self_update_openbsd_amd64_v1/lefthook" => "pypi/lefthook/bin/lefthook-openbsd-x86_64/lefthook",
"#{DIST}/no_self_update_openbsd_arm64/lefthook" => "pypi/lefthook/bin/lefthook-openbsd-arm64/lefthook",
"#{DIST}/no_self_update_windows_amd64_v1/lefthook.exe" => "pypi/lefthook/bin/lefthook-windows-x86_64/lefthook.exe",
"#{DIST}/no_self_update_windows_arm64/lefthook.exe" => "pypi/lefthook/bin/lefthook-windows-arm64/lefthook.exe",
"#{DIST}/no_self_update_darwin_amd64_v1/lefthook" => "pypi/lefthook/bin/lefthook-darwin-x86_64/lefthook",
"#{DIST}/no_self_update_darwin_arm64/lefthook" => "pypi/lefthook/bin/lefthook-darwin-arm64/lefthook",
}.each do |(source, dest)|
mkdir_p(File.dirname(dest))
cp(source, dest, verbose: true)
end

puts "done"
end

Expand Down
Empty file.
6 changes: 6 additions & 0 deletions packaging/pypi/lefthook/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys

from .main import main

if __name__ == "__main__":
sys.exit(main())
13 changes: 13 additions & 0 deletions packaging/pypi/lefthook/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import sys
import platform
import subprocess

def main():
os_name = platform.system().lower()
ext = os_name == "windows" and ".exe" or ""
arch = platform.machine()
subfolder = f"lefthook-{os_name}-{arch}"
executable = os.path.join(os.path.dirname(__file__), "bin", subfolder, "lefthook"+ext)
result = subprocess.run([executable] + sys.argv[1:])
return result.returncode
36 changes: 36 additions & 0 deletions packaging/pypi/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from setuptools import setup, find_packages

setup(
name='lefthook',
version='1.7.18',
author='Evil Martians',
author_email='[email protected]',
url='https://github.com/evilmartians/lefthook',
description='A single dependency-free binary to manage all your git hooks that works with any language in any environment, and in all common team workflows',
packages=find_packages(),
entry_points={
'console_scripts': [
'lefthook=lefthook.main:main'
],
},
package_data={
'lefthook':[
'bin/lefthook-linux-x86_64/lefthook',
'bin/lefthook-linux-arm64/lefthook',
'bin/lefthook-freebsd-x86_64/lefthook',
'bin/lefthook-freebsd-arm64/lefthook',
'bin/lefthook-openbsd-x86_64/lefthook',
'bin/lefthook-openbsd-arm64/lefthook',
'bin/lefthook-windows-x86_64/lefthook.exe',
'bin/lefthook-windows-arm64/lefthook.exe',
'bin/lefthook-darwin-x86_64/lefthook',
'bin/lefthook-darwin-arm64/lefthook',
]
},
classifiers=[
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Topic :: Software Development :: Version Control :: Git'
],
python_requires='>=3.6',
)

0 comments on commit 322ff3f

Please sign in to comment.