Merge lp:~maphew/leo-editor/pypi-packaging into lp:leo-editor

Proposed by Matt Wilkie
Status: Merged
Merged at revision: 5778
Proposed branch: lp:~maphew/leo-editor/pypi-packaging
Merge into: lp:leo-editor
Diff against target: 257 lines (+179/-15)
5 files modified
build-leo.bat (+6/-0)
create-leobat.bat (+68/-0)
leo/config/leoSettings.leo (+1/-1)
register-leo.leos (+83/-0)
setup.py (+21/-14)
To merge this branch: bzr merge lp:~maphew/leo-editor/pypi-packaging
Reviewer Review Type Date Requested Status
The Leo editor team Pending
Review via email: mp+163277@code.launchpad.net

Description of the change

See commit log for details.

The "register-leo.leos" leo script is the least tested part and should be reviewed most closely. If it works widely, it obviates the need for "create-leobat.bat ... register" to register file type, and consolidates setting the filetype and Explorer icon into a single package.

To post a comment you must log in.
Revision history for this message
Edward K. Ream (edreamleo) wrote :

On Fri, May 10, 2013 at 3:55 AM, Matt Wilkie <email address hidden> wrote:

> Matt Wilkie has proposed merging lp:~maphew/leo-editor/pypi-packaging into
> lp:leo-editor.
>

Go ahead. The script will be a starting point. Not sure what I think
about .leos (Leo script) file extension: it's just a .py file.

Edward

Revision history for this message
Jake Peck (gatesphere) wrote :

On 5/10/2013 7:25 AM, Edward K. Ream wrote:
> On Fri, May 10, 2013 at 3:55 AM, Matt Wilkie <email address hidden> wrote:
>
>> Matt Wilkie has proposed merging lp:~maphew/leo-editor/pypi-packaging into
>> lp:leo-editor.
>>
> Go ahead. The script will be a starting point. Not sure what I think
> about .leos (Leo script) file extension: it's just a .py file.
>
> Edward
>
I agree, w/r/t the .leos extension - just do .py, and perhaps have a
guard in the `if __name__ == '__main__':` bit... perhaps check for the
existence of g.app? If it's not found, print a message stating that
"This script needs to be run from Leo!" and exit.

-->Jake

Revision history for this message
Matt Wilkie (maphew) wrote :

> Go ahead.

ok, thanks.

> The script will be a starting point. Not sure what I think
> about .leos (Leo script) file extension: it's just a .py file.

yeah, it's a .py file, but you can't use it unless you're inside Leo. I
just wanted an easy way to tell the difference between a Leo script and
regular python module without having to inspect it.

