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
make twisted.internet.endpoints importable on Windows when pywin32 is not installed #6032
Comments
This would fix Tahoe-LAFS ticket https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2028 . |
For the upcoming Tahoe-LAFS v1.11 release, we're working-around this issue by requiring Twisted < 12.2.0: |
This interacts with twisted/nevow#43 (why does Nevow depend on Twisted >= 13.0?). |
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. |
OK, I guess the Tahoe problem here is recently resolved, so the original reporters are probably not motivated to fix it; but, wow, this must be a terrible onboarding experience for windows users. We should definitely fix it. |
Now that we test on appveyor, this (specifically, the no-modules builder) could be submitted as a regular Twisted ticket, without needing a buildbot configuration change. |
Would be really great to have this fixed. I maintain a web app framework that is based on Django Channels. I can't upgrade to the latest Channels because it depends on twisted.internet.endpoints, which relies on pypiwin32. I have ruled out adding a dependency on pypiwin32 because it creates too many installation/deployment complications for my users. Here is an issue someone logged in Django Channels that also references this issue: |
Thanks for the update. If you would like to contribute a fix, please have a look at the development process documentation. Please just contribute a change to appveyor.yml that runs a tox environment without "alldeps" in its name so that we have a build tracking what happens without pywin32; at that point it should be relatively easy to add the try/except around the relevant import. |
We would absolutely love to support Django Channels' use of Twisted, and I'm sorry I don't have the time personally to do this fix. |
I wrapped the import in a simple try/except, and all Django Channels tests are passing. In appveyor.yml, line 44, add this:
In src/twisted/internet/endpoints.py, line 41, change this:
To this:
Also, this command passes (but it passed even before I made the change):
Not sure how to really test or how to use AppVeyor. I'm totally new to Twisted. This is all the time I was able to spend on this for now. Leaving this here in case someone with more Twisted knowledge has a chance. |
Replying to oTree-org:
Hi oTree-org! First, thanks for improving Twisted :) I'm curious to know why I ask because we're considering moving to pywincffi for many reasons including ease of packaging, and if "making Twisted easier for Django channels" is one of those reasons, then I can prioritize that switch. On the other hand, if any additional transitive dependency is a problem, then we need graceful degradation along the lines of what you've written in a later comment. We might need that anyway, because, as Glyph said, this is a really bad experience for Windows users. |
Thanks for the reply! I'm fine with just supporting Python 3.6. Rather, the issue is about adding a complex dependency that is platform specific. pywincffi definitely looks more manageable than pypiwin32, which is huge and doesn't install on non-Windows systems (which breaks the ability to "pip freeze" and push to Heroku, collaborate with others, etc; many of my framework's users are novice programmers so they have difficulty troubleshooting these things). But it would be good to eliminate unnecessary dependencies. Django channels already installs a sizable set of dependencies:
With the standard Redis backend, add:
I would like to avoid making the list longer, in order to keep my project lightweight, and to be able to understand what each part is doing. In particular, pywincffi+cffi are pretty complex, low-level, and platform-specific (which means I need to do more testing, and anticipate what happens if a Mac/Linux user accidentally installs it, etc). At the end of the day, pywincffi would probably be OK, but the import cleanly avoids the dependency altogether, which is why it is more appealing to me :) |
Replying to oTree-org:
PEP 508 markers allow you to restrict dependencies to specific platforms:
I did a little research with the PyPI BigQuery dataset to determine if people are using version of pip and setuptools that support PEP 508. Since you're OK supporting only 3.6, I limited the query to that version of Python:
Here were the results as of today:
All of these versions of pip and setuptools support PEP 508 markers. I think you'd be safe adding them to your project's dependencies so that
I'll look into |
Pull request: #1088 |
Hi, is there anything I can do to move this pull request along? |
Replying to oTree-org:
Hi oTree-org, I'm sorry nobody has been by to code review your changes yet. Twisted does tend to go through seasons of waxing and waning interest, and things have been at a bit of a low ebb lately. But you can be the change you want to see in the world! :) There are lots of things you could potentially do to move things along.
I would suggest doing some combination of these things. Ultimately the real power move here is to get a commit bit, review every change but your own, then wait for any other reviewer to come along and notice there's only one review so they have to review yours :). Reminding folks of the existence of https://twistedmatrix.com/highscores/ is sometimes helpful - it hasn't been super competitive lately, but then again, nobody's been talking about it recently. Thanks for contributing to Twisted, and I hope that someone (maybe even me) will have time to get this reviewed and integrated soon! |
Approved |
In changeset 8292869
|
Using Twisted 12.2,
twisted.internet.endpoints
cannot be imported on Windows unless pywin32 is available: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.
Searchable metadata
The text was updated successfully, but these errors were encountered: