andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 38 forks source link

Add: Docs and workarounds for building on Windows #136

Closed bjones1 closed 10 years ago

bjones1 commented 10 years ago

Some of this was hacky, but it's a necessary evil until PyInstaller handles a few more cases. In particular, pkgutil.iter_modules doesn't work under PyInstaller, breaking plugin loading. Also, some .ui loads (QWebKit in this case) fail, forcing a manual compile of the .ui and .qrc files to .py files first.

andreikop commented 10 years ago

Hi I see, that some of my optimizations doesn't work on Windows ;)

Few ideas, how to make the life on Win easier:

Plugins list

I afraid I will often forget to add plugin to the list and on Windows Enki will be released with not full plugins list. Is it possible to

  1. generate a list of plugins during ./setup.py install (modify setup.py file to do it on Windows), save as enki/plugins/list.txt
  2. include this file to package_data
  3. if system is frozen, open os.path.join(os.path.dirname(__file__), '..', 'plugins', 'list.txt') and iterate on it ?

uic and Lazy imports

If I understand correctly, uic doesn't work because import is lazy. I done lazy uic imports sometimes because it decreased startup time. But this little optimization not worth hacks on Windows. I removed it, rebase onto my master and try to remove your hack.

Btw, there are few lazy imports in enki/plugins/preview/preview.py. They also won't work probably. Do you have an idea how to workaround it?

Icons file

enkiicons.qrc is already compiled to enki/resources/icons.py and is loaded during startup. Did you understand, why it is necessary to create file enkiicons_rc.py on Windows? There are few other .ui files, which use enkiicons.rc (but not during startup). Try to open Help -> About

bjones1 commented 10 years ago

Andrei,

Thanks for the detailed answer and your ideas. I've replied in-line with your comments below.

Bryan

On Mon, Nov 25, 2013 at 12:44 AM, Andrei Kopats notifications@github.comwrote:

Hi I see, that some of my optimizations doesn't work on Windows ;)

Few ideas, how to make the life on Win easier: Plugins list

I afraid I will often forget to add plugin to the list and on Windows Enki will be released with not full plugins list. Is it possible to

I agree -- that's easy to overlook. This is obviously a Pyinstaller bug; it's weak when dealing with hidden imports, since the filesystem gets compressed into a single file holding all Python .pyc files. Let me see if the Pyinstaller team is interested in fixing this; they're pretty responsive. If so, I'd suggest leaving the ugly hack for a bit then using a fixed version of Pyinstaller. If not, your idea below sounds reasonable.

  1. generate a list of plugins during ./setup.py install (modify setup.py file to do it on Windows), save as enki/plugins/list.txt
  2. include this file to package_data
  3. if system is frozen, open os.path.join(os.path.dirname(file), '..', 'plugins', 'list.txt') and iterate on it ? uic and Lazy imports

If I understand correctly, uic doesn't work because import is lazy.

No, it seems that PyInstaller interacts in some strange way with uic.loadUi when loading widgets outside QtGui. It doesn't matter when this happens; CodeChat loads its QScintilla widget at start-up, and still needs a work-around. Now that I better understand the source of this bug, let me see if I can (again) work with the PyInstaller team to get it fixed. Your changes produce a different failure (instead of an exception, the Preview window states 'No preview for this type of file' for BUILD.md, which works when not running the PyInstaller binary). You might consider backing these changes out, since they don't seem to help.

I done lazy uic imports sometimes because it decreased startup time. But this little optimization not worth hacks on Windows. I removed it, rebase onto my master and try to remove your hack.

Btw, there are few lazy imports in enki/plugins/preview/preview.py. They also won't work probably. Do you have an idea how to workaround it? Icons file

enkiicons.qrc is already compiled to enki/resources/icons.py and is loaded during startup. Did you understand, why it is necessary to create file enkiicons_rc.py on Windows? There are few other .ui files, which use enkiicons.rc (but not during startup). Try to open Help -> About

Oops, I missed that -- I didn't realize you'd already done it. I haven't used qrc files, so I'm less familiar with their operation. I understand it's necessary to get access to icons, etc. used in a .ui file, and the import is autogenerated by pyuic4. Let me see if there's a workaround for this.

— Reply to this email directly or view it on GitHubhttps://github.com/hlamer/enki/pull/136#issuecomment-29180732 .

Bryan A. Jones, Ph.D. Associate Professor Department of Electrical and Computer Engineering 231 Simrall / PO Box 9571 Mississippi State University Mississippi state, MS 39762 http://www.ece.msstate.edu/~bjones bjones AT ece DOT msstate DOT edu voice 662-325-3149 fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on time, his arrival guaranteed by the Blessed and Undisputed Ruler, High King, High God.

bjones1 commented 10 years ago

Andrei,

