Bundle native modules inside Python package
This commit is contained in:
parent
de9fab6f41
commit
6f83d5bb23
9 changed files with 104 additions and 16 deletions
12
python/.gitignore
vendored
12
python/.gitignore
vendored
|
|
@ -1,2 +1,12 @@
|
|||
/Cargo.lock
|
||||
/target
|
||||
/target/
|
||||
/venv/
|
||||
|
||||
# Ignore locally built native modules.
|
||||
/hyperbuild/**/*.so
|
||||
/hyperbuild/**/*.pyd
|
||||
|
||||
# Used by Python setuptools.
|
||||
/build/
|
||||
/dist/
|
||||
/*.egg-info/
|
||||
|
|
|
|||
1
python/MANIFEST.in
Normal file
1
python/MANIFEST.in
Normal file
|
|
@ -0,0 +1 @@
|
|||
recursive-include hyperbuild *.so *.pyd
|
||||
23
python/hyperbuild/__init__.py
Normal file
23
python/hyperbuild/__init__.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import platform
|
||||
import importlib
|
||||
|
||||
def _load_native_module():
|
||||
os_raw = platform.system()
|
||||
if os_raw == "Linux":
|
||||
os = "linux"
|
||||
elif os_raw == "Darwin":
|
||||
os = "macos"
|
||||
elif os_raw == "Windows":
|
||||
os = "windows"
|
||||
else:
|
||||
os = "unknown"
|
||||
|
||||
os_arch_raw = platform.machine()
|
||||
if os_arch_raw == "AMD64" or os_arch_raw == "x86_64":
|
||||
os_arch = "x86_64"
|
||||
else:
|
||||
os_arch = "unknown"
|
||||
|
||||
return importlib.import_module(os + "-" + os_arch + ".hyperbuild")
|
||||
|
||||
minify = _load_native_module().minify
|
||||
23
python/setup.py
Normal file
23
python/setup.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import setuptools
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setuptools.setup(
|
||||
name="hyperbuild",
|
||||
version="0.0.29",
|
||||
author="Wilson Lin",
|
||||
author_email="code@wilsonl.in",
|
||||
description="Fast one-pass in-place HTML minifier written in Rust with context-aware whitespace handling",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/wilsonzlin/hyperbuild",
|
||||
packages=["hyperbuild"],
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
python_requires='>=3.5',
|
||||
)
|
||||
Reference in a new issue