Merge pull request #100 from singingwolfboy/py3

Document Python 3 support
This commit is contained in:
Joseph Nix 2017-06-12 16:58:18 -05:00 committed by GitHub
commit 63551fca17
11 changed files with 72 additions and 68 deletions

View File

@ -1,5 +1,5 @@
language: python
python: 2.7
python: 3.5
install:
- "pip install -U pip"
- "pip install git+https://github.com/lektor/lektor#egg=Lektor"

View File

@ -23,15 +23,19 @@ LRESULT = LPARAM
HWND_BROADCAST = 0xFFFF
WM_SETTINGCHANGE = 0x1A
PY2 = sys.version_info[0] == 2
if PY2:
input = raw_input
def get_confirmation():
while 1:
input = raw_input('Continue? [Yn] ').lower().strip()
if input in ('', 'y'):
user_input = input('Continue? [Yn] ').lower().strip()
if user_input in ('', 'y'):
break
elif input == 'n':
print
print 'Aborted!'
elif user_input == 'n':
print()
print('Aborted!')
sys.exit()
def find_location():
@ -39,9 +43,9 @@ def find_location():
return install_dir, os.path.join(install_dir, LIB)
def deletion_error(func, path, excinfo):
print 'Problem deleting {}'.format(path)
print 'Please try and delete {} manually'.format(path)
print 'Aborted!'
print('Problem deleting {}'.format(path))
print('Please try and delete {} manually'.format(path))
print('Aborted!')
sys.exit()
def wipe_installation(install_dir):
@ -49,16 +53,16 @@ def wipe_installation(install_dir):
def check_installation(install_dir):
if os.path.exists(install_dir):
print ' Lektor seems to be installed already.'
print ' Continuing will delete:'
print ' %s' % install_dir
print
print(' Lektor seems to be installed already.')
print(' Continuing will delete:')
print(' %s' % install_dir)
print()
get_confirmation()
print
print()
wipe_installation(install_dir)
def fail(message):
print 'Error: %s' % message
print('Error: %s' % message)
sys.exit(1)
def add_to_path(location):
@ -108,19 +112,19 @@ def install(virtualenv_url, virtualenv_filename, install_dir, lib_dir):
def main():
print
print 'Welcome to Lektor'
print
print 'This script will install Lektor on your computer.'
print
print()
print('Welcome to Lektor')
print()
print('This script will install Lektor on your computer.')
print()
install_dir, lib_dir = find_location()
check_installation(install_dir)
print ' Installing at:'
print ' %s' % install_dir
print
print(' Installing at:')
print(' %s' % install_dir)
print()
get_confirmation()
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)
print
print 'All done!'
print()
print('All done!')
main()
"@

View File

@ -11,16 +11,12 @@
I() {
set -u
if hash python2 2> /dev/null; then
PY=python2
elif hash python 2> /dev/null; then
PY=python
else
if ! hash python 2> /dev/null; then
echo "Error: To use this script you need to have Python installed"
exit 1
fi
$PY - <<'EOF'
python - <<'EOF'
if 1:
import os
@ -31,6 +27,10 @@ if 1:
import shutil
from subprocess import Popen
PY2 = sys.version_info[0] == 2
if PY2:
input = raw_input
sys.stdin = open('/dev/tty', 'r')
VENV_URL = "https://pypi.python.org/pypi/virtualenv/json"
@ -66,18 +66,18 @@ if 1:
def get_confirmation():
while 1:
input = raw_input('Continue? [Yn] ').lower().strip()
if input in ('', 'y'):
user_input = input('Continue? [Yn] ').lower().strip()
if user_input in ('', 'y'):
break
elif input == 'n':
print
print 'Aborted!'
elif user_input == 'n':
print()
print('Aborted!')
sys.exit()
def deletion_error(func, path, excinfo):
print 'Problem deleting {}'.format(path)
print 'Please try and delete {} manually'.format(path)
print 'Aborted!'
print('Problem deleting {}'.format(path))
print('Please try and delete {} manually'.format(path))
print('Aborted!')
sys.exit()
def wipe_installation(lib_dir, symlink_path):
@ -89,18 +89,18 @@ if 1:
def check_installation(lib_dir, bin_dir):
symlink_path = os.path.join(bin_dir, 'lektor')
if os.path.exists(lib_dir) or os.path.lexists(symlink_path):
print ' Lektor seems to be installed already.'
print ' Continuing will delete:'
print ' %s' % lib_dir
print ' and remove this symlink:'
print ' %s' % symlink_path
print
print(' Lektor seems to be installed already.')
print(' Continuing will delete:')
print(' %s' % lib_dir)
print(' and remove this symlink:')
print(' %s' % symlink_path)
print()
get_confirmation()
print
print()
wipe_installation(lib_dir, symlink_path)
def fail(message):
print 'Error: %s' % message
print('Error: %s' % message)
sys.exit(1)
def install(virtualenv_url, lib_dir, bin_dir):
@ -119,11 +119,11 @@ if 1:
os.path.join(bin_dir, 'lektor'))
def main():
print
print 'Welcome to Lektor'
print
print 'This script will install Lektor on your computer.'
print
print()
print('Welcome to Lektor')
print()
print('This script will install Lektor on your computer.')
print()
paths = find_user_paths()
if not paths:
@ -136,10 +136,10 @@ if 1:
check_installation(lib_dir, bin_dir)
print 'Installing at:'
print ' bin: %s' % bin_dir
print ' app: %s' % lib_dir
print
print('Installing at:')
print(' bin: %s' % bin_dir)
print(' app: %s' % lib_dir)
print()
get_confirmation()
@ -152,8 +152,8 @@ if 1:
install(virtualenv, lib_dir, bin_dir)
print
print 'All done!'
print()
print('All done!')
main()
EOF

View File

@ -25,5 +25,5 @@ the return value will be `None`.
from lektor.context import get_ctx
ctx = get_ctx()
print 'The current source is %s' % ctx.source
print('The current source is %s' % ctx.source)
```

View File

@ -21,5 +21,5 @@ encounters a dependency it will invoke the passed function.
deps = set()
with get_ctx().gather_dependencies(deps.add):
items = pad.query('/path/to/some/pages').all()
print 'The dependencies are: %s' % deps
print('The dependencies are: %s' % deps)
```

View File

@ -18,5 +18,5 @@ as system fields which are prefixed by an underscore).
```python
for child in this.children:
print 'ID: %s' % child['_id']
print('ID: %s' % child['_id'])
```

View File

@ -31,5 +31,5 @@ in future versions.
```python
def on_before_build(self, source, prog, **extra):
print 'building %s' % source.source_filename
print('building %s' % source.source_filename)
```

View File

@ -32,7 +32,7 @@ from lektor.pluginsystem import Plugin
class MyPlugin(Plugin):
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`)

View File

@ -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:
```yaml
image: python:2.7
image: python:latest
pages:
script:

View File

@ -24,7 +24,7 @@ file into your repository. You can copy paste this over:
```yaml
language: python
python: 2.7
python: 3.5
install: "pip install Lektor"
script: "lektor build"
deploy:
@ -115,7 +115,7 @@ caching. Adjust your `.travis.yml` file to look like this:
```yaml
language: python
python: 2.7
python: 3.5
cache:
directories:
- $HOME/.cache/pip
@ -135,7 +135,7 @@ config:
```yaml
language: python
python: 2.7
python: 3.5
cache:
directories:
- $HOME/.cache/pip

View File

@ -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:
* 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)
`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`