-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Slendi <slendi@socopon.com>
- Loading branch information
Showing
5 changed files
with
167 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Build + Release Wheels Linux | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
deploy_to_testpypi: | ||
description: "Whether the build should be deployed to test.pypi.org instead of regular PyPI" | ||
required: true | ||
default: 'false' | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
|
||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install build tools | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build twine auditwheel | ||
- name: Build in manylinux container | ||
run: | | ||
docker pull quay.io/pypa/manylinux1_x86_64 | ||
docker run --rm -v `pwd`:/io quay.io/pypa/manylinux2014_x86_64 /io/ci/build_manylinux.sh build | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd) | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
- name: Determine PyPI target | ||
id: pypi_target | ||
run: | | ||
if [ "${{ github.event.inputs.deploy_to_testpypi }}" == "true" ]; then | ||
echo "::set-output name=repository_url::https://test.pypi.org/legacy/" | ||
echo "::set-output name=api_token::${{ secrets.TEST_PYPI_API_TOKEN }}" | ||
else | ||
echo "::set-output name=repository_url::https://upload.pypi.org/legacy/" | ||
echo "::set-output name=api_token::${{ secrets.PYPI_API_TOKEN }}" | ||
fi | ||
- name: Upload to PyPI repositories | ||
run: twine upload dist/* --verbose --skip-existing -u __token__ -p ${{ steps.pypi_target.outputs.api_token }} | ||
env: | ||
TWINE_REPOSITORY_URL: ${{ steps.pypi_target.outputs.repository_url }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# From: https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh | ||
# which is in the public domain. | ||
# | ||
# This is run inside a CentOS 5 virtual machine to build manylinux wheels: | ||
# | ||
# $ docker run -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/ci/build_manylinux.sh | ||
# | ||
|
||
set -e -x | ||
|
||
action=$1 | ||
|
||
yum --assumeyes install epel-release | ||
yum --assumeyes update | ||
yum --assumeyes install libxdo-devel libX11-devel libXtst-devel libXext-devel | ||
|
||
if [[ $action == "build" ]]; then | ||
# Compile wheels | ||
cd /io | ||
for PYBIN in /opt/python/*/bin; do | ||
if echo "$PYBIN" | grep 3; then | ||
"$PYBIN/python" setup.py bdist_wheel -d ~/wheelhouse/ | ||
fi | ||
done | ||
cd ~ | ||
|
||
# Bundle external shared libraries into the wheels | ||
for whl in wheelhouse/*.whl; do | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/io | ||
auditwheel repair "$whl" -w /io/dist/ | ||
done | ||
|
||
elif [[ $action == "test" ]]; then | ||
# Install packages and test | ||
TOXBIN=/opt/python/cp27-cp27m/bin | ||
"$TOXBIN/pip" install -r /io/requirements/ci.pip | ||
|
||
for PYBIN in /opt/python/*/bin/; do | ||
PYNAME=$("$PYBIN/python" -c "import sys; print('python{0[0]}.{0[1]}'.format(sys.version_info))") | ||
TOXENV=$("$PYBIN/python" -c "import sys; print('py{0[0]}{0[1]}'.format(sys.version_info))") | ||
ln -s "$PYBIN/$PYNAME" /usr/local/bin/$PYNAME | ||
"$TOXBIN/tox" -e $TOXENV | ||
rm -f /usr/local/bin/$PYNAME | ||
#"${PYBIN}/pip" install python-manylinux-demo --no-index -f /io/dist | ||
#(cd "$HOME"; "${PYBIN}/nosetests" pymanylinuxdemo) | ||
done | ||
|
||
else | ||
echo "Need an action to perform!" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,45 @@ | ||
from setuptools import setup, Extension | ||
from setuptools.command.build_ext import build_ext | ||
import subprocess | ||
import sys | ||
|
||
with open("README.md", "r") as fh: | ||
long_description = fh.read() | ||
|
||
libraries = ['vinput'] | ||
if sys.platform == 'win32': | ||
libraries.append('User32') | ||
|
||
class CustomBuildExt(build_ext): | ||
def run(self): | ||
lib = "" | ||
if sys.platform == 'win32': | ||
lib = "vinput.lib" | ||
elif sys.platform == 'darwin': | ||
lib = "libvinput.dylib" | ||
else: | ||
lib = "libvinput.so" | ||
protoc_command = ["make", lib] | ||
if subprocess.call(protoc_command) != 0: | ||
sys.exit(-1) | ||
super().run() | ||
|
||
module = Extension('libvinput', | ||
sources=['src/pybind.c'], | ||
include_dirs=['src'], | ||
libraries=['vinput'], | ||
library_dirs=['.']) | ||
sources=['src/pybind.c'], | ||
include_dirs=['src'], | ||
libraries=libraries, | ||
library_dirs=['.']) | ||
|
||
setup(name='libvinput', | ||
version='1.0', | ||
author='Slendi', | ||
description='Python interface for libvinput', | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
ext_modules=[module]) | ||
setup( | ||
name='libvinput', | ||
version='1.0', | ||
author='Slendi', | ||
description='Python interface for libvinput', | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
ext_modules=[module], | ||
cmdclass={ | ||
'build_ext': CustomBuildExt, # Changed from build_py to build_ext | ||
}, | ||
setup_requires=['wheel'] # Ensure wheel is available for building | ||
) |