Oops, and update on the uic and lazy import: my testing was wrong; I'd forgotten to remove some .pyc files. Fixed and tested with your changes, the errors are the same as before. Note the problem: the module should be PyQt4.QtWebKit.QtWebView, but the PyQt4 prefix somehow gets omitted when running a Pyinstaller binary. For example:

CRITICAL:root:Traceback (most recent call last): File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\enki.plugins.preview", line 58, in _onDocumentChanged File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\enki.plugins.preview", line 92, in _createDock File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\enki.plugins.preview.preview", line 131, in init File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic", line 223, in loadUi File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.Loader.loader", line 71, in loadUi File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 931, in parse File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 772, in createUserInterface File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 750, in traverseWidgetTree File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 461, in createLayout File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 750, in traverseWidgetTree File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 504, in handleItem File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 750, in traverseWidgetTree File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 215, in createWidget File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.uiparser", line 176, in setupObject File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.objcreator", line 106, in createQObject File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.objcreator", line 131, in findQObjectType File "C:\Users\bjones\Documents\enki_all\enki\build\enki\out00-PYZ.pyz\PyQt4.uic.Loader.qobjectcreator", line 107, in search ImportError: No module named QtWebKit.QWebView

Bryan

On Mon, Nov 25, 2013 at 11:59 AM, Bryan A. Jones bjones@ece.msstate.eduwrote:

Andrei,

Thanks for the detailed answer and your ideas. I've replied in-line with your comments below.

Bryan

On Mon, Nov 25, 2013 at 12:44 AM, Andrei Kopats notifications@github.comwrote:

Hi I see, that some of my optimizations doesn't work on Windows ;)

Few ideas, how to make the life on Win easier: Plugins list

I afraid I will often forget to add plugin to the list and on Windows Enki will be released with not full plugins list. Is it possible to

I agree -- that's easy to overlook. This is obviously a Pyinstaller bug; it's weak when dealing with hidden imports, since the filesystem gets compressed into a single file holding all Python .pyc files. Let me see if the Pyinstaller team is interested in fixing this; they're pretty responsive. If so, I'd suggest leaving the ugly hack for a bit then using a fixed version of Pyinstaller. If not, your idea below sounds reasonable.

  1. generate a list of plugins during ./setup.py install (modify setup.py file to do it on Windows), save as enki/plugins/list.txt
  2. include this file to package_data
  3. if system is frozen, open os.path.join(os.path.dirname(file), '..', 'plugins', 'list.txt') and iterate on it ? uic and Lazy imports

If I understand correctly, uic doesn't work because import is lazy.

No, it seems that PyInstaller interacts in some strange way with uic.loadUi when loading widgets outside QtGui. It doesn't matter when this happens; CodeChat loads its QScintilla widget at start-up, and still needs a work-around. Now that I better understand the source of this bug, let me see if I can (again) work with the PyInstaller team to get it fixed. Your changes produce a different failure (instead of an exception, the Preview window states 'No preview for this type of file' for BUILD.md, which works when not running the PyInstaller binary). You might consider backing these changes out, since they don't seem to help.

I done lazy uic imports sometimes because it decreased startup time. But this little optimization not worth hacks on Windows. I removed it, rebase onto my master and try to remove your hack.

Btw, there are few lazy imports in enki/plugins/preview/preview.py. They also won't work probably. Do you have an idea how to workaround it? Icons file

enkiicons.qrc is already compiled to enki/resources/icons.py and is loaded during startup. Did you understand, why it is necessary to create file enkiicons_rc.py on Windows? There are few other .ui files, which use enkiicons.rc (but not during startup). Try to open Help -> About

Oops, I missed that -- I didn't realize you'd already done it. I haven't used qrc files, so I'm less familiar with their operation. I understand it's necessary to get access to icons, etc. used in a .ui file, and the import is autogenerated by pyuic4. Let me see if there's a workaround for this.

— Reply to this email directly or view it on GitHubhttps://github.com/hlamer/enki/pull/136#issuecomment-29180732 .

Bryan A. Jones, Ph.D. Associate Professor Department of Electrical and Computer Engineering 231 Simrall / PO Box 9571 Mississippi State University Mississippi state, MS 39762 http://www.ece.msstate.edu/~bjones bjones AT ece DOT msstate DOT edu voice 662-325-3149 fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on time, his arrival guaranteed by the Blessed and Undisputed Ruler, High King, High God.

  • 1 Tim. 6:14b-15 (The Message)

Bryan A. Jones, Ph.D. Associate Professor Department of Electrical and Computer Engineering 231 Simrall / PO Box 9571 Mississippi State University Mississippi state, MS 39762 http://www.ece.msstate.edu/~bjones bjones AT ece DOT msstate DOT edu voice 662-325-3149 fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on time, his arrival guaranteed by the Blessed and Undisputed Ruler, High King, High God.