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

Add support for Windows (ImportError: No module named fcntl) #18

Closed
evertvr opened this issue Mar 1, 2017 · 25 comments
Closed

Add support for Windows (ImportError: No module named fcntl) #18

evertvr opened this issue Mar 1, 2017 · 25 comments
Assignees

Comments

@evertvr
Copy link

evertvr commented Mar 1, 2017

Hi!
First of all, awesome that you made this! I think this could be a great asset when teaching debugging skills of any kind!
Now, for the problem I have:
I'm on windows 7 with pip 9.0.1
Python version is 2.7
And I get this error:

#pip install gdbgui --upgrade
Collecting gdbgui
  Using cached gdbgui-0.7.4.0.tar.gz
Collecting Flask>=0.12 (from gdbgui)
  Using cached Flask-0.12-py2.py3-none-any.whl
Collecting pygdbmi>=0.7.2.1 (from gdbgui)
  Using cached pygdbmi-0.7.3.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\evvr\appdata\local\temp\pip-build-c2ejm6\pygdbmi\setup.py", line 4, in <module>
        from pygdbmi.tests import test_app
      File "c:\users\evvr\appdata\local\temp\pip-build-c2ejm6\pygdbmi\pygdbmi\tests\test_app.py", line 13, in <module>
        from pygdbmi.gdbcontroller import GdbController
      File "c:\users\evvr\appdata\local\temp\pip-build-c2ejm6\pygdbmi\pygdbmi\gdbcontroller.py", line 3, in <module>
        import fcntl
    ImportError: No module named fcntl

Any idea why fcntl is failing on me? Is it because this module is only for Unix systems?

@ksarink
Copy link

ksarink commented Mar 1, 2017

As written under https://github.com/cs01/gdbgui#compatibility it only supports Ubuntu. Since the fcntl module is for unix(like) systems only, it is unlikely the software works on Windows...

@cs01
Copy link
Owner

cs01 commented Mar 1, 2017

Thanks @FlDutchman. Unfortunately I only develop on Linux. I would love to add support for OSX and Windows, but unless someone else makes the change it won't be happening any time soon by me.

EDIT: I'm will be adding OSX support soon, but no plans for Windows at this time

@cs01 cs01 changed the title ImportError: No module named fcntl No support for Windows (ImportError: No module named fcntl) Mar 2, 2017
@Ciberth
Copy link

Ciberth commented Mar 5, 2017

@evertvr #36

It is a bypass and it runs on ubuntu instead of windows but this might be a workaround for you.

@ssokolow
Copy link

ssokolow commented Mar 5, 2017

At least in that module, fcntl seems to be used purely for setting the pipes into non-blocking mode.

Here's a StackOverflow answer that explains how to do non-blocking pipe reads in Windows. (Apparently, Windows APIs use the term "overlapped" in place of "non-blocking")

http://stackoverflow.com/a/34504971/435253
https://gist.github.com/techtonik/48c2561f38f729a15b7b

Since it depends on the Win32 API, you'll want to follow the example of os.path and implement two different abstractions with the same API, then import one or the other depending on whether os.name == 'nt'.

@cs01
Copy link
Owner

cs01 commented Mar 7, 2017

@ssokolow, that is correct that pygdbmi uses fnctl solely for changing the mode of gdb's i/o pipes. I do remember that fnctl is incompatible with Windows, but at the time I was just trying to get things rolling. Thanks for the links!

@cs01 cs01 self-assigned this Mar 7, 2017
@cs01 cs01 changed the title No support for Windows (ImportError: No module named fcntl) Add support for Windows (ImportError: No module named fcntl) Mar 7, 2017
@cs01
Copy link
Owner

cs01 commented Mar 7, 2017

For anyone looking for windows support, I am trying to add it in gdbgui's library pygdbmi, but I don't have Windows to test if it works. Test it out and let me know if it works. If so I'll add it to gdbgui and close this ticket cs01/pygdbmi#8

@ssokolow
Copy link

ssokolow commented Mar 7, 2017

If it's a complete and total lack of Windows that's the issue, rather than a matter of time or expertise constraints, you should be able to set up a test environment in one of the 90-day trial-version Windows VMs that Microsoft makes available for testing websites' IE/Edge compatibility.

https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

(Note: Microsoft says that their testing VM license terms supercede the trial-version license within the VM and explicitly recommends that you use your VM manager to snapshot the VM before first boot so you can easily reset the trial period. The gist of the license is that it has their usual EULA boilerplate about making copies, but, instead, says that you are not allowed to activate the contained copies of Windows and must only use them for testing things.)

