-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maturin fails if sys.stdout
is an io.StringIO
object
#1814
Comments
What's your proposed solution here? From reading the issues you linked, I'm leaning towards that if you are patching @konstin What do you think? |
Normally, i'd say maturin should support mocked
I would argue that a linux distribution should follow the PEP 517 recommendation. You can use the build library which provides an easy integration. |
Sorry I am not that familiar with python so I am searching for solution as well. If I find an elegant solution, I will comment. Actually in the case I am not patching the sys.stdout, the type of sys.stdout differs because the standard output is redirected. |
How exactly was the stdout redirected? I'm not sure why redirect stdout (like using |
Ok, found it in your code @contextlib.contextmanager
def hook_call():
captured_out = StringIO()
with contextlib.redirect_stdout(captured_out):
yield
for line in captured_out.getvalue().splitlines():
print_err('HOOK STDOUT:', line) so you are effectively patching I'm going to close this as wontfix. |
Bug Description
I am a package maintainer of a fedora-like linux distribution. In our case of using
rpmbuild
to build a python package bymaturin
, it throws an exception. This happens in the stage that some rpmbuild-related python scripts are called to generate the dependency of package.This exception turns out to be a known risk of using
sys.stdout.buffer
while the context of standard streams is unknown. By usingsys.stdout.buffer
, it is supposed thatsys.stdout
isio.TextIOWrapper
. This is true for most of the common usages. However, in some cases, such as a library usage,sys.stdout
can beio.StringIO
, which does not havebuffer
, and here comes the exception.It's been officially documented at here.
There is also similar issues for flake, at [1] [2].
Your maturin version (
maturin --version
)1.3.0
Your Python version (
python -V
)3.10.13
Your pip version (
pip -V
)23.1
What bindings you're using
None
Does
cargo build
work?If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash
/
)?Steps to Reproduce
I have packed all the resources into a tarball. By downloading and extracting it you can reproduce this problem.
Then, you will get this output:
The text was updated successfully, but these errors were encountered: