Bundle native modules inside Python package
This commit is contained in:
parent
de9fab6f41
commit
6f83d5bb23
|
@ -1,4 +1,4 @@
|
|||
name: Build, package, and upload Java library
|
||||
name: Build and publish Java artifact
|
||||
|
||||
on:
|
||||
create:
|
||||
|
@ -71,7 +71,7 @@ jobs:
|
|||
mv $f/* "$f.nativelib"
|
||||
rmdir "$f"
|
||||
done
|
||||
- name: Build, package, and publish JAR
|
||||
- name: Build, pack, and publish JAR
|
||||
working-directory: ./java
|
||||
env:
|
||||
SONATYPE_GPG_PRIVATE_KEY: ${{ secrets.SONATYPE_GPG_PRIVATE_KEY }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: Build and upload Node.js native module
|
||||
name: Build and publish Node.js package
|
||||
|
||||
on:
|
||||
create:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: Build and upload Python native module
|
||||
name: Build and publish Python package
|
||||
|
||||
on:
|
||||
create:
|
||||
|
@ -6,7 +6,7 @@ on:
|
|||
- 'v*'
|
||||
|
||||
jobs:
|
||||
nodejs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
|
@ -30,10 +30,6 @@ jobs:
|
|||
id: version
|
||||
shell: bash
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
|
||||
- name: Get file name
|
||||
id: file
|
||||
shell: bash
|
||||
run: echo ::set-output name=FILE::${{ steps.version.outputs.VERSION }}-${{ matrix.ARCH }}-python.${{ matrix.PYEXT }}
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
|
@ -47,12 +43,43 @@ jobs:
|
|||
default: true
|
||||
- name: Build native module
|
||||
working-directory: ./python
|
||||
run: |
|
||||
cargo build --release
|
||||
run: cargo build --release
|
||||
- uses: chrislennon/action-aws-cli@v1.1
|
||||
- name: Upload to S3
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_REGION: us-west-2
|
||||
run: aws s3 cp ./python/target/release/${{ matrix.LIBFILE }} s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/${{ steps.file.outputs.FILE }}
|
||||
run: aws s3 cp ./python/target/release/${{ matrix.LIBFILE }} s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/python/${{ steps.version.outputs.VERSION }}/${{ matrix.ARCH }}/hyperbuild.${{ matrix.PYEXT }}
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Get version
|
||||
id: version
|
||||
shell: bash
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.5'
|
||||
architecture: 'x64'
|
||||
- uses: chrislennon/action-aws-cli@v1.1
|
||||
- name: Pack and publish package
|
||||
working-directory: ./python
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_REGION: us-west-2
|
||||
run: |
|
||||
cat << 'EOF' > "$HOME/.pypirc"
|
||||
[pypi]
|
||||
username = __token__
|
||||
password = ${{ secrets.PYPI_API_TOKEN }}
|
||||
EOF
|
||||
cp ../README.md .
|
||||
aws s3 mv s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/python/${{ steps.version.outputs.VERSION }}/ ./hyperbuild/. --recursive
|
||||
pip3 install --upgrade setuptools wheel twine
|
||||
python3 setup.py sdist bdist_wheel
|
||||
python3 -m twine upload dist/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: Build, package, and upload Ruby gem
|
||||
name: Build and publish Ruby gem
|
||||
|
||||
on:
|
||||
create:
|
||||
|
@ -70,7 +70,7 @@ jobs:
|
|||
with:
|
||||
ruby-version: '2.5'
|
||||
- uses: chrislennon/action-aws-cli@v1.1
|
||||
- name: Package and publish gem
|
||||
- name: Pack and publish gem
|
||||
working-directory: ./ruby
|
||||
run: |
|
||||
cp ../README.md .
|
||||
|
|
|
@ -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/
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
recursive-include hyperbuild *.so *.pyd
|
|
@ -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
|
|
@ -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',
|
||||
)
|
6
version
6
version
|
@ -52,12 +52,16 @@ for (const f of ["Cargo.toml", "nodejs/native/Cargo.toml", "java/Cargo.toml", "p
|
|||
replaceInFile(f, /^version = "\d+\.\d+\.\d+"\s*$/m, `version = "${NEW_VERSION}"`);
|
||||
}
|
||||
|
||||
for (const f of ["python/setup.py"]) {
|
||||
replaceInFile(f, /^(\s*version=)"\d+\.\d+\.\d+",\s*$/m, `$1"${NEW_VERSION}",`);
|
||||
}
|
||||
|
||||
for (const f of ["README.md", "nodejs/native/Cargo.toml", "java/Cargo.toml", "python/Cargo.toml", "ruby/Cargo.toml"]) {
|
||||
replaceInFile(f, /^hyperbuild = "\d+\.\d+\.\d+"\s*$/m, `hyperbuild = "${NEW_VERSION}"`);
|
||||
}
|
||||
|
||||
for (const f of ["nodejs/package.json"]) {
|
||||
replaceInFile(f, /^(\s*)"version": "\d+\.\d+\.\d+",\s*$/m, `$1"version": "${NEW_VERSION}",`);
|
||||
replaceInFile(f, /^(\s*"version": )"\d+\.\d+\.\d+",\s*$/m, `$1"${NEW_VERSION}",`);
|
||||
}
|
||||
|
||||
for (const f of ["ruby/hyperbuild.gemspec"]) {
|
||||
|
|
Loading…
Reference in New Issue