Opened 2 years ago

Last modified 2 weeks ago

#6032 enhancement new

make twisted.internet.endpoints importable on Windows when pywin32 is not installed

Reported by: tray Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: davidsarah Branch:
Author: Launchpad Bug:

Description (last modified by exarkun)

Using Twisted 12.2, twisted.internet.endpoints cannot be imported on Windows unless pywin32 is available:

 Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "twisted\web\client.py", line 21, in <module>
    from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint
  File "twisted\internet\endpoints.py", line 28, in <module>
    from twisted.internet import stdio
  File "twisted\internet\stdio.py", line 28, in <module>
    from twisted.internet import _win32stdio
  File "twisted\internet\_win32stdio.py", line 7, in <module>
    import win32api
ImportError: No module named win32api

As demonstrated by this traceback, this also affects any module that depends on endpoints. The pywin32 dependency is only necessary for stdio; other endpoints should be usable even if it is not installed.

This likely requires a Windows version of the no-modules builder to be set up first - see <https://bugs.launchpad.net/twisted-buildbot-configuration/+bug/1059240>.

Change History (6)

comment:1 Changed 2 years ago by exarkun

  • Description modified (diff)
  • Priority changed from high to normal
  • Summary changed from Either making pywin32 a requirement, or don't have endpoints break when it is missing to make twisted.internet.endpoints importable on Windows when pywin32 is not installed
  • Type changed from regression to enhancement

comment:2 Changed 2 years ago by exarkun

  • Description modified (diff)

comment:3 Changed 17 months ago by davidsarah

  • Cc davidsarah added

This would fix Tahoe-LAFS ticket https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2028 .

comment:4 Changed 7 months ago by zooko

For the upcoming Tahoe-LAFS v1.11 release, we're working-around this issue by requiring Twisted < 12.2.0:

https://github.com/tahoe-lafs/tahoe-lafs/commit/d888b28b715020e879a52f5159b6e14c7dcab6b8

comment:5 Changed 6 months ago by zooko

This interacts with https://github.com/twisted/nevow/issues/43 (why does Nevow depend on Twisted >= 13.0?).

comment:6 Changed 2 weeks ago by zooko

I suppose switching from pywin32 to new fork "pypiwin32" https://pypi.python.org/pypi/pypiwin32 (which exists because of this reason — http://sourceforge.net/p/pywin32/feature-requests/110/ , http://sourceforge.net/p/pywin32/bugs/669/ ) would solve this issue.

Note: See TracTickets for help on using tickets.