Changeset - aa6f17a53b49
[Not reviewed]
default
0 14 0
Mads Kiilerich - 6 years ago 2019-11-23 22:08:18
mads@kiilerich.com
Grafted from: 3f8e198b4b77
py3: switch to use Python 3 interpreter, temporarily leaving many things very broken until they have been migrated/fixed in a reviewable way

Bump Mercurial minimum version to 5.2 - the first version that claim stable py3
support.
14 files changed with 23 insertions and 17 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -117,25 +117,25 @@ force_https = false
 
use_htsts = false
 

	
 
## number of commits stats will parse on each iteration
 
commit_parse_limit = 25
 

	
 
## Path to Python executable to be used for git hooks.
 
## This value will be written inside the git hook scripts as the text
 
## after '#!' (shebang). When empty or not defined, the value of
 
## 'sys.executable' at the time of installation of the git hooks is
 
## used, which is correct in many cases but for example not when using uwsgi.
 
## If you change this setting, you should reinstall the Git hooks via
 
## Admin > Settings > Remap and Rescan.
 
# git_hook_interpreter = /srv/kallithea/venv/bin/python2
 
# git_hook_interpreter = /srv/kallithea/venv/bin/python3
 

	
 
## path to git executable
 
git_path = git
 

	
 
## git rev filter option, --all is the default filter, if you need to
 
## hide all refs in changelog switch this to --branches --tags
 
#git_rev_filter = --branches --tags
 

	
 
## RSS feed options
 
rss_cut_off_limit = 256000
 
rss_items_per_page = 10
 
rss_include_diff = false
kallithea/__init__.py
Show inline comments
 
@@ -22,24 +22,27 @@ Versioning implementation: http://www.py
 
This file was forked by the Kallithea project in July 2014.
 
Original author and date, and relevant copyright and licensing information is below:
 
:created_on: Apr 9, 2010
 
:author: marcink
 
:copyright: (c) 2013 RhodeCode GmbH, (C) 2014 Bradley M. Kuhn, and others.
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
import platform
 
import sys
 

	
 

	
 
if sys.version_info < (3, 6):
 
    raise Exception('Kallithea requires python 3.6 or later')
 

	
 
VERSION = (0, 5, 99)
 
BACKENDS = {
 
    'hg': 'Mercurial repository',
 
    'git': 'Git repository',
 
}
 

	
 
CELERY_ON = False
 
CELERY_EAGER = False
 

	
 
CONFIG = {}
 

	
 
# Linked module for extensions
kallithea/lib/paster_commands/template.ini.mako
Show inline comments
 
@@ -211,25 +211,25 @@ force_https = false
 
use_htsts = false
 

	
 
<%text>## number of commits stats will parse on each iteration</%text>
 
commit_parse_limit = 25
 

	
 
<%text>## Path to Python executable to be used for git hooks.</%text>
 
<%text>## This value will be written inside the git hook scripts as the text</%text>
 
<%text>## after '#!' (shebang). When empty or not defined, the value of</%text>
 
<%text>## 'sys.executable' at the time of installation of the git hooks is</%text>
 
<%text>## used, which is correct in many cases but for example not when using uwsgi.</%text>
 
<%text>## If you change this setting, you should reinstall the Git hooks via</%text>
 
<%text>## Admin > Settings > Remap and Rescan.</%text>
 
# git_hook_interpreter = /srv/kallithea/venv/bin/python2
 
# git_hook_interpreter = /srv/kallithea/venv/bin/python3
 
%if git_hook_interpreter:
 
git_hook_interpreter = ${git_hook_interpreter}
 
%endif
 

	
 
<%text>## path to git executable</%text>
 
git_path = git
 

	
 
<%text>## git rev filter option, --all is the default filter, if you need to</%text>
 
<%text>## hide all refs in changelog switch this to --branches --tags</%text>
 
#git_rev_filter = --branches --tags
 

	
 
<%text>## RSS feed options</%text>
kallithea/model/scm.py
Show inline comments
 
@@ -691,25 +691,25 @@ class ScmModel(object):
 
    def _get_git_hook_interpreter(self):
 
        """Return a suitable interpreter for Git hooks.
 

	
 
        Return a suitable string to be written in the POSIX #! shebang line for
 
        Git hook scripts so they invoke Kallithea code with the right Python
 
        interpreter and in the right environment.
 
        """
 
        # Note: sys.executable might not point at a usable Python interpreter. For
 
        # example, when using uwsgi, it will point at the uwsgi program itself.
 
        # FIXME This may not work on Windows and may need a shell wrapper script.
 
        return (kallithea.CONFIG.get('git_hook_interpreter')
 
                or sys.executable
 
                or '/usr/bin/env python2')
 
                or '/usr/bin/env python3')
 

	
 
    def install_git_hooks(self, repo, force_create=False):
 
        """
 
        Creates a kallithea hook inside a git repository
 

	
 
        :param repo: Instance of VCS repo
 
        :param force_create: Create even if same name hook exists
 
        """
 

	
 
        loc = os.path.join(repo.path, 'hooks')
 
        if not repo.bare:
 
            loc = os.path.join(repo.path, '.git', 'hooks')
