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
=== added file 'build-leo.bat'
--- build-leo.bat 1970-01-01 00:00:00 +0000
+++ build-leo.bat 2013-05-10 08:54:30 +0000
@@ -0,0 +1,6 @@
1#@+leo-ver=5-thin
2#@+node:maphew.20130505160115.1636: * @file leo-editor/build-leo.bat
3python setup.py sdist
4python setup.py bdist_wininst --user-access-control=auto --bitmap leo\Icons\SplashScreen-installer.bmp
5start dist
6#@-leo
07
=== added file 'create-leobat.bat'
--- create-leobat.bat 1970-01-01 00:00:00 +0000
+++ create-leobat.bat 2013-05-10 08:54:30 +0000
@@ -0,0 +1,68 @@
1@echo off
2:: A batch file which generates other batch files to run the Leo Editor,
3:: adapted for the local machine. Optionally, it will also set the Windows
4:: filetype and association so .leo files can be opened from Explorer.
5::
6:: It needs to live in the same folder as "launchLeo.py"
7::
8:: Open Source X/MIT License
9:: initial version * 2012-Dec-13 * matt wilkie <maphew@gmail.com>
10
11if "%1"=="" goto :Usage
12
13call :pyCheck %1
14call :main %1
15if "%2"=="register" call :register %1
16goto :eof
17
18:main
19 :: %1 is the path to folder containing python .exe's
20 set pyexe=%~dp1python.exe
21 set pywexe=%~dp1pythonw.exe
22 echo.
23 echo. Generating...
24 echo.
25 echo. Leo.bat - run leo in Windows mode
26 echo. Leoc.bat - run leo and keep console window open
27 echo.
28 echo. These can be placed anywhere in PATH.
29 echo.
30 echo @"%pyexe%" "%~dp0launchLeo.py" %%* > leoc.bat
31 echo @start /b "Leo" "%pywexe%" "%~dp0launchLeo.py" %%* > leo.bat
32 goto :eof
33
34:register
35 :: perms check courtesy of http://stackoverflow.com/questions/4051883
36 :: batch-script-how-to-check-for-admin-rights
37 net session >nul 2>&1
38 if %errorlevel% == 0 (
39 echo.
40 echo. Setting .leo filetype and registering association with Windows
41 echo.
42 assoc .leo=Leo.File
43 ftype Leo.File=%pywexe% "%~dp0launchLeo.py" "%%1" %%*
44 ) else (
45 echo. Error: Can't set filetype and register association.
46 echo. Please run from elevated shell to do that.
47 echo.
48 )
49 goto :eof
50
51:pyCheck
52 if not exist "%1" goto :Usage
53 goto :eof
54
55:usage
56 echo.
57 echo. -=[%~nx0]=-
58 echo.
59 echo. Create batch files to launch Leo Editor that can be
60 echo. placed and run from anywhere on this machine.
61 echo.
62 echo. and optionally register filetype with windows
63 echo.
64 echo. Usage:
65 echo. %~n0 "c:\path\to\python.exe"
66 echo. %~n0 "c:\path\to\python.exe" register
67 echo.
68 goto :eof
069
=== added file 'leo/Icons/SplashScreen-installer.bmp'
1Binary 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 differ70Binary 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
=== added file 'leo/Icons/SplashScreen.xcf'
2Binary files leo/Icons/SplashScreen.xcf 1970-01-01 00:00:00 +0000 and leo/Icons/SplashScreen.xcf 2013-05-10 08:54:30 +0000 differ71Binary 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
=== modified file 'leo/config/leoSettings.leo'
--- leo/config/leoSettings.leo 2013-05-04 12:33:40 +0000
+++ leo/config/leoSettings.leo 2013-05-10 08:54:30 +0000
@@ -4464,7 +4464,7 @@
44644464
4465# Alphabetical list of all Leo plugins.4465# Alphabetical list of all Leo plugins.
44664466
4467# active_path.py4467active_path.py
4468# add_directives.py4468# add_directives.py
4469# at_folder.py4469# at_folder.py
4470# at_produce.py4470# at_produce.py
44714471
=== added file 'register-leo.leos'
--- register-leo.leos 1970-01-01 00:00:00 +0000
+++ register-leo.leos 2013-05-10 08:54:30 +0000
@@ -0,0 +1,83 @@
1#@+leo-ver=5-thin
2#@+node:maphew.20130501121440.1885: * @file register-leo.leos
3#@@language python
4#@@tabwidth -4
5#@+others
6#@+node:maphew.20130510011223.1645: ** docstring
7'''Tell Windows how to handle .leo files, enables double clicking on them to open.
8
9To run: in Leo make this the active node and press [Ctrl-B] (execute-script)
10
11Requires elevated User Account Control (UAC) privileges.
12See http://superuser.com/questions/88491/force-cmd-exe-to-run-as-admin/
13'''
14#@+node:maphew.20130509185752.1607: ** register_leo
15def register_leo(pyexe, launchLeo, icon):
16 '''Create registry key for Leo file type, set default icon, and launch command
17
18 Resources:
19 http://stackoverflow.com/questions/2331690/how-to-set-a-icon-file-while-creating-file
20 http://stackoverflow.com/questions/771689/how-can-i-set-an-icon-for-my-own-file-extension
21 '''
22 g.es("\nAttempting to register leo filetype with Windows...")
23
24 if g.os_path_exists(icon):
25 g.es("Found:", icon)
26
27 leoKey = CreateKey(HKEY_CLASSES_ROOT, "Leo.File")
28 iconKey = CreateKey(leoKey, "DefaultIcon")
29 shellKey = CreateKey(leoKey, "Shell")
30 openKey = CreateKey(shellKey, "Open")
31 cmdKey = CreateKey(openKey, "Command")
32
33 SetValue(leoKey, None, REG_SZ, "Leo Editor File")
34 SetValue(iconKey, None, REG_SZ, icon)
35 SetValueEx(cmdKey, None, None, REG_EXPAND_SZ, '"{0}" "{1}" "%1" %*'.format(pywexe, launchLeo))
36
37 for k in (leoKey, iconKey, shellKey, openKey, cmdKey):
38 CloseKey(k)
39
40 g.es("Registered!")
41 else:
42 g.es("LeoDoc.ico not in expected location, can't continue.")
43#@+node:maphew.20130510011223.1646: *3* sample registry outcome
44'''This is what the resulting registry key should look like, once exported from
45regedit. The translated hex code is:
46
47 "d:\Python27\python.exe" "C:\Users\Matt\Dropbox\apps\leo-editor\launchLeo.py" "%1" %*
48
49'''
50#@+at
51# Windows Registry Editor Version 5.00
52#
53# [HKEY_CLASSES_ROOT\Leo.File]
54# @="Leo Editor File"
55#
56# [HKEY_CLASSES_ROOT\Leo.File\DefaultIcon]
57# @="C:\\Users\\Matt\\Dropbox\\apps\\leo-editor\\leo\\Icons\\LeoDoc.ico"
58#
59# [HKEY_CLASSES_ROOT\Leo.File\Shell]
60#
61# [HKEY_CLASSES_ROOT\Leo.File\Shell\Open]
62#
63# [HKEY_CLASSES_ROOT\Leo.File\Shell\Open\Command]
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,\
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,\
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,\
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,\
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,\
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,\
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
71#@-others
72from _winreg import *
73
74pyexe = g.sys.executable
75pywexe = pyexe.replace('python.exe', 'pythonw.exe')
76launchLeo = g.os_path_finalize_join(g.computeLeoDir(), '../launchLeo.py')
77icon = "%s\Icons\LeoDoc.ico" % g.computeLeoDir()
78
79g.es(pywexe)
80g.es(launchLeo)
81
82register_leo(pyexe, launchLeo, icon)
83#@-leo
084
=== modified file 'setup.py'
--- setup.py 2013-04-18 19:54:01 +0000
+++ setup.py 2013-05-10 08:54:30 +0000
@@ -19,6 +19,21 @@
19from distutils.command.install_data import install_data19from distutils.command.install_data import install_data
20from distutils.command.install import INSTALL_SCHEMES20from distutils.command.install import INSTALL_SCHEMES
21import os,fnmatch21import os,fnmatch
22#@+node:maphew.20130503222911.1635: ** Get description
23try:
24 long_description = open('README.TXT', 'rt').read()
25except IOError:
26 long_description = """
27Leo is an outline-oriented IDE written in 100% pure Python.
28Leo features a multi-window outlining editor, Python colorizing,
29powerful outline commands and many other things, including
30unlimited Undo/Redo and an integrated Python shell(IDLE) window.
31Leo requires Python 2.6 or above. Leo works with Python 3.x.
32Requires PyQt and SIP preinstalled.
33 """
34#@+node:maphew.20130508020338.1645: ** Get version
35import leo
36version = '{0}-build-{1}'.format(leo.core.leoVersion.version, leo.core.leoVersion.build)
22#@+node:ville.20090213231648.3: ** fullsplit37#@+node:ville.20090213231648.3: ** fullsplit
23import sys38import sys
2439
@@ -91,7 +106,6 @@
91 file_info[0] = '\\PURELIB\\%s' % file_info[0]106 file_info[0] = '\\PURELIB\\%s' % file_info[0]
92#@-others107#@-others
93108
94
95# Note than only *.ui matches now - add asterisks as needed/valid109# Note than only *.ui matches now - add asterisks as needed/valid
96datapats = ['.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']110datapats = ['.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']
97#print data_files111#print data_files
@@ -100,28 +114,21 @@
100# https://testpypi.python.org/pypi?name=leo-editor&version=4.10-final&:action=submit_form114# https://testpypi.python.org/pypi?name=leo-editor&version=4.10-final&:action=submit_form
101setup(115setup(
102 name = 'leo-editor',116 name = 'leo-editor',
103 version = "4.10-final",117 version = version,
104 author = "Edward K. Ream",118 author = "Edward K. Ream",
105 author_email = 'edreamleo@gmail.com',119 author_email = 'edreamleo@gmail.com',
106 #maintainer = '',120 maintainer = 'Matt Wilkie',
107 #maintainer_email = '',121 maintainer_email = 'maphew@gmail.com',
108 url = 'http://leoeditor.com',122 url = 'http://leoeditor.com',
109 license = 'MIT License',123 license = 'MIT License',
110 description = "Leonine Editor with Outlines",124 description = "Leonine Editor with Outlines",
111 long_description = """125 long_description = long_description,
112Leo is an outline-oriented IDE written in 100% pure Python.
113Leo features a multi-window outlining editor, Python colorizing,
114powerful outline commands and many other things, including
115unlimited Undo/Redo and an integrated Python shell(IDLE) window.
116Leo requires Python 2.6 or above. Leo works with Python 3.x.
117Requires PyQt and SIP preinstalled.
118 """,
119 #keywords = [],126 #keywords = [],
120 platforms = ['linux','windows'],127 platforms = ['linux','windows'],
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/',
122 #bugtrack_url = 'https://bugs.launchpad.net/leo-editor', #only py3?129 #bugtrack_url = 'https://bugs.launchpad.net/leo-editor', #only py3?
123130
124 # only include dependencies which can be installed by pip131 # only include dependencies which can be installed by pip (so not PyQt or SIP)
125 requires = ['docutils'],132 requires = ['docutils'],
126133
127 #provides = [],134 #provides = [],

Subscribers

People subscribed via source and target branches