andreikop / enki

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

Create cross-platform script to run Enki #162

Closed bjones1 closed 10 years ago

bjones1 commented 10 years ago

Currently, setup.py lists bin/enki as a script, but this doesn't work on Windows. Instead, should use http://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation to create a cross-platform script. I think the extra entry to setup() would be:

entry_points = {
    'gui_scripts': [
        'enki = enki.bin.enki.main',
    ]
}

and rename bin/enki to bin/enki.py.

andreikop commented 10 years ago

Hi

This solution requires setuptools. I wouldn't like to have one more dependency unless necessary. If one wants to execute enki from the sources, he might run python bin/enki, and if enki is installed to the system - it is installed as a binary.

Is it necessary to fix this problem?

andreikop commented 10 years ago

I added enki.py entry point, which is used on Windows. Is it OK now?

bjones1 commented 10 years ago

I can understand your reluctance to use setuptools. IMHO, it's a good thing because it creates an executable for Windows, allowing usage like "enki" from the command line rather than "enki.py" from the command line. However, factoring out the original enki script into main.py is a good thing. On Windows, I get one error when running the installed version:

C:\Users\bjones\Documents\enki_all\enki>enki.py Traceback (most recent call last): File "C:\Python27\Scripts\enki.py", line 15, in import enki.main File "C:\Python27\Scripts\enki.py", line 15, in import enki.main ImportError: No module named main

The enki.py script is being imported, in preference to the enki directory in site-packages. I'm not sure how to fix this search order problem without renaming enki.py to something else. However, using setuptools should fix it, since there will no longer be an enki.py (it will be turned into enki.exe).

Another problem: pyinstaller fails, with a similar error: trying to import enki.main from the enki.py script, rather than the enki module.

andreikop commented 10 years ago

Hi

I found a bug in enki.py. Could you please try now?

However, using setuptools should fix it, since there will no longer be an enki.py (it will be turned into enki.exe).

If I understand correctly, setuptools will fix situation, when Enki is installed to the system with ./setup.py install. But, is it common situation on Windows? I expect that developers will run Enki from the sources, and users will install pyinstaller generated binary

bjones1 commented 10 years ago

With the fix, I still see the same results:

On my PC, the default Python path is:

['', 'C:\Python27\lib\site-packages\pyinstaller-2.1-py2.7.egg', 'C:\Windows\system32\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', 'C:\Python27\lib\plat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27', 'C:\Python27\lib\site-packages', 'C:\Python27\lib\site-packages\FontTools', 'C:\Python27\lib\site-packages\itk', 'C:\Python27\lib\site-packages\win32', 'C:\Python27\lib\site-packages\win32\lib', 'C:\Python27\lib\site-packages\Pythonwin', 'c:\python27\lib\site-packages', 'C:\Python27\lib\site-packages\wx-2.8-msw-unicode']

bjones1 commented 10 years ago

I finally figured out how to make this work. I'll submit a pull request.

andreikop commented 10 years ago

Rename enki executable or package to avoid conflicts

andreikop commented 10 years ago

bin/enki-editor.pyw