classification
Title: curses for windows (alternative patch)
Type: enhancement Stage: patch review
Components: Extension Modules, Windows Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, Prasun Ratn, Trundle, akuchling, cgohlke, christoph.baumgartner, ipatrol, jmb, loewis, pmoore, rpetrov, techtonik, zhirsch
Priority: normal Keywords: patch

Created on 2008-05-16 06:38 by techtonik, last changed 2014-07-09 21:20 by BreamoreBoy.

Files
File name Uploaded Description Edit
curses_win_port.patch.txt techtonik, 2008-05-16 06:38
curses_win_compile.bat techtonik, 2008-05-16 06:39
python-pdcurses.patch zhirsch, 2009-01-26 00:49
python-pdcurses-2.patch zhirsch, 2009-03-09 09:56
python-pdcurses-3.patch jmb, 2009-10-21 07:24
pdcurses-changes.patch Prasun Ratn, 2011-01-23 11:49 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 Prasun Ratn, 2011-01-23 11:50 pdcurses source
Messages (18)
msg66920 - (view) Author: anatoly techtonik (techtonik) Date: 2008-05-16 06:38
Make curses available on Windows by using PDCurses library. Alternative
patch for issue 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
msg67288 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-05-24 09:51
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
msg80554 - (view) Author: Zach Hirsch (zhirsch) Date: 2009-01-26 00:49
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.
msg82781 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2009-02-26 22:22
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.
msg83365 - (view) Author: Zach Hirsch (zhirsch) Date: 2009-03-09 09:56
> * 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.
msg94309 - (view) Author: (jmb) Date: 2009-10-21 07:24
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.
msg114011 - (view) Author: (ipatrol) Date: 2010-08-15 21:26
Any progress yat?
msg114013 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-08-15 21:30
It can't go into 2.x anymore.
msg114370 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-19 15:54
Brian or Tim any interest in this?
msg114399 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010-08-19 18:46
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.
msg114740 - (view) Author: Roumen Petrov (rpetrov) * Date: 2010-08-23 21:48
-1 for PDCurses
msg114770 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010-08-24 07:27
I have no strong opinion, Roumen, (and no experience with the package) 
but why -1 from you?
msg114778 - (view) Author: Roumen Petrov (rpetrov) * Date: 2010-08-24 11:42
Recent ncurses pass python tests with only one small update (part of patch to issue 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.
msg116224 - (view) Author: anatoly techtonik (techtonik) Date: 2010-09-12 18:43
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.
msg126887 - (view) Author: Prasun Ratn (Prasun Ratn) Date: 2011-01-23 11:49
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.
msg128191 - (view) Author: Christoph Gohlke (cgohlke) Date: 2011-02-08 21:47
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>.
msg185746 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-04-01 17:21
@Christoph Gohlke any chance of providing a build for 3.3?
msg222640 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-09 21:20
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 ?
History
Date User Action Args
2014-07-09 21:20:43BreamoreBoysetnosy: + BreamoreBoy
messages: + msg222640
2014-02-03 15:47:28BreamoreBoysetnosy: - BreamoreBoy
2013-11-05 10:08:47christoph.baumgartnersetnosy: + christoph.baumgartner
2013-10-24 10:00:33tim.goldensetnosy: - tim.golden
2013-07-31 15:10:03tim.goldensetassignee: tim.golden ->
2013-04-01 17:21:39BreamoreBoysetmessages: + msg185746
2011-02-08 21:47:32cgohlkesetnosy: loewis, akuchling, pmoore, techtonik, tim.golden, rpetrov, zhirsch, Trundle, cgohlke, jmb, ipatrol, BreamoreBoy, Prasun Ratn
messages: + msg128191
2011-01-23 11:50:57Prasun Ratnsetfiles: + pdcurses.patch
nosy: loewis, akuchling, pmoore, techtonik, tim.golden, rpetrov, zhirsch, Trundle, cgohlke, jmb, ipatrol, BreamoreBoy, Prasun Ratn
2011-01-23 11:49:11Prasun Ratnsetfiles: + pdcurses-changes.patch
nosy: + Prasun Ratn
messages: + msg126887

2010-12-30 22:40:27georg.brandlsetnosy: loewis, akuchling, pmoore, techtonik, tim.golden, rpetrov, zhirsch, Trundle, cgohlke, jmb, ipatrol, BreamoreBoy
versions: + Python 3.3, - Python 3.2
2010-10-09 06:58:35cgohlkesetnosy: + cgohlke
2010-09-12 22:02:27brian.curtinsetnosy: - brian.curtin
2010-09-12 18:43:42techtoniksetmessages: + msg116224
2010-08-24 11:42:15rpetrovsetmessages: + msg114778
2010-08-24 07:27:29tim.goldensetmessages: + msg114770
2010-08-24 01:13:38Trundlesetnosy: + Trundle
2010-08-23 21:48:31rpetrovsetnosy: + rpetrov
messages: + msg114740
2010-08-19 18:46:23tim.goldensetassignee: tim.golden
messages: + msg114399
2010-08-19 15:54:37BreamoreBoysetnosy: + tim.golden, brian.curtin, BreamoreBoy

messages: + msg114370
stage: patch review
2010-08-15 21:30:57loewissetmessages: + msg114013
versions: + Python 3.2, - Python 2.6, Python 2.7
2010-08-15 21:26:59ipatrolsetversions: + Python 2.7
nosy: + ipatrol

messages: + msg114011

components: + Windows
type: enhancement
2009-10-21 07:24:18jmbsetfiles: + python-pdcurses-3.patch

messages: + msg94309
2009-10-19 13:02:36jmbsetnosy: + jmb
2009-03-23 20:55:30pmooresetnosy: + pmoore
2009-03-09 09:56:53zhirschsetfiles: + python-pdcurses-2.patch

messages: + msg83365
2009-02-26 22:23:00akuchlingsetmessages: + msg82781
2009-02-26 22:12:14akuchlingsetnosy: + akuchling
2009-01-26 00:49:37zhirschsetfiles: + python-pdcurses.patch
nosy: + zhirsch
messages: + msg80554
keywords: + patch
2008-05-24 09:51:38loewissetnosy: + loewis
messages: + msg67288
2008-05-16 06:39:47techtoniksetfiles: + curses_win_compile.bat
2008-05-16 06:38:26techtonikcreate