Skip to content

Commit cb5bca9

Browse files
authored
Merge pull request #220 from TeoZosa/migrate-packaging-from-pure-python-to-mypyc-compiled-platform-specific-packages
📦⚡️Compile Package Modules as C-Extensions via Mypyc
2 parents 8813d31 + 6648983 commit cb5bca9

File tree

7 files changed

+47
-17
lines changed

7 files changed

+47
-17
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ jobs:
7878
7979
# Package build ----------------------
8080
package-build:
81+
strategy:
82+
matrix:
83+
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
84+
python-version: ["3.7", "3.8", "3.9"]
85+
8186
name: Package build
82-
runs-on: ubuntu-latest
87+
runs-on: ${{ matrix.os }}
8388
needs: get-tag-xor-dev-version
8489
outputs:
8590
# yamllint disable-line rule:line-length
@@ -94,7 +99,7 @@ jobs:
9499
- name: Set up Python
95100
uses: actions/[email protected]
96101
with:
97-
python-version: "3.9"
102+
python-version: ${{ matrix.python-version }}
98103

99104
- name: Upgrade pip
100105
run: |
@@ -118,12 +123,14 @@ jobs:
118123
VERSION="${{ needs.get-tag-xor-dev-version.outputs.dev-version }}"
119124
poetry version "${VERSION}"
120125
echo "::set-output name=is_testing::true"
126+
shell: bash
121127

122128
- name: Log package version
123129
id: log-package-version
124130
run: |
125131
VERSION=$(make get-project-version-number)
126132
echo "::set-output name=version::${VERSION}"
133+
shell: bash
127134

128135
# PyPI/TestPyPI package upload ----------------------
129136
- name: Build package
@@ -137,7 +144,7 @@ jobs:
137144
path: dist
138145

139146
# PyPI/TestPyPI package upload ----------------------
140-
pypi-package-upload:
147+
pypi-packages-upload:
141148
name: PyPI/TestPyPI package upload
142149
runs-on: ubuntu-latest
143150
needs: package-build
@@ -159,20 +166,20 @@ jobs:
159166
pip install --constraint=.github/workflows/constraints.txt pip
160167
pip --version
161168
162-
- name: Download the binary wheel
169+
- name: Download the binary wheels
163170
uses: actions/[email protected]
164171
with:
165172
name: python-package-distributions
166173
path: dist
167174

168-
- name: Publish package on PyPI
175+
- name: Publish packages on PyPI
169176
if: "! needs.package-build.outputs.is-test-package"
170177
uses: pypa/[email protected]
171178
with:
172179
user: __token__
173180
password: ${{ secrets.PYPI_TOKEN }} # pragma: allowlist secret
174181

175-
- name: Publish package on TestPyPI
182+
- name: Publish packages on TestPyPI
176183
if: "needs.package-build.outputs.is-test-package"
177184
uses: pypa/[email protected]
178185
with:
@@ -189,7 +196,7 @@ jobs:
189196

190197
name: Verify package install as user
191198
runs-on: ${{ matrix.os }}
192-
needs: pypi-package-upload
199+
needs: pypi-packages-upload
193200

194201
steps:
195202
- name: Check out the repository
@@ -217,7 +224,7 @@ jobs:
217224
done
218225
pip list -v
219226
env:
220-
PACKAGE_VERSION: ${{ needs.pypi-package-upload.outputs.package-version }}
227+
PACKAGE_VERSION: ${{ needs.pypi-packages-upload.outputs.package-version }}
221228
shell: bash
222229
# yamllint enable rule:line-length
223230

.mutmut-cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:4a327e7d5ec9a48d07a2298c0e3a15101e3a609c410eb525999b2625739fb601
2+
oid sha256:a43cecb1b33db4f68e9d629858a19066dfb8081077a5851756ff44ded1a8bb93
33
size 73728

build.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import mypyc.build
2+
3+
4+
def build(setup_kwargs: dict) -> None:
5+
"""
6+
This function is mandatory in order to build the extensions.
7+
"""
8+
setup_kwargs.update(
9+
{
10+
"ext_modules": mypyc.build.mypycify(
11+
[
12+
"--disallow-untyped-defs",
13+
"structlog_sentry_logger/__init__.py",
14+
"structlog_sentry_logger/_config.py",
15+
]
16+
),
17+
}
18+
)

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ classifiers = [
2323
"Topic :: Software Development :: Libraries :: Python Modules",
2424
]
2525

26+
[tool.poetry.build]
27+
script = "build.py"
28+
generate-setup-file = false
29+
2630
[tool.poetry.urls]
2731
Changelog = "https://github.com/TeoZosa/structlog-sentry-logger/releases"
2832

@@ -198,5 +202,5 @@ testpaths = ["tests",]
198202
norecursedirs = [".*", "*.egg", "build", "dist",]
199203

200204
[build-system]
201-
requires = ["poetry-core>=1.0.0"]
205+
requires = ["poetry-core>=1.0.0", "mypy"]
202206
build-backend = "poetry.core.masonry.api"

structlog_sentry_logger/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def set_structlog_config(timestamper: structlog.processors.TimeStamper) -> None:
207207
processors=(
208208
stdlib_log_compatibility_processors # type: ignore[arg-type]
209209
+ structlog_processors
210-
+ format_wrapper_processer # type: ignore[operator]
210+
+ format_wrapper_processer # type: ignore[arg-type,operator]
211211
),
212212
# See [Performance](https://www.structlog.org/en/stable/performance.html)
213213
# for an in-depth explanation of the below settings

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ commands = pre-commit run {posargs} -vv --all-files --color always
140140
description = Build Python package and validate its long description
141141
deps =
142142
poetry >= 1.1.2
143+
mypy >= 0.910
143144
twine >= 1.12.1
144145
readme-renderer[md] >= 24.0
145146
skip_install = true

0 commit comments

Comments
 (0)