Merge pull request #100 from singingwolfboy/py3
Document Python 3 support
This commit is contained in:
commit
63551fca17
|
@ -1,5 +1,5 @@
|
||||||
language: python
|
language: python
|
||||||
python: 2.7
|
python: 3.5
|
||||||
install:
|
install:
|
||||||
- "pip install -U pip"
|
- "pip install -U pip"
|
||||||
- "pip install git+https://github.com/lektor/lektor#egg=Lektor"
|
- "pip install git+https://github.com/lektor/lektor#egg=Lektor"
|
||||||
|
|
|
@ -23,15 +23,19 @@ LRESULT = LPARAM
|
||||||
HWND_BROADCAST = 0xFFFF
|
HWND_BROADCAST = 0xFFFF
|
||||||
WM_SETTINGCHANGE = 0x1A
|
WM_SETTINGCHANGE = 0x1A
|
||||||
|
|
||||||
|
PY2 = sys.version_info[0] == 2
|
||||||
|
if PY2:
|
||||||
|
input = raw_input
|
||||||
|
|
||||||
|
|
||||||
def get_confirmation():
|
def get_confirmation():
|
||||||
while 1:
|
while 1:
|
||||||
input = raw_input('Continue? [Yn] ').lower().strip()
|
user_input = input('Continue? [Yn] ').lower().strip()
|
||||||
if input in ('', 'y'):
|
if user_input in ('', 'y'):
|
||||||
break
|
break
|
||||||
elif input == 'n':
|
elif user_input == 'n':
|
||||||
print
|
print()
|
||||||
print 'Aborted!'
|
print('Aborted!')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def find_location():
|
def find_location():
|
||||||
|
@ -39,9 +43,9 @@ def find_location():
|
||||||
return install_dir, os.path.join(install_dir, LIB)
|
return install_dir, os.path.join(install_dir, LIB)
|
||||||
|
|
||||||
def deletion_error(func, path, excinfo):
|
def deletion_error(func, path, excinfo):
|
||||||
print 'Problem deleting {}'.format(path)
|
print('Problem deleting {}'.format(path))
|
||||||
print 'Please try and delete {} manually'.format(path)
|
print('Please try and delete {} manually'.format(path))
|
||||||
print 'Aborted!'
|
print('Aborted!')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def wipe_installation(install_dir):
|
def wipe_installation(install_dir):
|
||||||
|
@ -49,16 +53,16 @@ def wipe_installation(install_dir):
|
||||||
|
|
||||||
def check_installation(install_dir):
|
def check_installation(install_dir):
|
||||||
if os.path.exists(install_dir):
|
if os.path.exists(install_dir):
|
||||||
print ' Lektor seems to be installed already.'
|
print(' Lektor seems to be installed already.')
|
||||||
print ' Continuing will delete:'
|
print(' Continuing will delete:')
|
||||||
print ' %s' % install_dir
|
print(' %s' % install_dir)
|
||||||
print
|
print()
|
||||||
get_confirmation()
|
get_confirmation()
|
||||||
print
|
print()
|
||||||
wipe_installation(install_dir)
|
wipe_installation(install_dir)
|
||||||
|
|
||||||
def fail(message):
|
def fail(message):
|
||||||
print 'Error: %s' % message
|
print('Error: %s' % message)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def add_to_path(location):
|
def add_to_path(location):
|
||||||
|
@ -108,19 +112,19 @@ def install(virtualenv_url, virtualenv_filename, install_dir, lib_dir):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print
|
print()
|
||||||
print 'Welcome to Lektor'
|
print('Welcome to Lektor')
|
||||||
print
|
print()
|
||||||
print 'This script will install Lektor on your computer.'
|
print('This script will install Lektor on your computer.')
|
||||||
print
|
print()
|
||||||
|
|
||||||
install_dir, lib_dir = find_location()
|
install_dir, lib_dir = find_location()
|
||||||
|
|
||||||
check_installation(install_dir)
|
check_installation(install_dir)
|
||||||
|
|
||||||
print ' Installing at:'
|
print(' Installing at:')
|
||||||
print ' %s' % install_dir
|
print(' %s' % install_dir)
|
||||||
print
|
print()
|
||||||
get_confirmation()
|
get_confirmation()
|
||||||
|
|
||||||
for url in json.load(urllib.urlopen(VENV_URL))['urls']:
|
for url in json.load(urllib.urlopen(VENV_URL))['urls']:
|
||||||
|
@ -134,8 +138,8 @@ def main():
|
||||||
|
|
||||||
install(virtualenv_url, virtualenv_filename, install_dir, lib_dir)
|
install(virtualenv_url, virtualenv_filename, install_dir, lib_dir)
|
||||||
|
|
||||||
print
|
print()
|
||||||
print 'All done!'
|
print('All done!')
|
||||||
|
|
||||||
main()
|
main()
|
||||||
"@
|
"@
|
||||||
|
|
|
@ -11,16 +11,12 @@
|
||||||
I() {
|
I() {
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
if hash python2 2> /dev/null; then
|
if ! hash python 2> /dev/null; then
|
||||||
PY=python2
|
|
||||||
elif hash python 2> /dev/null; then
|
|
||||||
PY=python
|
|
||||||
else
|
|
||||||
echo "Error: To use this script you need to have Python installed"
|
echo "Error: To use this script you need to have Python installed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$PY - <<'EOF'
|
python - <<'EOF'
|
||||||
if 1:
|
if 1:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -31,6 +27,10 @@ if 1:
|
||||||
import shutil
|
import shutil
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
|
||||||
|
PY2 = sys.version_info[0] == 2
|
||||||
|
if PY2:
|
||||||
|
input = raw_input
|
||||||
|
|
||||||
sys.stdin = open('/dev/tty', 'r')
|
sys.stdin = open('/dev/tty', 'r')
|
||||||
|
|
||||||
VENV_URL = "https://pypi.python.org/pypi/virtualenv/json"
|
VENV_URL = "https://pypi.python.org/pypi/virtualenv/json"
|
||||||
|
@ -66,18 +66,18 @@ if 1:
|
||||||
|
|
||||||
def get_confirmation():
|
def get_confirmation():
|
||||||
while 1:
|
while 1:
|
||||||
input = raw_input('Continue? [Yn] ').lower().strip()
|
user_input = input('Continue? [Yn] ').lower().strip()
|
||||||
if input in ('', 'y'):
|
if user_input in ('', 'y'):
|
||||||
break
|
break
|
||||||
elif input == 'n':
|
elif user_input == 'n':
|
||||||
print
|
print()
|
||||||
print 'Aborted!'
|
print('Aborted!')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def deletion_error(func, path, excinfo):
|
def deletion_error(func, path, excinfo):
|
||||||
print 'Problem deleting {}'.format(path)
|
print('Problem deleting {}'.format(path))
|
||||||
print 'Please try and delete {} manually'.format(path)
|
print('Please try and delete {} manually'.format(path))
|
||||||
print 'Aborted!'
|
print('Aborted!')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def wipe_installation(lib_dir, symlink_path):
|
def wipe_installation(lib_dir, symlink_path):
|
||||||
|
@ -89,18 +89,18 @@ if 1:
|
||||||
def check_installation(lib_dir, bin_dir):
|
def check_installation(lib_dir, bin_dir):
|
||||||
symlink_path = os.path.join(bin_dir, 'lektor')
|
symlink_path = os.path.join(bin_dir, 'lektor')
|
||||||
if os.path.exists(lib_dir) or os.path.lexists(symlink_path):
|
if os.path.exists(lib_dir) or os.path.lexists(symlink_path):
|
||||||
print ' Lektor seems to be installed already.'
|
print(' Lektor seems to be installed already.')
|
||||||
print ' Continuing will delete:'
|
print(' Continuing will delete:')
|
||||||
print ' %s' % lib_dir
|
print(' %s' % lib_dir)
|
||||||
print ' and remove this symlink:'
|
print(' and remove this symlink:')
|
||||||
print ' %s' % symlink_path
|
print(' %s' % symlink_path)
|
||||||
print
|
print()
|
||||||
get_confirmation()
|
get_confirmation()
|
||||||
print
|
print()
|
||||||
wipe_installation(lib_dir, symlink_path)
|
wipe_installation(lib_dir, symlink_path)
|
||||||
|
|
||||||
def fail(message):
|
def fail(message):
|
||||||
print 'Error: %s' % message
|
print('Error: %s' % message)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def install(virtualenv_url, lib_dir, bin_dir):
|
def install(virtualenv_url, lib_dir, bin_dir):
|
||||||
|
@ -119,11 +119,11 @@ if 1:
|
||||||
os.path.join(bin_dir, 'lektor'))
|
os.path.join(bin_dir, 'lektor'))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print
|
print()
|
||||||
print 'Welcome to Lektor'
|
print('Welcome to Lektor')
|
||||||
print
|
print()
|
||||||
print 'This script will install Lektor on your computer.'
|
print('This script will install Lektor on your computer.')
|
||||||
print
|
print()
|
||||||
|
|
||||||
paths = find_user_paths()
|
paths = find_user_paths()
|
||||||
if not paths:
|
if not paths:
|
||||||
|
@ -136,10 +136,10 @@ if 1:
|
||||||
|
|
||||||
check_installation(lib_dir, bin_dir)
|
check_installation(lib_dir, bin_dir)
|
||||||
|
|
||||||
print 'Installing at:'
|
print('Installing at:')
|
||||||
print ' bin: %s' % bin_dir
|
print(' bin: %s' % bin_dir)
|
||||||
print ' app: %s' % lib_dir
|
print(' app: %s' % lib_dir)
|
||||||
print
|
print()
|
||||||
|
|
||||||
get_confirmation()
|
get_confirmation()
|
||||||
|
|
||||||
|
@ -152,8 +152,8 @@ if 1:
|
||||||
|
|
||||||
install(virtualenv, lib_dir, bin_dir)
|
install(virtualenv, lib_dir, bin_dir)
|
||||||
|
|
||||||
print
|
print()
|
||||||
print 'All done!'
|
print('All done!')
|
||||||
|
|
||||||
main()
|
main()
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -25,5 +25,5 @@ the return value will be `None`.
|
||||||
from lektor.context import get_ctx
|
from lektor.context import get_ctx
|
||||||
|
|
||||||
ctx = get_ctx()
|
ctx = get_ctx()
|
||||||
print 'The current source is %s' % ctx.source
|
print('The current source is %s' % ctx.source)
|
||||||
```
|
```
|
||||||
|
|
|
@ -21,5 +21,5 @@ encounters a dependency it will invoke the passed function.
|
||||||
deps = set()
|
deps = set()
|
||||||
with get_ctx().gather_dependencies(deps.add):
|
with get_ctx().gather_dependencies(deps.add):
|
||||||
items = pad.query('/path/to/some/pages').all()
|
items = pad.query('/path/to/some/pages').all()
|
||||||
print 'The dependencies are: %s' % deps
|
print('The dependencies are: %s' % deps)
|
||||||
```
|
```
|
||||||
|
|
|
@ -18,5 +18,5 @@ as system fields which are prefixed by an underscore).
|
||||||
|
|
||||||
```python
|
```python
|
||||||
for child in this.children:
|
for child in this.children:
|
||||||
print 'ID: %s' % child['_id']
|
print('ID: %s' % child['_id'])
|
||||||
```
|
```
|
||||||
|
|
|
@ -31,5 +31,5 @@ in future versions.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def on_before_build(self, source, prog, **extra):
|
def on_before_build(self, source, prog, **extra):
|
||||||
print 'building %s' % source.source_filename
|
print('building %s' % source.source_filename)
|
||||||
```
|
```
|
||||||
|
|
|
@ -32,7 +32,7 @@ from lektor.pluginsystem import Plugin
|
||||||
class MyPlugin(Plugin):
|
class MyPlugin(Plugin):
|
||||||
|
|
||||||
def on_my_plugin_setup(self, foo, **extra):
|
def on_my_plugin_setup(self, foo, **extra):
|
||||||
print 'got %s' % foo
|
print('got %s' % foo)
|
||||||
```
|
```
|
||||||
|
|
||||||
(This assumes the plugin id is set to `my-plugin` in `setup.py`)
|
(This assumes the plugin id is set to `my-plugin` in `setup.py`)
|
||||||
|
|
|
@ -32,7 +32,7 @@ To enable support for Lektor you need to create a `.gitlab-ci.yml` config
|
||||||
next to your `.lektorproject` file with the following contents:
|
next to your `.lektorproject` file with the following contents:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
image: python:2.7
|
image: python:latest
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
script:
|
script:
|
||||||
|
|
|
@ -24,7 +24,7 @@ file into your repository. You can copy paste this over:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
language: python
|
language: python
|
||||||
python: 2.7
|
python: 3.5
|
||||||
install: "pip install Lektor"
|
install: "pip install Lektor"
|
||||||
script: "lektor build"
|
script: "lektor build"
|
||||||
deploy:
|
deploy:
|
||||||
|
@ -115,7 +115,7 @@ caching. Adjust your `.travis.yml` file to look like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
language: python
|
language: python
|
||||||
python: 2.7
|
python: 3.5
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.cache/pip
|
- $HOME/.cache/pip
|
||||||
|
@ -135,7 +135,7 @@ config:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
language: python
|
language: python
|
||||||
python: 2.7
|
python: 3.5
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.cache/pip
|
- $HOME/.cache/pip
|
||||||
|
|
|
@ -30,7 +30,7 @@ the installation is a bit more involved.
|
||||||
|
|
||||||
You need to make sure you have the following software installed on your computer:
|
You need to make sure you have the following software installed on your computer:
|
||||||
|
|
||||||
* Python 2.7 (**not** Python 3.x, also `python-dev`, `libssl-dev` and
|
* Python 2.7 or above (also `python-dev`, `libssl-dev` and
|
||||||
`libffi-dev` is required on Ubuntu)
|
`libffi-dev` is required on Ubuntu)
|
||||||
`sudo apt-get install python-dev libssl-dev libffi-dev`
|
`sudo apt-get install python-dev libssl-dev libffi-dev`
|
||||||
* ImageMagick (`brew install imagemagick` can get you this on OS X and `sudo apt-get install imagemagick`
|
* ImageMagick (`brew install imagemagick` can get you this on OS X and `sudo apt-get install imagemagick`
|
||||||
|
|
Loading…
Reference in New Issue