Skip to content

Commit

Permalink
use meson
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Dec 7, 2024
1 parent f304dd7 commit 722e786
Show file tree
Hide file tree
Showing 19 changed files with 125 additions and 805 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Build sdists and pure-python wheel
env:
PIP_CONSTRAINT: requirements/cython.txt
run: python -Im build --config-setting=pure-python=true
run: python -Im build --config-setting=setup-args=-Dpure-python=enabled
- name: Determine actual created filenames
id: dist-filenames-detection
run: >-
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/reusable-build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ jobs:
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
CIBW_CONFIG_SETTINGS: >- # Cython line tracing for coverage collection
pure-python=false
with-cython-tracing=${{ inputs.cython-tracing }}
# Cython line tracing for coverage collection
# CIBW_CONFIG_SETTINGS: >-
# pure-python=false
# with-cython-tracing=${{ inputs.cython-tracing }}

- name: Upload built artifacts for testing and publishing
uses: actions/upload-artifact@v4
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/reusable-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ jobs:
- name: Self-install
run: |
pip install .
- name: Run linters
run: |
make lint
- uses: pre-commit/action@v3.0.1
# - name: Run linters
# run: |
# make lint
- name: Send coverage data to Codecov
uses: codecov/codecov-action@v5
with:
Expand All @@ -81,7 +82,7 @@ jobs:
- name: Prepare twine checker
run: |
pip install -U build twine
python -m build --config-setting=pure-python=true
python -m build --config-setting=setup-args=-Dpure-python=enabled
- name: Run twine checker
run: |
twine check --strict dist/*
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var/
*.egg-info/
.installed.cfg
*.egg
taskfile.yaml
.vscode/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
1 change: 0 additions & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ python_version = 3.8
color_output = true
error_summary = true
files =
packaging/,
tests/,
yarl/

Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build:
post_create_environment:
- >-
pip install .
--config-settings=pure-python=true
--config-settings=setup-args=-Dpure-python=enabled
python:
install:
Expand Down
74 changes: 74 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
project(
'yarl',
'c',
default_options: [
'buildtype=release',
'debug=false',
],
meson_version: '>= 1.3.0',
)

py_inter = import('python').find_installation()

PY_IMPL = run_command(
py_inter,
'-c', 'import sys; print(sys.implementation.name)',
check: true,
).stdout().strip()

pure_py = (get_option('pure-python').enabled()) or (PY_IMPL != 'cpython')

py = import('python').find_installation(pure: pure_py)

py.install_sources(
[
'yarl/__init__.py',
'yarl/py.typed',
'yarl/_parse.py',
'yarl/_path.py',
'yarl/_query.py',
'yarl/_quoters.py',
'yarl/_quoting.py',
'yarl/_quoting_py.py',
'yarl/_url.py',
],
subdir: 'yarl',
)

if not pure_py
cython = find_program('cython')

cython_gen = generator(
cython,
output: ['@BASENAME@.c'],
arguments: ['@INPUT@', '--output-file', '@OUTPUT0@'],
)

quoting_c = cython_gen.process(
'yarl/_quoting_c.pyx',
preserve_path_from: meson.current_source_dir(),
)

out = py.extension_module(
'_quoting_c',
quoting_c,
subdir: 'yarl',
install: true,
dependencies: py.dependency(),
)

# support for in-tree build
# # will target will copy binary extension back to source directory
custom_target(
'copy extension back to file tree',
input: out,
output: 'copy',
depends: out,
command: [
'cp',
out.full_path(),
join_paths(meson.project_source_root(), 'yarl/'),
],
build_by_default: false,
)
endif
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('pure-python', type: 'feature', value: 'disabled')
11 changes: 0 additions & 11 deletions packaging/README.md

This file was deleted.

1 change: 0 additions & 1 deletion packaging/pep517_backend/__init__.py

This file was deleted.

6 changes: 0 additions & 6 deletions packaging/pep517_backend/__main__.py

This file was deleted.

Loading

0 comments on commit 722e786

Please sign in to comment.