Skip to content

Commit

Permalink
Merge pull request #267 from davidhewitt/mingw
Browse files Browse the repository at this point in the history
add mingw CI
  • Loading branch information
messense authored Jul 25, 2022
2 parents 4c88c6a + 14732c2 commit 8fe44b9
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 111 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,46 @@ jobs:
CIBW_BUILD_VERBOSITY: 1
with:
package-dir: examples/namespace_package

test-mingw:
runs-on: windows-latest
name: ${{ matrix.python-version }} mingw-${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
include: [
{ msystem: MINGW64, arch: x86_64, path: mingw64, rust_target: x86_64-pc-windows-gnu },
{ msystem: MINGW32, arch: i686, path: mingw32, rust_target: i686-pc-windows-gnu }
]
steps:
- uses: actions/checkout@v2
- name: Install MSys2 and dependencies
uses: msys2/setup-msys2@v2
with:
update: true
msystem: ${{ matrix.msystem }}
install: >-
git
mingw-w64-${{ matrix.arch }}-python
mingw-w64-${{ matrix.arch }}-python-pip
mingw-w64-${{ matrix.arch }}-openssl
mingw-w64-${{ matrix.arch }}-toolchain
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable-${{ matrix.rust_target }}
default: true

- name: Install test dependencies
shell: msys2 {0}
run: python -m pip install --upgrade nox pip wheel

- name: Create libpython symlink
shell: msys2 {0}
run: ln -s /${{ matrix.path }}/lib/libpython3.10.dll.a /${{ matrix.path }}/lib/libpython310.dll.a

- name: Test examples
shell: msys2 {0}
run: |
PATH="$PATH:/c/Users/runneradmin/.cargo/bin" nox -s test-mingw
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Changelog

## 1.4.1 (2022-07-05)
## Unreleased
### Changed
- 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)


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

## 1.4.0 (2022-07-05)

### Packaging
- Increase minimum `setuptools` version to 62.4. [#246](https://github.com/PyO3/setuptools-rust/pull/246)

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

## 1.3.0 (2022-04-26)

### Packaging
- Increase minimum `setuptools` version to 58. [#222](https://github.com/PyO3/setuptools-rust/pull/222)

Expand Down
2 changes: 1 addition & 1 deletion examples/namespace_package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2018"

[lib]
crate-type = ["cdylib"]
crate-type = ["cdylib", "rlib"]

[dependencies]
pyo3 = { version = "0.16.5", features = ["extension-module"] }
38 changes: 38 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import tarfile
from glob import glob
from pathlib import Path
from unittest.mock import patch

import nox

Expand Down Expand Up @@ -35,3 +36,40 @@ def mypy(session: nox.Session):
def test(session: nox.Session):
session.install("pytest", ".")
session.run("pytest", "setuptools_rust", "tests", *session.posargs)


@nox.session(name="test-mingw")
def test_mingw(session: nox.Session):
# manually re-implemented test-examples to workaround
# https://github.com/wntrblm/nox/issues/630

oldrun = nox.command.run

def newrun(*args, **kwargs):
# suppress "external" error on install
kwargs["external"] = True
oldrun(*args, **kwargs)

def chdir(path: Path):
print(path)
os.chdir(path)

examples = Path(os.path.dirname(__file__)).absolute() / "examples"

with patch.object(nox.command, "run", newrun):
session.install(".")

session.install("--no-build-isolation", str(examples / "hello-world"))
session.run("hello-world")

session.install("pytest", "pytest-benchmark", "beautifulsoup4")
session.install("--no-build-isolation", str(examples / "html-py-ever"))
session.run("pytest", str(examples / "html-py-ever"))

session.install("pytest")
session.install("--no-build-isolation", str(examples / "html-py-ever"))
session.run("pytest", str(examples / "html-py-ever"))

session.install("pytest", "cffi")
session.install("--no-build-isolation", str(examples / "html-py-ever"))
session.run("pytest", str(examples / "html-py-ever"))
18 changes: 15 additions & 3 deletions setuptools_rust/_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import subprocess


def format_called_process_error(e: subprocess.CalledProcessError) -> str:
def format_called_process_error(
e: subprocess.CalledProcessError,
*,
include_stdout: bool = True,
include_stderr: bool = True,
) -> str:
"""Helper to convert a CalledProcessError to an error message.
If `include_stdout` or `include_stderr` are True (the default), the
respective output stream will be added to the error message (if
present in the exception).
>>> format_called_process_error(subprocess.CalledProcessError(
... 777, ['ls', '-la'], None, None
Expand All @@ -14,18 +22,22 @@ def format_called_process_error(e: subprocess.CalledProcessError) -> str:
... ))
"`cargo 'foo bar'` failed with code 1\\n-- Output captured from stdout:\\nmessage"
>>> format_called_process_error(subprocess.CalledProcessError(
... 1, ['cargo', 'foo bar'], 'message', None
... ), include_stdout=False)
"`cargo 'foo bar'` failed with code 1"
>>> format_called_process_error(subprocess.CalledProcessError(
... -1, ['cargo'], 'stdout', 'stderr'
... ))
'`cargo` failed with code -1\\n-- Output captured from stdout:\\nstdout\\n-- Output captured from stderr:\\nstderr'
"""
command = " ".join(_quote_whitespace(arg) for arg in e.cmd)
message = f"`{command}` failed with code {e.returncode}"
if e.stdout is not None:
if include_stdout and e.stdout is not None:
message += f"""
-- Output captured from stdout:
{e.stdout}"""

if e.stderr is not None:
if include_stderr and e.stderr is not None:
message += f"""
-- Output captured from stderr:
{e.stderr}"""
Expand Down
Loading

0 comments on commit 8fe44b9

Please sign in to comment.