-matt

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'build-leo.bat'
2--- build-leo.bat 1970-01-01 00:00:00 +0000
3+++ build-leo.bat 2013-05-10 08:54:30 +0000
4@@ -0,0 +1,6 @@
5+#@+leo-ver=5-thin
6+#@+node:maphew.20130505160115.1636: * @file leo-editor/build-leo.bat
7+python setup.py sdist
8+python setup.py bdist_wininst --user-access-control=auto --bitmap leo\Icons\SplashScreen-installer.bmp
9+start dist
10+#@-leo
11
12=== added file 'create-leobat.bat'
13--- create-leobat.bat 1970-01-01 00:00:00 +0000
14+++ create-leobat.bat 2013-05-10 08:54:30 +0000
15@@ -0,0 +1,68 @@
16+@echo off
17+:: A batch file which generates other batch files to run the Leo Editor,
18+:: adapted for the local machine. Optionally, it will also set the Windows
19+:: filetype and association so .leo files can be opened from Explorer.
20+::
21+:: It needs to live in the same folder as "launchLeo.py"
22+::
23+:: Open Source X/MIT License
24+:: initial version * 2012-Dec-13 * matt wilkie <maphew@gmail.com>
25+
26+if "%1"=="" goto :Usage
27+
28+call :pyCheck %1
29+call :main %1
30+if "%2"=="register" call :register %1
31+goto :eof
32+
33+:main
34+ :: %1 is the path to folder containing python .exe's
35+ set pyexe=%~dp1python.exe
36+ set pywexe=%~dp1pythonw.exe
37+ echo.
38+ echo. Generating...
39+ echo.
40+ echo. Leo.bat - run leo in Windows mode
41+ echo. Leoc.bat - run leo and keep console window open
42+ echo.
43+ echo. These can be placed anywhere in PATH.
44+ echo.
45+ echo @"%pyexe%" "%~dp0launchLeo.py" %%* > leoc.bat
46+ echo @start /b "Leo" "%pywexe%" "%~dp0launchLeo.py" %%* > leo.bat
47+ goto :eof
48+
49+:register
50+ :: perms check courtesy of http://stackoverflow.com/questions/4051883
51+ :: batch-script-how-to-check-for-admin-rights
52+ net session >nul 2>&1
53+ if %errorlevel% == 0 (
54+ echo.
55+ echo. Setting .leo filetype and registering association with Windows
56+ echo.
57+ assoc .leo=Leo.File
58+ ftype Leo.File=%pywexe% "%~dp0launchLeo.py" "%%1" %%*
59+ ) else (
60+ echo. Error: Can't set filetype and register association.
61+ echo. Please run from elevated shell to do that.
62+ echo.
63+ )
64+ goto :eof
65+
66+:pyCheck
67+ if not exist "%1" goto :Usage
68+ goto :eof
69+
70+:usage
71+ echo.
72+ echo. -=[%~nx0]=-
73+ echo.
74+ echo. Create batch files to launch Leo Editor that can be
75+ echo. placed and run from anywhere on this machine.
76+ echo.
77+ echo. and optionally register filetype with windows
78+ echo.
79+ echo. Usage:
80+ echo. %~n0 "c:\path\to\python.exe"
81+ echo. %~n0 "c:\path\to\python.exe" register
82+ echo.
83+ goto :eof
84
85=== added file 'leo/Icons/SplashScreen-installer.bmp'
86Binary files leo/Icons/SplashScreen-installer.bmp 1970-01-01 00:00:00 +0000 and leo/Icons/SplashScreen-installer.bmp 2013-05-10 08:54:30 +0000 differ
87=== added file 'leo/Icons/SplashScreen.xcf'
88Binary files leo/Icons/SplashScreen.xcf 1970-01-01 00:00:00 +0000 and leo/Icons/SplashScreen.xcf 2013-05-10 08:54:30 +0000 differ
89=== modified file 'leo/config/leoSettings.leo'
90--- leo/config/leoSettings.leo 2013-05-04 12:33:40 +0000
91+++ leo/config/leoSettings.leo 2013-05-10 08:54:30 +0000
92@@ -4464,7 +4464,7 @@
93
94 # Alphabetical list of all Leo plugins.
95
96-# active_path.py
97+active_path.py
98 # add_directives.py
99 # at_folder.py
100 # at_produce.py
101
102=== added file 'register-leo.leos'
103--- register-leo.leos 1970-01-01 00:00:00 +0000
104+++ register-leo.leos 2013-05-10 08:54:30 +0000
105@@ -0,0 +1,83 @@
106+#@+leo-ver=5-thin
107+#@+node:maphew.20130501121440.1885: * @file register-leo.leos
108+#@@language python
109+#@@tabwidth -4
110+#@+others
111+#@+node:maphew.20130510011223.1645: ** docstring
112+'''Tell Windows how to handle .leo files, enables double clicking on them to open.
113+
114+To run: in Leo make this the active node and press [Ctrl-B] (execute-script)
115+
116+Requires elevated User Account Control (UAC) privileges.
117+See http://superuser.com/questions/88491/force-cmd-exe-to-run-as-admin/
118+'''
119+#@+node:maphew.20130509185752.1607: ** register_leo
120+def register_leo(pyexe, launchLeo, icon):
121+ '''Create registry key for Leo file type, set default icon, and launch command
122+
123+ Resources:
124+ http://stackoverflow.com/questions/2331690/how-to-set-a-icon-file-while-creating-file
125+ http://stackoverflow.com/questions/771689/how-can-i-set-an-icon-for-my-own-file-extension
126+ '''
127+ g.es("\nAttempting to register leo filetype with Windows...")
128+
129+ if g.os_path_exists(icon):
130+ g.es("Found:", icon)
131+
132+ leoKey = CreateKey(HKEY_CLASSES_ROOT, "Leo.File")
133+ iconKey = CreateKey(leoKey, "DefaultIcon")
134+ shellKey = CreateKey(leoKey, "Shell")
135+ openKey = CreateKey(shellKey, "Open")
136+ cmdKey = CreateKey(openKey, "Command")
137+
138+ SetValue(leoKey, None, REG_SZ, "Leo Editor File")
139+ SetValue(iconKey, None, REG_SZ, icon)
140+ SetValueEx(cmdKey, None, None, REG_EXPAND_SZ, '"{0}" "{1}" "%1" %*'.format(pywexe, launchLeo))
141+
142+ for k in (leoKey, iconKey, shellKey, openKey, cmdKey):
143+ CloseKey(k)
144+
145+ g.es("Registered!")
146+ else:
147+ g.es("LeoDoc.ico not in expected location, can't continue.")
148+#@+node:maphew.20130510011223.1646: *3* sample registry outcome
149+'''This is what the resulting registry key should look like, once exported from
150+regedit. The translated hex code is:
151+
152+ "d:\Python27\python.exe" "C:\Users\Matt\Dropbox\apps\leo-editor\launchLeo.py" "%1" %*
153+
154+'''
155+#@+at
156+# Windows Registry Editor Version 5.00
157+#
158+# [HKEY_CLASSES_ROOT\Leo.File]
159+# @="Leo Editor File"
160+#
161+# [HKEY_CLASSES_ROOT\Leo.File\DefaultIcon]
162+# @="C:\\Users\\Matt\\Dropbox\\apps\\leo-editor\\leo\\Icons\\LeoDoc.ico"
163+#
164+# [HKEY_CLASSES_ROOT\Leo.File\Shell]
165+#
166+# [HKEY_CLASSES_ROOT\Leo.File\Shell\Open]
167+#
168+# [HKEY_CLASSES_ROOT\Leo.File\Shell\Open\Command]
169+# @=hex(2):22,00,64,00,3a,00,5c,00,50,00,79,00,74,00,68,00,6f,00,6e,00,32,00,37,\
170+# 00,5c,00,70,00,79,00,74,00,68,00,6f,00,6e,00,2e,00,65,00,78,00,65,00,22,00,\
171+# 20,00,22,00,43,00,3a,00,5c,00,55,00,73,00,65,00,72,00,73,00,5c,00,4d,00,61,\
172+# 00,74,00,74,00,5c,00,44,00,72,00,6f,00,70,00,62,00,6f,00,78,00,5c,00,61,00,\
173+# 70,00,70,00,73,00,5c,00,6c,00,65,00,6f,00,2d,00,65,00,64,00,69,00,74,00,6f,\
174+# 00,72,00,5c,00,6c,00,61,00,75,00,6e,00,63,00,68,00,4c,00,65,00,6f,00,2e,00,\
175+# 70,00,79,00,22,00,20,00,22,00,25,00,31,00,22,00,20,00,25,00,2a,00,00,00
176+#@-others
177+from _winreg import *
178+
179+pyexe = g.sys.executable
180+pywexe = pyexe.replace('python.exe', 'pythonw.exe')
181+launchLeo = g.os_path_finalize_join(g.computeLeoDir(), '../launchLeo.py')
182+icon = "%s\Icons\LeoDoc.ico" % g.computeLeoDir()
183+
184+g.es(pywexe)
185+g.es(launchLeo)
186+
187+register_leo(pyexe, launchLeo, icon)
188+#@-leo
189
190=== modified file 'setup.py'
191--- setup.py 2013-04-18 19:54:01 +0000
192+++ setup.py 2013-05-10 08:54:30 +0000
193@@ -19,6 +19,21 @@
194 from distutils.command.install_data import install_data
195 from distutils.command.install import INSTALL_SCHEMES
196 import os,fnmatch
197+#@+node:maphew.20130503222911.1635: ** Get description
198+try:
199+ long_description = open('README.TXT', 'rt').read()
200+except IOError:
201+ long_description = """
202+Leo is an outline-oriented IDE written in 100% pure Python.
203+Leo features a multi-window outlining editor, Python colorizing,
204+powerful outline commands and many other things, including
205+unlimited Undo/Redo and an integrated Python shell(IDLE) window.
206+Leo requires Python 2.6 or above. Leo works with Python 3.x.
207+Requires PyQt and SIP preinstalled.
208+ """
209+#@+node:maphew.20130508020338.1645: ** Get version
210+import leo
211+version = '{0}-build-{1}'.format(leo.core.leoVersion.version, leo.core.leoVersion.build)
212 #@+node:ville.20090213231648.3: ** fullsplit
213 import sys
214
215@@ -91,7 +106,6 @@
216 file_info[0] = '\\PURELIB\\%s' % file_info[0]
217 #@-others
218
219-
220 # Note than only *.ui matches now - add asterisks as needed/valid
221 datapats = ['.tix', '.GIF', '.dbm', '.conf', '.TXT', '.xml', '.gif', '*.leo', '.def', '.svg', '*.ini', '.six', '.bat', '.cat', '.pro', '.sh', '.xsl', '.bmp', '.js', '*.ui', '.rix', '.pmsp', '.pyd', '.png', '.alg', '.php', '.css', '.ico', '*.txt', '.html', '.iix', '.w']
222 #print data_files
223@@ -100,28 +114,21 @@
224 # https://testpypi.python.org/pypi?name=leo-editor&version=4.10-final&:action=submit_form
225 setup(
226 name = 'leo-editor',
227- version = "4.10-final",
228+ version = version,
229 author = "Edward K. Ream",
230 author_email = 'edreamleo@gmail.com',
231- #maintainer = '',
232- #maintainer_email = '',
233+ maintainer = 'Matt Wilkie',
234+ maintainer_email = 'maphew@gmail.com',
235 url = 'http://leoeditor.com',
236 license = 'MIT License',
237 description = "Leonine Editor with Outlines",
238- long_description = """
239-Leo is an outline-oriented IDE written in 100% pure Python.
240-Leo features a multi-window outlining editor, Python colorizing,
241-powerful outline commands and many other things, including
242-unlimited Undo/Redo and an integrated Python shell(IDLE) window.
243-Leo requires Python 2.6 or above. Leo works with Python 3.x.
244-Requires PyQt and SIP preinstalled.
245- """,
246+ long_description = long_description,
247 #keywords = [],
248 platforms = ['linux','windows'],
249- download_url = 'http://sourceforge.net/projects/leo/files/Leo/4.10%20final/Leo-4.10-final.zip/download',
250+ download_url = 'http://sourceforge.net/projects/leo/files/Leo/',
251 #bugtrack_url = 'https://bugs.launchpad.net/leo-editor', #only py3?
252
253- # only include dependencies which can be installed by pip
254+ # only include dependencies which can be installed by pip (so not PyQt or SIP)
255 requires = ['docutils'],
256
257 #provides = [],

Subscribers

People subscribed via source and target branches