Skip to content

Commit

Permalink
Add dependencies for Ubuntu CI
Browse files Browse the repository at this point in the history
Signed-off-by: Slendi <slendi@socopon.com>
  • Loading branch information
xslendix committed May 3, 2024
1 parent 8e67f8a commit ce79d73
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 14 deletions.
31 changes: 18 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@ jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
build_command: make libvinput.so
artifact_name: libvinput.so
- os: windows-latest
build_command: make libvinput.dll
artifact_name: libvinput.dll
build_command: make vinput.lib
artifact_name: vinput.lib
extra_setup: echo "No extra setup needed"
- os: macos-latest
build_command: make libvinput.dylib
artifact_name: libvinput.dylib
extra_setup: echo "No extra setup needed"
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Setup Dependencies
run: ${{ matrix.extra_setup }}
- name: Build native binary
run: |
${{ matrix.build_command }}
Expand All @@ -38,16 +40,19 @@ jobs:
python -m build --wheel
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions
name: python-package-distributions-${{ matrix.os }}
path: dist
- name: Install Twine
run: pip install twine

- name: Upload to PyPI
if: github.event.inputs.deploy_to_testpypi == 'false'
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
password: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/* --verbose --skip-existing -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}
env:
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/

- name: Upload to TestPyPI
if: github.event.inputs.deploy_to_testpypi == 'true'
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
repository_url: 'https://test.pypi.org/legacy/'
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: twine upload dist/* --verbose --skip-existing -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }}
env:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
57 changes: 57 additions & 0 deletions .github/workflows/release_linux_sdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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
services:
manylinux:
image: quay.io/pypa/manylinux2010_x86_64:latest
options: --user root

steps:
- uses: actions/checkout@v4

- name: Build and Repair Wheels
run: |
# Install tools needed
python -m pip install build
python -m pip install auditwheel
# Build sdist and wheel
python -m build --sdist --wheel --outdir /github/workspace/dist/
# Repair the wheel
sh -c 'auditwheel repair /github/workspace/dist/*.whl -w /github/workspace/dist/'
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Install Twine
run: pip install twine

- name: Upload to PyPI
if: github.event.inputs.deploy_to_testpypi == 'false'
run: twine upload dist/* --verbose --skip-existing -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}
env:
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/

- name: Upload to TestPyPI
if: github.event.inputs.deploy_to_testpypi == 'true'
run: twine upload dist/* --verbose --skip-existing -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }}
env:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ wordlogger_mac: wordlogger.c
libvinput.dll: src/libvinput.c src/windows_emu.c src/windows.c
x86_64-w64-mingw32-gcc $(CFLAGS) -fPIC -o $@ -shared $^

vinput.lib: src/libvinput.c src/windows_emu.c src/windows.c
x86_64-w64-mingw32-gcc $(CFLAGS) -c src/libvinput.c -o libvinput.o
x86_64-w64-mingw32-gcc $(CFLAGS) -c src/windows_emu.c -o windows_emu.o
x86_64-w64-mingw32-gcc $(CFLAGS) -c src/windows.c -o windows.o
ar rcs vinput.lib libvinput.o windows_emu.o windows.o

wordlogger.exe: libvinput.dll wordlogger.c
x86_64-w64-mingw32-gcc $(CFLAGS) wordlogger.c -o $@ -L. -l:$<

Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from setuptools import setup, Extension
import sys

with open("README.md", "r") as fh:
long_description = fh.read()

libraries = ['vinput']
if sys.platform == 'win32':
libraries.append('User32')

module = Extension('libvinput',
sources=['src/pybind.c'],
include_dirs=['src'],
libraries=['vinput'],
libraries=libraries,
library_dirs=['.'])

setup(name='libvinput',
Expand Down

0 comments on commit ce79d73

Please sign in to comment.