@cs01
Copy link
Owner

cs01 commented Mar 7, 2017

It's more of a time constraint. I can get to this at some point, just wanted to put it out there in case someone really was trying to get gdbgui running on windows.

cs01 pushed a commit that referenced this issue Mar 11, 2017
upgrade pygdbmi version (issue #18) for windows; add remote option
@cs01
Copy link
Owner

cs01 commented Mar 11, 2017

tested on windows 10 with cygwin, and it worked nicely with pygdbmi v0.7.3.3.

@cs01 cs01 closed this as completed Mar 11, 2017
@ssokolow
Copy link

Umm... Cygwin is a POSIX API shim. That's sort of like counting something as "supports Linux" because it runs in Wine.

@cs01
Copy link
Owner

cs01 commented Mar 11, 2017

It successfully used the non-blocking pipe code for windows.

@ssokolow
Copy link

Ahh. So, not a perfect test, but a pass for the specific facet being focused on here.

@cs01
Copy link
Owner

cs01 commented Mar 11, 2017

Yes, but I also considered it complete for windows. I guess technically it still may not function properly on windows since as you said Cygwin is a shim. Do you know of anything in particular that could still fail if Cygwin was not used?

It at least provides some path forward for windows users. I'm not a windows developer. I just installed python on there for the first time today, played around with powershell (which was horrible), and then set up cygwin, and ran some tests.

@ssokolow
Copy link

ssokolow commented Mar 11, 2017

Since most of your code runs in the browser, I was able to make time to look through the entire Python codebase of pygdbmi and gdbgui for any problems I can recognize without running the code. Here's what I found:

  1. The escapes in printcolor.py and in gdbgui.backend.dbprint and gdbgui.backend.colorize only work on Windows if the user installs ANSICON or enables Windows 10's VT100 Emulation.

    The proper solution is to depend on colorama and call colorama.init() to conditionally (it's a no-op outside Windows) monkey-patch ANSI-to-Win32 escape translation into your terminal outputs. (Or, if you don't want to add a dependency, here's a code snippet.)

    In fact, colorama gives you ready-made constants like the CYELLOW2 you define inside dbprint.

  2. gdbcontroller.py, Line 113 uses if True: where I think you meant if USING_WINDOWS: ...though, if that does work reliably on Linux, then it bodes well for Windows.

  3. The README should probably explicitly mention that the default is to expect gdb to be in the PATH, since Windows has no concept of a /usr/bin-like place to dump binaries.

  4. In gdbgui.backend, you're using the global keyword, which is considered really bad form because, given how scoping works, it's a bit of a footgun. The general "5-minute fix" recommendation is to replace your three globals with a single dict with a name like defaults or settings, since you can mutate that without global. (Also, by convention, ALL_CAPS is supposed to be equivalent to the const keyword that Python doesn't provide.)

    EDIT: I can't remember whether it's flake8 or PyLint which actually provides those specific checks, but Prospector (the open-sourced backend to Landscape.io) catches those on my system.

    I'm not familiar enough with Flask to know if there's a more idiomatic way to pass in arguments like those, but putting them in a dict would also make it much simpler to load overrides to the defaults from a config file.

  5. On gdbgui.backend, Line 57, you mention that you're using eventlet because of Flask-SocketIO issue How to open a coredump? #413, but that discussion seems to suggest that your switch from epoll() to select() to support OSX would have fixed the problem.

  6. Given the expectations of a Windows user (and just plain convenience for Linux/OSX users), I think it'd make more sense, UX-wise, to have verify_gdb_exists pop up an error overlay in the browser rather than killing gdbgui, allow the user to specify a path to the debugger right in the browser UI, and then store that on disk as an override for the default.

    The appdirs module will give you a cross-platform way to look up where to store user-specific settings (in case someone installs gdbgui system-wide, meaning no permissions to write to os.path.dirname(__file__)) and, if you don't want to depend on another package, it's explicitly built as a single module you can copy into your project.

  7. It'd probably be a good idea to support disabling the "exit GDB on disconnect" behaviour. (Ideally, as a checkbox in the UI so I can uncheck it, restart my browser or move the debugger from Firefox to Chrome or vice versa without losing work in progress, and then re-check it.)

    (I tend to leave my desktop open for weeks at a time, so I periodically run into bugs brought about by my browsers having been left running for weeks at a time, either caused directly by that or by having APT upgrades result in some kind of RPC API mismatch between the top-level process and the more transient content/plugin processes.)

@ssokolow
Copy link

ssokolow commented Mar 11, 2017

Speaking of Landscape.io, given that you seem to like badges, here are the free-for-open-source static analysis services I'm aware of which are relevant to gdbgui:

(Dependency CI, VersionEye, and Requires.io monitor various aspects of dependencies specified in your repo and pull requests, such as license conflicts and stale or insecure dependencies... which is why I mention Bower in their support lists. It'd make it a lot easier to update your vendored client-side assets when necessary.)

If you do use Bower, then also consider bitHound as an NPM/Bower-aware static analysis service for JavaScript, TypeScript, and JSX.

Finally, since I think gdbgui is awesome (aside from the license) and want it to become more popular among people producing open-source software for me to use, I'd suggest adding it to the following software listings:

  • alternativeTo (In the ddd, kdbg, and Insight listings at least)
  • BlackDuck OpenHub (Formerly Ohloh)
  • Linux-Apps.com (The desktop-neutral face of openDesktop.org)
  • SourceForge (They're desperate enough to remain relevant that they're perfectly fine getting their foot in the door by letting GitHub-hosted projects use them as a software directory.)

In the case of alternativeTo and OpenHub, 3rd-parties are allowed to create the profiles, so I could add gdbgui to them if you'd prefer that.

(As a matter of principle, I avoid becoming dependant on software which requires me to maintain a "stuff I can only use in hobby projects unless I pay" list. It's too much bother.)

EDIT: Actually, now that I think about it, I'm not sure if any of those except alternativeTo allow applications with a non-commercial clause. One of the core requirements of the open source definition (itself, a more pragmatic take on the Free Software definition) is "No Discrimination Against Fields of Endeavor". (The Debian Free Software Guidelines actually call out this specific case, phrasing it as "No discrimination against fields of endeavor, like commercial use.")

(That's why the JSLint license's "The Software shall be used for Good, not Evil." clause renders it ineligible for the "open source" label, drove the creation and widespread adoption of ESLint, kept it and projects based on it out of Google Code[1] and the Debian package repositories[2], and will ensure they never show up in the Ubuntu or Fedora package repositories.)

@cs01
Copy link
Owner

cs01 commented Mar 13, 2017

I may change the license to permit commercial use and add premium features that require a purchase.

As a matter of principle, I avoid becoming dependant on software which requires me to maintain a "stuff I can only use in hobby projects unless I pay" list. It's too much bother.

I find this ironic considering how much work I have put into this project.

@ssokolow
Copy link

ssokolow commented Mar 13, 2017

I may change the license to permit commercial use and add premium features that require a purchase.

I wouldn't have a problem with that.

I find this ironic considering how much work I have put into this project.

Hey, I'm not a hypocrite. I always charge for my time and release my personal-time source under OSI-, Debian- and FSF-approved licenses.

I just don't feel right trading something scarce (money) for something not inherently scarce (a copy of a license).

@cs01
Copy link
Owner

cs01 commented Mar 19, 2017

@ssokolow the license has been changed to GNU GPLv3.

Thanks for the other feedback. I will check out the static analysis tools.

@ssokolow
Copy link

ssokolow commented Mar 19, 2017

That definitely meets my needs.

If life stops throwing new busy-work at me, I'll probably contribute some patches of my own. (The last few months have been a pain. I've been hit with a new urgent "must migrate off a closing service/feature" announcement every month since December. This month's was DotEmu preparing to close down their store to focus on the original game-porting side of their business, which means backing up my entire library from servers where each download link functions as a nonce, so I have to play human download manager.)

@ssokolow
Copy link

ssokolow commented Mar 20, 2017

One last thing before I stop using this thread for off-topic stuff.

This morning, when I woke up, I had a "waitaminute..." moment and went to read the text of the CC BY-ND license.

It wasn't doing what you thought in the first place because, as a license intended for art and culture rather than software, it hangs all of its non-commercial restrictions on copying, performance, and derivative works. (Running pre-GPL gdbgui off a piece of removable media someone else made for no profit should bypass the copying part, leaving non-commercial use un-restricted outside of patching and screencasting/workshops/demos.)

TL;DR: All of these things are distribution licenses, not end-user licenses.

@cs01
Copy link
Owner

cs01 commented Jan 20, 2018

Native Windows support has been added. gdbgui now works with both MinGW and Cygwin.

@Settheworldonfireiii
Copy link

Settheworldonfireiii commented Aug 12, 2018

@cs01 Somewhy even after I upgraded gdbgui from Cygwin, I still get the same error:

 gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker server:app
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\gunicorn.exe\__main__.py", line 5, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\gunicorn\app\wsgiapp.py", line 9, in <module>
    from gunicorn.app.base import Application
  File "c:\programdata\anaconda3\lib\site-packages\gunicorn\app\base.py", line 12, in <module>
    from gunicorn import util
  File "c:\programdata\anaconda3\lib\site-packages\gunicorn\util.py", line 9, in <module>
    import fcntl
ModuleNotFoundError: No module named 'fcntl'

@fanguoguo
Copy link

F:\python_pro\ZKJTml>gunicorn -w 4 -b 127.0.0.1:8000 wsgi:application
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\gunicorn.exe_main
.py", line 5, in
File "c:\programdata\anaconda3\lib\site-packages\gunicorn\app\wsgiapp.py", line 9, in
from gunicorn.app.base import Application
File "c:\programdata\anaconda3\lib\site-packages\gunicorn\app\base.py", line 12, in
from gunicorn import util
File "c:\programdata\anaconda3\lib\site-packages\gunicorn\util.py", line 9, in
import fcntl
ModuleNotFoundError: No module named 'fcntl'

F:\python_pro\ZKJTml>gunicorn --workers=2 app:app
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\gunicorn.exe_main
.py", line 5, in
File "c:\programdata\anaconda3\lib\site-packages\gunicorn\app\wsgiapp.py", line 9, in
from gunicorn.app.base import Application
File "c:\programdata\anaconda3\lib\site-packages\gunicorn\app\base.py", line 12, in
from gunicorn import util
File "c:\programdata\anaconda3\lib\site-packages\gunicorn\util.py", line 9, in
import fcntl
ModuleNotFoundError: No module named 'fcntl'

@L4ZZA
Copy link

L4ZZA commented Sep 17, 2018

Same issue for me...
Win10 Pro
Python environment 3.6.6

C:\Users\Pietro\Desktop\Dev\python-getting-started (master -> origin)
pipenv shell
Loading .env environment variables...
Launching subshell in virtual environment…

C:\Users\Pietro\Desktop\Dev\python-getting-started (master -> origin)
(python-getting-started-oi_qSd27) λ heroku local
[OKAY] Loaded ENV .env File as KEY=VALUE Format
2:19:45 PM web.1 |  Traceback (most recent call last):
2:19:45 PM web.1 |    File "C:\Users\Pietro\AppData\Local\Programs\Python\Python36\Lib\runpy.py", line 193, in _run_module_as_main
2:19:45 PM web.1 |      "__main__", mod_spec)
2:19:45 PM web.1 |    File "C:\Users\Pietro\AppData\Local\Programs\Python\Python36\Lib\runpy.py", line 85, in _run_code
2:19:45 PM web.1 |      exec(code, run_globals)
2:19:45 PM web.1 |    File "C:\Users\Pietro\.virtualenvs\python-getting-started-oi_qSd27\Scripts\gunicorn.exe\__main__.py", line 5, in <module>
2:19:45 PM web.1 |    File "c:\users\pietro\.virtualenvs\python-getting-started-oi_qsd27\lib\site-packages\gunicorn\app\wsgiapp.py", line 9, in <module>
2:19:45 PM web.1 |      from gunicorn.app.base import Application
2:19:45 PM web.1 |    File "c:\users\pietro\.virtualenvs\python-getting-started-oi_qsd27\lib\site-packages\gunicorn\app\base.py", line 12, in <module>
2:19:45 PM web.1 |      from gunicorn import util
2:19:45 PM web.1 |    File "c:\users\pietro\.virtualenvs\python-getting-started-oi_qsd27\lib\site-packages\gunicorn\util.py", line 9, in <module>
2:19:45 PM web.1 |      import fcntl
2:19:45 PM web.1 |  ModuleNotFoundError: No module named 'fcntl'
[DONE] Killing all processes with signal  SIGINT
2:19:45 PM web.1 Exited with exit code null

@cs01 cs01 reopened this Sep 18, 2018
@cs01 cs01 closed this as completed Nov 5, 2018
Repository owner locked as resolved and limited conversation to collaborators Nov 5, 2018
@cs01
Copy link
Owner

cs01 commented Nov 5, 2018

If you are stil having trouble please create a new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants