Git Product home page Git Product logo

Comments (5)

messense avatar messense commented on June 16, 2024 2

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 > /dev/null in shell) would change it to io.StringIO.

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 sys.stdout with io.StringIO().

I'm going to close this as wontfix.

from maturin.

messense avatar messense commented on June 16, 2024

What's your proposed solution here? From reading the issues you linked, I'm leaning towards that if you are patching sys.stdout it's your responsibility to use io.TextIOWrapper.

@konstin What do you think?

from maturin.

konstin avatar konstin commented on June 16, 2024

Normally, i'd say maturin should support mocked sys.stdout, but for the case of PEP 517 specifically, the spec says:

Frontends should call each hook in a fresh subprocess, so that backends are free to change process global state (such as environment variables or the working directory). A Python library will be provided which frontends can use to easily call hooks this way.

I would argue that a linux distribution should follow the PEP 517 recommendation. You can use the build library which provides an easy integration.

from maturin.

zlind0 avatar zlind0 commented on June 16, 2024

What's your proposed solution here? From reading the issues you linked, I'm leaning towards that if you are patching sys.stdout it's your responsibility to use io.TextIOWrapper.

@konstin What do you think?

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.

from maturin.

messense avatar messense commented on June 16, 2024

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 > /dev/null in shell) would change it to io.StringIO.

from maturin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.