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