Skip to content

Commit 8fe44b9

Browse files
authored
Merge pull request #267 from davidhewitt/mingw
add mingw CI
2 parents 4c88c6a + 14732c2 commit 8fe44b9

File tree

8 files changed

+268
-111
lines changed

8 files changed

+268
-111
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,46 @@ jobs:
357357
CIBW_BUILD_VERBOSITY: 1
358358
with:
359359
package-dir: examples/namespace_package
360+
361+
test-mingw:
362+
runs-on: windows-latest
363+
name: ${{ matrix.python-version }} mingw-${{ matrix.arch }}
364+
strategy:
365+
fail-fast: false
366+
matrix:
367+
include: [
368+
{ msystem: MINGW64, arch: x86_64, path: mingw64, rust_target: x86_64-pc-windows-gnu },
369+
{ msystem: MINGW32, arch: i686, path: mingw32, rust_target: i686-pc-windows-gnu }
370+
]
371+
steps:
372+
- uses: actions/checkout@v2
373+
- name: Install MSys2 and dependencies
374+
uses: msys2/setup-msys2@v2
375+
with:
376+
update: true
377+
msystem: ${{ matrix.msystem }}
378+
install: >-
379+
git
380+
mingw-w64-${{ matrix.arch }}-python
381+
mingw-w64-${{ matrix.arch }}-python-pip
382+
mingw-w64-${{ matrix.arch }}-openssl
383+
mingw-w64-${{ matrix.arch }}-toolchain
384+
385+
- uses: actions-rs/toolchain@v1
386+
with:
387+
profile: minimal
388+
toolchain: stable-${{ matrix.rust_target }}
389+
default: true
390+
391+
- name: Install test dependencies
392+
shell: msys2 {0}
393+
run: python -m pip install --upgrade nox pip wheel
394+
395+
- name: Create libpython symlink
396+
shell: msys2 {0}
397+
run: ln -s /${{ matrix.path }}/lib/libpython3.10.dll.a /${{ matrix.path }}/lib/libpython310.dll.a
398+
399+
- name: Test examples
400+
shell: msys2 {0}
401+
run: |
402+
PATH="$PATH:/c/Users/runneradmin/.cargo/bin" nox -s test-mingw

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Changelog
22

3-
## 1.4.1 (2022-07-05)
3+
## Unreleased
4+
### Changed
5+
- Locate cdylib artifacts by handling messages from cargo instead of searching target dir (fixes build on MSYS2). [#267](https://github.com/PyO3/setuptools-rust/pull/267)
6+
47

8+
## 1.4.1 (2022-07-05)
59
### Fixed
610
- Fix crash when checking Rust version. [#263](https://github.com/PyO3/setuptools-rust/pull/263)
711

812
## 1.4.0 (2022-07-05)
9-
1013
### Packaging
1114
- Increase minimum `setuptools` version to 62.4. [#246](https://github.com/PyO3/setuptools-rust/pull/246)
1215

@@ -25,7 +28,6 @@
2528
- If the sysconfig for `BLDSHARED` has no flags, `setuptools-rust` won't crash anymore. [#241](https://github.com/PyO3/setuptools-rust/pull/241)
2629

2730
## 1.3.0 (2022-04-26)
28-
2931
### Packaging
3032
- Increase minimum `setuptools` version to 58. [#222](https://github.com/PyO3/setuptools-rust/pull/222)
3133

examples/namespace_package/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2018"
55

66
[lib]
7-
crate-type = ["cdylib"]
7+
crate-type = ["cdylib", "rlib"]
88

99
[dependencies]
1010
pyo3 = { version = "0.16.5", features = ["extension-module"] }

noxfile.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import tarfile
33
from glob import glob
44
from pathlib import Path
5+
from unittest.mock import patch
56

67
import nox
78

@@ -35,3 +36,40 @@ def mypy(session: nox.Session):
3536
def test(session: nox.Session):
3637
session.install("pytest", ".")
3738
session.run("pytest", "setuptools_rust", "tests", *session.posargs)
39+
40+
41+
@nox.session(name="test-mingw")
42+
def test_mingw(session: nox.Session):
43+
# manually re-implemented test-examples to workaround
44+
# https://github.com/wntrblm/nox/issues/630
45+
46+
oldrun = nox.command.run
47+
48+
def newrun(*args, **kwargs):
49+
# suppress "external" error on install
50+
kwargs["external"] = True
51+
oldrun(*args, **kwargs)
52+
53+
def chdir(path: Path):
54+
print(path)
55+
os.chdir(path)
56+
57+
examples = Path(os.path.dirname(__file__)).absolute() / "examples"
58+
59+
with patch.object(nox.command, "run", newrun):
60+
session.install(".")
61+
62+
session.install("--no-build-isolation", str(examples / "hello-world"))
63+
session.run("hello-world")
64+
65+
session.install("pytest", "pytest-benchmark", "beautifulsoup4")
66+
session.install("--no-build-isolation", str(examples / "html-py-ever"))
67+
session.run("pytest", str(examples / "html-py-ever"))
68+
69+
session.install("pytest")
70+
session.install("--no-build-isolation", str(examples / "html-py-ever"))
71+
session.run("pytest", str(examples / "html-py-ever"))
72+
73+
session.install("pytest", "cffi")
74+
session.install("--no-build-isolation", str(examples / "html-py-ever"))
75+
session.run("pytest", str(examples / "html-py-ever"))

setuptools_rust/_utils.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import subprocess
22

33

4-
def format_called_process_error(e: subprocess.CalledProcessError) -> str:
4+
def format_called_process_error(
5+
e: subprocess.CalledProcessError,
6+
*,
7+
include_stdout: bool = True,
8+
include_stderr: bool = True,
9+
) -> str:
510
"""Helper to convert a CalledProcessError to an error message.
611
12+
If `include_stdout` or `include_stderr` are True (the default), the
13+
respective output stream will be added to the error message (if
14+
present in the exception).
715
816
>>> format_called_process_error(subprocess.CalledProcessError(
917
... 777, ['ls', '-la'], None, None
@@ -14,18 +22,22 @@ def format_called_process_error(e: subprocess.CalledProcessError) -> str:
1422
... ))
1523
"`cargo 'foo bar'` failed with code 1\\n-- Output captured from stdout:\\nmessage"
1624
>>> format_called_process_error(subprocess.CalledProcessError(
25+
... 1, ['cargo', 'foo bar'], 'message', None
26+
... ), include_stdout=False)
27+
"`cargo 'foo bar'` failed with code 1"
28+
>>> format_called_process_error(subprocess.CalledProcessError(
1729
... -1, ['cargo'], 'stdout', 'stderr'
1830
... ))
1931
'`cargo` failed with code -1\\n-- Output captured from stdout:\\nstdout\\n-- Output captured from stderr:\\nstderr'
2032
"""
2133
command = " ".join(_quote_whitespace(arg) for arg in e.cmd)
2234
message = f"`{command}` failed with code {e.returncode}"
23-
if e.stdout is not None:
35+
if include_stdout and e.stdout is not None:
2436
message += f"""
2537
-- Output captured from stdout:
2638
{e.stdout}"""
2739

28-
if e.stderr is not None:
40+
if include_stderr and e.stderr is not None:
2941
message += f"""
3042
-- Output captured from stderr:
3143
{e.stderr}"""

0 commit comments

Comments
 (0)