kallithea/tests/scripts/manual_test_crawler.py
Show inline comments
 
#!/usr/bin/env python2
 
#!/usr/bin/env python3
 
# -*- coding: utf-8 -*-
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
scripts/docs-headings.py
Show inline comments
 
#!/usr/bin/env python2
 
#!/usr/bin/env python3
 

	
 
"""
 
Consistent formatting of rst section titles
 
"""
 

	
 
from __future__ import print_function
 

	
 
import re
 
import subprocess
 

	
 

	
 
spaces = [
scripts/generate-ini.py
Show inline comments
 
#!/usr/bin/env python2
 
#!/usr/bin/env python3
 
"""
 
Based on kallithea/lib/paster_commands/template.ini.mako, generate development.ini
 
"""
 

	
 
from __future__ import print_function
 

	
 
import re
 

	
 
from kallithea.lib import inifile
 

	
 

	
 
# files to be generated from the mako template
scripts/logformat.py
Show inline comments
 
#!/usr/bin/env python2
 
#!/usr/bin/env python3
 

	
 
from __future__ import print_function
 

	
 
import re
 
import sys
 

	
 

	
 
logre = r'''
 
(log\.(?:error|info|warning|debug)
 
[(][ \n]*
 
)
 
%s
scripts/make-release
Show inline comments
 
@@ -6,59 +6,59 @@ cleanup()
 
{
 
  echo "Removing venv $venv"
 
  rm  -rf "$venv"
 
}
 

	
 
echo "Checking that you are NOT inside a virtualenv"
 
[ -z "$VIRTUAL_ENV" ]
 

	
 
venv=$(mktemp -d --tmpdir kallithea-release-XXXXX)
 
trap cleanup EXIT
 

	
 
echo "Setting up a fresh virtualenv in $venv"
 
virtualenv -p python2 "$venv"
 
virtualenv -p python3 "$venv"
 
. "$venv/bin/activate"
 

	
 
echo "Install/verify tools needed for building and uploading stuff"
 
pip install --upgrade -e . -r dev_requirements.txt twine python-ldap python-pam
 

	
 
echo "Cleanup and update copyrights ... and clean checkout"
 
scripts/run-all-cleanup
 
scripts/update-copyrights.py
 
hg up -cr .
 

	
 
echo "Make release build from clean checkout in build/"
 
rm -rf build dist
 
hg archive build
 
cd build
 

	
 
echo "Check that each entry in MANIFEST.in match something"
 
sed -e 's/[^ ]*[ ]*\([^ ]*\).*/\1/g' MANIFEST.in | xargs ls -lad
 

	
 
echo "Build dist"
 
python2 setup.py compile_catalog
 
python2 setup.py sdist
 
python3 setup.py compile_catalog
 
python3 setup.py sdist
 

	
 
echo "Verify VERSION from kallithea/__init__.py"
 
namerel=$(cd dist && echo Kallithea-*.tar.gz)
 
namerel=${namerel%.tar.gz}
 
version=${namerel#Kallithea-}
 
ls -l $(pwd)/dist/$namerel.tar.gz
 
echo "Releasing Kallithea $version in directory $namerel"
 

	
 
echo "Verify dist file content"
 
diff -u <((hg mani | grep -v '^\.hg\|^kallithea/i18n/en/LC_MESSAGES/kallithea.mo$') | LANG=C sort) <(tar tf dist/Kallithea-$version.tar.gz | sed "s|^$namerel/||" | grep . | grep -v '^kallithea/i18n/.*/LC_MESSAGES/kallithea.mo$\|^Kallithea.egg-info/\|^PKG-INFO$\|/$' | LANG=C sort)
 

	
 
echo "Verify docs build"
 
python2 setup.py build_sphinx # the results are not actually used, but we want to make sure it builds
 
python3 setup.py build_sphinx # the results are not actually used, but we want to make sure it builds
 

	
 
echo "Shortlog for inclusion in the release announcement"
 
scripts/shortlog.py "only('.', branch('stable') & tagged() & public() & not '.')"
 

	
 
cat - << EOT
 

	
 
Now, make sure
 
* all tests are passing
 
* release note is ready
 
* announcement is ready
 
* source has been pushed to https://kallithea-scm.org/repos/kallithea
 

	
scripts/shortlog.py
Show inline comments
 
#!/usr/bin/env python2
 
#!/usr/bin/env python3
 
# -*- coding: utf-8 -*-
 

	
 
"""
 
Kallithea script for generating a quick overview of contributors and their
 
commit counts in a given revision set.
 
"""
 
import argparse
 
import os
 
from collections import Counter
 

	
 
from . import contributor_data
 

	
scripts/update-copyrights.py
Show inline comments
 
#!/usr/bin/env python2
 
#!/usr/bin/env python3
 
# -*- coding: utf-8 -*-
 

	
 
"""
 
Kallithea script for maintaining contributor lists from version control
 
history.
 

	
 
This script and the data in it is a best effort attempt at reverse engineering
 
previous attributions and correlate that with version control history while
 
preserving all existing copyright statements and attribution. This script is
 
processing and summarizing information found elsewhere - it is not by itself
 
making any claims. Comments in the script are an attempt at reverse engineering
 
possible explanations - they are not showing any intent or confirming it is
scripts/validate-commits
Show inline comments
 
@@ -25,25 +25,25 @@ finish()
 
    cleanup
 
    # print (possibly intermediate) results
 
    cat "$resultfile"
 
    rm "$resultfile"
 
}
 
trap finish EXIT
 

	
 
for rev in $(hg log -r "$1" -T '{node}\n'); do
 
    hg log -r "$rev"
 
    hg update "$rev"
 

	
 
    cleanup
 
    virtualenv -p "$(command -v python2)" "$venv"
 
    virtualenv -p "$(command -v python3)" "$venv"
 
    source "$venv/bin/activate"
 
    pip install --upgrade pip setuptools
 
    pip install -e . -r dev_requirements.txt python-ldap python-pam
 

	
 
    # run-all-cleanup
 
    scripts/run-all-cleanup
 
    if ! hg update --check -q .; then
 
        echo "run-all-cleanup did not give clean results!"
 
        result="NOK"
 
        hg diff
 
        hg revert -a
 
    else
scripts/validate-minimum-dependency-versions
Show inline comments
 
@@ -19,25 +19,25 @@ echo "log: $log"
 
echo "minimum requirements file: $min_requirements"
 

	
 
# clean up previous runs
 
rm -rf "$venv" "$log"
 
mkdir -p "$venv"
 

	
 
# Make a light weight parsing of setup.py and dev_requirements.txt,
 
# finding all >= requirements and dumping into a custom requirements.txt
 
# while fixating the requirement at the lower bound.
 
sed -n 's/.*"\(.*\)>=\(.*\)".*/\1==\2/p' setup.py > "$min_requirements"
 
sed 's/>=/==/p' dev_requirements.txt >> "$min_requirements"
 

	
 
virtualenv -p "$(command -v python2)" "$venv"
 
virtualenv -p "$(command -v python3)" "$venv"
 
source "$venv/bin/activate"
 
pip install --upgrade pip setuptools
 
pip install -e . -r "$min_requirements" python-ldap python-pam 2> >(tee "$log" >&2)
 

	
 
# Strip out the known Python 2.7 deprecation message.
 
sed -i '/DEPRECATION: Python 2\.7 /d' "$log"
 

	
 
# Treat any message on stderr as a problem, for the caller to interpret.
 
if [ -s "$log" ]; then
 
    echo
 
    echo "Error: pip detected following problems:"
 
    cat "$log"
setup.py
Show inline comments
 
#!/usr/bin/env python2
 
#!/usr/bin/env python3
 
# -*- coding: utf-8 -*-
 
import os
 
import platform
 
import sys
 

	
 
import setuptools
 
# monkey patch setuptools to use distutils owner/group functionality
 
from setuptools.command import sdist
 

	
 

	
 
if sys.version_info < (2, 6) or sys.version_info >= (3,):
 
    raise Exception('Kallithea requires python 2.7')
 
# But temporarily, at the same time:
 
if sys.version_info < (3, 6):
 
    raise Exception('Kallithea requires Python 3.6 or later')
 

	
 

	
 
here = os.path.abspath(os.path.dirname(__file__))
 

	
 

	
 
def _get_meta_var(name, data, callback_handler=None):
 
    import re
 
    matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
 
    if matches:
 
        if not callable(callback_handler):
 
            callback_handler = lambda v: v
 

	
 
@@ -53,25 +56,25 @@ requirements = [
 
    "SQLAlchemy >= 1.2.9, < 1.4",
 
    "Mako >= 0.9.1, < 1.1",
 
    "Pygments >= 2.2.0, < 2.5",
 
    "Whoosh >= 2.7.1, < 2.8",
 
    "celery >= 3.1, < 4.0", # TODO: celery 4 doesn't work
 
    "Babel >= 1.3, < 2.8",
 
    "python-dateutil >= 2.1.0, < 2.9",
 
    "Markdown >= 2.2.1, < 3.2",
 
    "docutils >= 0.11, < 0.15",
 
    "URLObject >= 2.3.4, < 2.5",
 
    "Routes >= 2.0, < 2.5",
 
    "dulwich >= 0.19.0, < 0.20",
 
    "mercurial >= 5.1, < 5.4",
 
    "mercurial >= 5.2, < 5.4",
 
    "decorator >= 4.2.1, < 4.5",
 
    "Paste >= 2.0.3, < 3.1",
 
    "bleach >= 3.0, < 3.2",
 
    "Click >= 7.0, < 8",
 
    "ipaddr >= 2.2.0, < 2.3",
 
    "paginate >= 0.5, < 0.6",
 
    "paginate_sqlalchemy >= 0.3.0, < 0.4",
 
]
 

	
 
if not is_windows:
 
    requirements.append("bcrypt >= 3.1.0, < 3.2")
 

	
0 comments (0 inline, 0 general)