Skip to content
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

curses for windows (alternative patch) #47138

Closed
techtonik mannequin opened this issue May 16, 2008 · 31 comments
Closed

curses for windows (alternative patch) #47138

techtonik mannequin opened this issue May 16, 2008 · 31 comments
Labels
extension-modules C modules in the Modules dir OS-windows type-feature A feature request or enhancement

Comments

@techtonik
Copy link
Mannequin

techtonik mannequin commented May 16, 2008

BPO 2889
Nosy @loewis, @pfmoore, @jkloth, @Trundle, @ipatrol, @ulfalizer, @madebr
Files
  • curses_win_port.patch.txt
  • curses_win_compile.bat
  • python-pdcurses.patch
  • python-pdcurses-2.patch
  • python-pdcurses-3.patch
  • pdcurses-changes.patch: Changes to Lib/test/test_curses.py Modules/_cursesmodule.c PC/mkstemp.c PC/pyconfig.h PCbuild/_curses.vcproj PCbuild/_curses_panel.vcproj PCbuild/pcbuild.sln PCbuild/pdcurses.vcproj PCbuild/pythoncore.vcproj
  • pdcurses.patch: pdcurses source
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2008-05-16.06:38:26.189>
    labels = ['extension-modules', 'type-feature', 'OS-windows']
    title = 'curses for windows (alternative patch)'
    updated_at = <Date 2021-04-05.14:37:31.276>
    user = 'https://bugs.python.org/techtonik'

    bugs.python.org fields:

    activity = <Date 2021-04-05.14:37:31.276>
    actor = 'jkloth'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Extension Modules', 'Windows']
    creation = <Date 2008-05-16.06:38:26.189>
    creator = 'techtonik'
    dependencies = []
    files = ['10339', '10340', '12862', '13282', '15171', '20492', '20493']
    hgrepos = []
    issue_num = 2889
    keywords = ['patch']
    message_count = 23.0
    messages = ['66920', '67288', '80554', '82781', '83365', '94309', '114011', '114013', '114370', '114399', '114740', '114770', '114778', '116224', '126887', '128191', '185746', '222640', '236384', '237855', '237857', '349089', '375683']
    nosy_count = 16.0
    nosy_names = ['loewis', 'paul.moore', 'techtonik', 'jkloth', 'rpetrov', 'zhirsch', 'Trundle', 'cgohlke', 'jmb', 'ipatrol', 'Prasun Ratn', 'christoph.baumgartner', 'Taylor.Marks', 'Mario Figueiredo', 'ulfalizer', 'maarten']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue2889'
    versions = ['Python 3.3']

    @techtonik
    Copy link
    Mannequin Author

    techtonik mannequin commented May 16, 2008

    Make curses available on Windows by using PDCurses library. Alternative
    patch for bpo-1005895 using current trunk.

    Attached .bat file is used to compile it under MinGW, but I'd be glad to
    know how to integrate the patch into Python build system.

    PDCurses includes support for mouse functions compatible with ncurses,
    but to turn it on if requires to define NCURSES_MOUSE_VERSION to 2
    before <curses.h> is included. I am not familiar with configure.* stuff,
    so I've just pasted required definitions into _cursesmodule.c
    With attached .bat file it works by external definition.

    Some functions, such as initterm are not available on Windows platform
    and were defined out.

    I hope that curses module will be included in next Python 2.6

    @techtonik techtonik mannequin added the extension-modules C modules in the Modules dir label May 16, 2008
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 24, 2008

    The patch, in its current form, is incomplete. Can you please provide:

    a) a VS 2008 project file, which builds both the curses module and the
    pdcurses library, fetching the sources for that from ../../pdcurses (or
    some such); the project file should be structured similar to all the
    other project files in PCbuild
    b) a patch to PCbuild/readme.txt, with instructions on how to build the
    extension

    @zhirsch
    Copy link
    Mannequin

    zhirsch mannequin commented Jan 26, 2009

    Here's a patch against the head of trunk that adds vcproj files for
    _curses and _curses_panel, modifies (slightly) the test suite and
    _cursesmodule.c (again, slightly) to get Python to work with pdcurses on
    windows. I also added a blurb to PCbuild\readme.txt.

    With this, test_curses.py passes and I'm able to run all the curses
    demos that come with Python's source.

    @akuchling
    Copy link
    Member

    I can't say anything about the Windows build aspects. Some observations
    about the curses/test_curses changes:

    • test_curses: I'd be happier to see the 'if' statement as sys.platform
      != 'win32' and (not term or term == 'unknown') -- easier to read.

    • test_curses: does putp() make PDCurses crash, or is it not available?
      If the latter, I'd prefer to see 'if hasattr(curses, "putp"): <putp
      test>'. Same for the tparm() test.

    • Given that you include term.h and IRIX included term.h, I wonder if we
      should make _cursesmodule.c include term.h on all platforms that have
      it, and then fix the resulting breakage claimed by the comment (if any).

    • Is setupterm() a no-up on Windows? Maybe the function just shouldn't
      be defined on Windows, then, so that user code can check for the
      function's existence.

    @zhirsch
    Copy link
    Mannequin

    zhirsch mannequin commented Mar 9, 2009

    • test_curses: I'd be happier to see the 'if' statement as sys.platform
      != 'win32' and (not term or term == 'unknown') -- easier to read.

    OK, fixed.

    • test_curses: does putp() make PDCurses crash, or is it not available?
      If the latter, I'd prefer to see 'if hasattr(curses, "putp"): <putp
      test>'. Same for the tparm() test.

    They're stubs in pdcurses that always return an error. I'm not sure
    which is better in this case -- make them available through the curses
    module but always raise an exception on Windows, or make them
    unavailable and have it be an AttributeError if something tries to call
    them on Windows.

    • Given that you include term.h and IRIX included term.h, I wonder if we
      should make _cursesmodule.c include term.h on all platforms that have
      it, and then fix the resulting breakage claimed by the comment (if any).

    Yea, it was actually really easy to resolve the conflicts. I've done
    that, and tested the result on Linux and OS X 10.4.

    • Is setupterm() a no-up on Windows? Maybe the function just shouldn't
      be defined on Windows, then, so that user code can check for the
      function's existence.

    PDCurses does the same thing for setupterm as it does for putp/tparm
    (and a number of other unsupported functions) -- always returns an
    error. However, the curses module keeps track of whether it's been
    initialized based on whether setupterm has been called, so I think it
    makes sense to keep setupterm available but not call PDCurses's
    setupterm function on Windows.

    @jmb
    Copy link
    Mannequin

    jmb mannequin commented Oct 21, 2009

    I've built a package for python 2.6 using a slightly modified version of
    this patch. I've uploaded it here: http://jeberger.free.fr/python/

    I'm attaching my version of the patch here. I had to make two
    modifications for it to work:

    • Change all references to _ISPAD into _PAD (obviously this needs to be
      done better since what I did will break the ncurses compatibility);
    • Change "(long) (n << 8)" into "COLOR_PAIR (n)". This should be
      compatible between curses implementations.

    With this package, I've been able to run the Mercurial "crecord"
    extension on Windows.

    @ipatrol
    Copy link
    Mannequin

    ipatrol mannequin commented Aug 15, 2010

    Any progress yat?

    @ipatrol ipatrol mannequin added OS-windows type-feature A feature request or enhancement labels Aug 15, 2010
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 15, 2010

    It can't go into 2.x anymore.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Aug 19, 2010

    Brian or Tim any interest in this?

    @tjguk
    Copy link
    Member

    tjguk commented Aug 19, 2010

    I'll pick it up for the moment to shepherd it along because I'm reasonably keen to see a Windows curses in the stdlib. However, I'm no expert in curses and I don't promise to do anything immediate with it.

    @tjguk tjguk self-assigned this Aug 19, 2010
    @rpetrov
    Copy link
    Mannequin

    rpetrov mannequin commented Aug 23, 2010

    -1 for PDCurses

    @tjguk
    Copy link
    Member

    tjguk commented Aug 24, 2010

    I have no strong opinion, Roumen, (and no experience with the package)
    but why -1 from you?

    @rpetrov
    Copy link
    Mannequin

    rpetrov mannequin commented Aug 24, 2010

    Recent ncurses pass python tests with only one small update (part of patch to bpo-3871):
    =====================================

    --- ./Lib/test/test_curses.py.MINGW	2010-08-09 00:03:48.000000000 +0300
    +++ ./Lib/test/test_curses.py	2010-08-09 00:05:38.000000000 +0300
    @@ -167,11 +167,16 @@
         curses.delay_output(1)
         curses.echo() ; curses.echo(1)
     
    -    f = tempfile.TemporaryFile()
    +    fx = tempfile.TemporaryFile()
    +    # cf tempfile.py TemporaryFile vs NamedTemporaryFile
    +    if os.name != 'posix' or os.sys.platform == 'cygwin':
    +        f = fx.file
    +    else:
    +        f = fx
         stdscr.putwin(f)
         f.seek(0)
         curses.getwin(f)
    -    f.close()
    +    fx.close()
     
         curses.halfdelay(1)
         curses.intrflush(1)

    =====================================
    About TERM environment variable - I don't have time to test ncurses if is not set.

    Also PDCurses is not updated since 2008.

    @techtonik
    Copy link
    Mannequin Author

    techtonik mannequin commented Sep 12, 2010

    PDCurses is not updated, because it is considered stable and mature library that has been tested on Windows platform by many roguelikes. I doubt that ncurses hackers care about Windows compatibility more than just to make it run.

    @PrasunRatn
    Copy link
    Mannequin

    PrasunRatn mannequin commented Jan 23, 2011

    What is the status of this bug?

    I tried to build the svn trunk with patches provided by zhirsch but I had problems applying the patches. I went ahead and made a new patch which is pretty similar to the earlier patch (mentioned above). The one change is that I implemented mkstemp() so putwin() and getwin() work.

    @cgohlke
    Copy link
    Mannequin

    cgohlke mannequin commented Feb 8, 2011

    Curses binaries for Python 2.5, 2.6, 2.7, 3.1 and 3.2, win32 and win-amd64, are available at <http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses\>.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Apr 1, 2013

    @Christoph Gohlke any chance of providing a build for 3.3?

    @tjguk tjguk removed their assignment Jul 31, 2013
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 9, 2014

    Can this be closed as curses binaries for Python 2.5, 2.6, 2.7, 3.1, 3.2, 3.3 and 3.4, win32 and win-amd64, are available at <http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses\>, plus there is also https://pypi.python.org/pypi/UniCurses/1.2 ?

    @TaylorMarks
    Copy link
    Mannequin

    TaylorMarks mannequin commented Feb 21, 2015

    Python is supposed to be cross platform. This has been a major incompatibility issue between Windows and *nix and you think this patch, which has been ready for nearly 7 years now, should simply get discarded because the fix is available from pip?

    I think there are two possible remedies to this:

    • Accept this patch.
    • Remove curses from the Python standard library for *nix (breaks backwards compatibility for *nix, but fixes compatibility between Windows and *nix going forward.)

    @MarioFigueiredo
    Copy link
    Mannequin

    MarioFigueiredo mannequin commented Mar 11, 2015

    This patch is a huge improvement over the current situation, which is we don't have a cross-platform curses implementation in the standard library.

    The alternatives listed by Mark aren't sufficient. For the two reasons given below:

    • The implementation at http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses does not support unicode characters, which is a big limitation in today's general computing tasks.

    • The UniCurses module isn't compatible with the curses standard lib implementation since it wraps curses/pdcurses and does not provide python own wrappers like the ability of addstr to accept encoded byte strings. This essentially makes UniCurses a 3rd-party library requirements regardless of the operating system, which is always nice to have but does not help the batteries included principles behind python standard library.

    Conclusion:
    Please implement this patch ASAP. It's been many years since it was made available. It works, it passes all tests and we all benefit if we close this python cross-compatibility issue.

    @pfmoore
    Copy link
    Member

    pfmoore commented Mar 11, 2015

    The patch would need updating to be applicable. Minimum changes I would expect to be required:

    1. Update to build for Python 3.5 (the patch will *not* be included in earlier versions, as it is a new feature), which means it needs the Visual Studio 2015 build files updating.
    2. Rather than wholesale dumping a curses implementation into the Python source (which is what pdcurses.patch seems to do) the appropriate curses source should be fetched via the externals.bat script, like the other external dependencies.
    3. Documentation. At a minimum "available in Windows from Python X.Y", but probably also document any differences from Unix, which from the comments here are likely to exist if the patch uses pdcurses on Windows.
    4. Tests. Again, make sure that any functionality that differs is properly covered on Windows, or skip specific Unix-only functionality.

    That's quite a lot of changes, in practice.

    Unless someone is going to step up and do all of that (and keep it maintained until it gets merged, which probably won't be till 3.6) *and* there's one of the core devs willing to support the code going forward once its committed, then I think closing this as "won't fix" and referring to the external packages is the best solution.

    A documentation patch to https://docs.python.org/3.4/howto/curses.html ("Curses programming with Python") which explained how to set up one of the external curses modules on Windows, and how to write cross-platform code that uses the core implementation on Unix and the 3rd party module on Windows, would be immensely useful for people interested in this patch. Probably far more so than pushing for this patch to go in, in all honesty, as it's easier to do and would be useful to people on older versions of Python as well.

    @ulfalizer
    Copy link
    Mannequin

    ulfalizer mannequin commented Aug 5, 2019

    Just as an FYI, there is a repository for building curses wheels for Windows at https://github.com/zephyrproject-rtos/windows-curses, based on patches from here and Gohlke's work.

    Building wheels is less straightforward than it used to be, e.g. due to term.h disappearing from PDCurses.

    We also make wheels available on PyPI.

    @madebr
    Copy link
    Mannequin

    madebr mannequin commented Aug 20, 2020

    Current ncurses master is buildable on Visual Studio, using msys2.

    It should be possible to create a vcxproject and integrate it in the Visual Studio build.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @erlend-aasland
    Copy link
    Contributor

    @pfmoore:

    Unless someone is going to step up and do all of that (and keep it maintained until it gets merged, which probably won't be till 3.6) and there's one of the core devs willing to support the code going forward once its committed, then I think closing this as "won't fix" and referring to the external packages is the best solution.

    +1

    Also, the windows-curses package seems to be fairly up to date for those who want to use PDCurses on Windows.

    @erlend-aasland erlend-aasland added the pending The issue will be closed if no feedback is provided label May 20, 2022
    @AA-Turner
    Copy link
    Member

    Closing as windows-curses exists, and per Paul & Erlend. If someone would like to do the work to implement curses on windows, we could re-open this issue or discuss in a new one (referencing 3.12+ rather than 3.6!)

    A

    @AA-Turner AA-Turner closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2022
    @AA-Turner AA-Turner removed the pending The issue will be closed if no feedback is provided label May 28, 2022
    @irvinren
    Copy link

    Closing as windows-curses exists, and per Paul & Erlend. If someone would like to do the work to implement curses on windows, we could re-open this issue or discuss in a new one (referencing 3.12+ rather than 3.6!)

    A

    Closing as windows-curses exists, and per Paul & Erlend. If someone would like to do the work to implement curses on windows, we could re-open this issue or discuss in a new one (referencing 3.12+ rather than 3.6!)

    A

    Windows-curses quit silently on Cpython3.12. is it possible to reopen this issue?

    @irvinren
    Copy link

    irvinren commented Dec 1, 2023

    @AA-Turner
    windows-curses stopped active development and looking for another maintainer, is it possible to reopen this issue?
    zephyrproject-rtos/windows-curses#50 (comment)

    @erlend-aasland
    Copy link
    Contributor

    See also #40725.

    @irvinren
    Copy link

    irvinren commented Dec 4, 2023

    See also #40725.

    that one seems not for MSVC compiler. Could I directly try this patch?

    @erlend-aasland
    Copy link
    Contributor

    that one seems not for MSVC compiler. Could I directly try this patch?

    I'm not sure which patch you are referring to, but I'd expect all the attached files both in this issue and #40725 to be seriously outdated; I would not expect any of these to merge cleanly into main, and even if they would merge "cleanishly", I would not expect them to compile. Any attempt at getting this ball rolling again would have to start by either adapting one of the outdated patches to work with the current C API, or by writing the extension module from scratch.

    @cgohlke
    Copy link

    cgohlke commented Dec 5, 2023

    FWIW, I moved the code and build script used for https://www.lfd.uci.edu/~gohlke/pythonlibs/#curses to https://github.com/cgohlke/python-curses-build

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir OS-windows type-feature A feature request or enhancement
    Projects
    Status: Done
    Development

    No branches or pull requests

    7 participants