Skip to content

Commit

Permalink
build: use pdm to build C extension
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw committed Aug 11, 2024
1 parent 339e97b commit df8ddeb
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 53 deletions.
8 changes: 0 additions & 8 deletions .github/dependabot.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/dependabot.yml

This file was deleted.

33 changes: 15 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
- name: Checkout repository
uses: actions/[email protected]

- name: Setup Python
uses: actions/setup-[email protected]
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '*'
cache: pip
cache: true

- name: Install the development dependencies
run: pip install -r requirements.txt
- name: Install dependencies
run: pdm install

- name: Run typechecker
run: pyright
Expand All @@ -34,14 +34,14 @@ jobs:
- name: Checkout repository
uses: actions/[email protected]

- name: Setup Python
uses: actions/setup-[email protected]
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '*'
cache: pip
cache: true

- name: Install the development dependencies
run: pip install -r requirements.txt
- name: Install dependencies
run: pdm install

- name: Run linter
run: pylint --recursive=y .
Expand All @@ -53,17 +53,14 @@ jobs:
- name: Checkout repository
uses: actions/[email protected]

- name: Setup Python
uses: actions/setup-[email protected]
- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: '*'
cache: pip
cache: true

- name: Install the development dependencies
run: pip install -r requirements.txt

- name: Build the extension
run: python setup.py build_ext --inplace
- name: Install dependencies
run: pdm install

- name: Run tests
run: pytest
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.vscode/
build/
dist/
*.egg-info/

*.pyc
*.pyd
*.pyd
.pdm*
257 changes: 257 additions & 0 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions pdm_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from sys import platform
from typing import TypedDict

from setuptools import Extension


class Build(TypedDict):
"""
Summary
-------
a typed dictionary for the build
Attributes
----------
ext_modules (list[Extension]) : a list of extensions
"""

ext_modules: list[Extension]


def pdm_build_initialize(_):
"""
Summary
-------
initialise the build
"""
if platform in ('win32', 'cygwin', 'cli'):
return

raise RuntimeError('keywin only supports Windows!')


def pdm_build_update_setup_kwargs(_, kwargs: Build):
"""
Summary
-------
update the setup kwargs with the extension modules
"""
kwargs.update(
ext_modules=[Extension('keywin.send_input', ['keywin/send_input/send_input.c'], libraries=['user32'])]
)
Loading

0 comments on commit df8ddeb

Please sign in to comment.