Changeset - 0a9ddb8cd8c1
[Not reviewed]
stable
0 8 0
Mads Kiilerich - 3 years ago 2023-04-13 13:54:24
mads@kiilerich.com
setup: avoid setuptools 67 - it can't handle celery's broken pytz dependency

With setuptools 67 or later, launching Kallithea fails as:

$ gearbox serve -c my.ini --reload
15:56:54,111 ERROR [gearbox] Expected closing RIGHT_PARENTHESIS
pytz (>dev)
~^

The `packaging` vendored in setuptools cannot handle the broken syntax
`Requires-Dist: pytz (>dev)` in
venv/lib/python3.11/site-packages/celery-5.0.5.dist-info/METADATA .

The old celery version currently used by Kallithea is wrong, and setuptools has
moved on after a reasonable grace period. We thus have to work around and avoid
latest setuptools.

See https://github.com/pypa/setuptools/issues/3889 .
8 files changed with 9 insertions and 9 deletions:
0 comments (0 inline, 0 general)
Jenkinsfile
Show inline comments
 
@@ -7,49 +7,49 @@ node {
 
                              artifactDaysToKeepStr: '',
 
                              artifactNumToKeepStr: '10',
 
                              daysToKeepStr: '',
 
                              numToKeepStr: '']]]);
 
    if (isUnix()) {
 
        createvirtualenv = 'rm -r $JENKINS_HOME/venv/$JOB_NAME || true && python3 -m venv $JENKINS_HOME/venv/$JOB_NAME'
 
        activatevirtualenv = '. $JENKINS_HOME/venv/$JOB_NAME/bin/activate'
 
    } else {
 
        createvirtualenv = 'rmdir /s /q %JENKINS_HOME%\\venv\\%JOB_NAME% || true && python3 -m venv %JENKINS_HOME%\\venv\\%JOB_NAME%'
 
        activatevirtualenv = 'call %JENKINS_HOME%\\venv\\%JOB_NAME%\\Scripts\\activate.bat'
 
    }
 

	
 
    stage('checkout') {
 
        checkout scm
 
        if (isUnix()) {
 
            sh 'hg --config extensions.purge= purge --all'
 
        } else {
 
            bat 'hg --config extensions.purge= purge --all'
 
        }
 
    }
 
    stage('virtual env') {
 
        def virtualenvscript = """$createvirtualenv
 
            $activatevirtualenv
 
            python -m pip install --upgrade pip
 
            pip install --upgrade setuptools
 
            pip install --upgrade "setuptools<67"
 
            pip install --upgrade pylint
 
            pip install --upgrade pytest-cov
 
            """
 
        if (isUnix()) {
 
            virtualenvscript += """
 
                pip install --upgrade python-ldap
 
                pip install --upgrade python-pam
 
                """
 
            sh virtualenvscript
 
        } else {
 
            bat virtualenvscript
 
        }
 
    }
 
    stage('setup') {
 
        def virtualenvscript = """$activatevirtualenv
 
            pip install --upgrade -e . -r dev_requirements.txt
 
            python setup.py compile_catalog
 
            """
 
        if (isUnix()) {
 
            sh virtualenvscript
 
        } else {
 
            bat virtualenvscript
 
        }
 
        stash name: 'kallithea', useDefaultExcludes: false
docs/contributing.rst
Show inline comments
 
@@ -12,49 +12,49 @@ Infrastructure
 
--------------
 

	
 
The main repository is hosted on Our Own Kallithea (aka OOK) at
 
https://kallithea-scm.org/repos/kallithea/, our self-hosted instance
 
of Kallithea.
 

	
 
Please use the `mailing list`_ to send patches or report issues.
 

	
 
We use Weblate_ to translate the user interface messages into languages other
 
than English. Join our project on `Hosted Weblate`_ to help us.
 
To register, you can use your Bitbucket or GitHub account. See :ref:`translations`
 
for more details.
 

	
 

	
 
Getting started
 
---------------
 

	
 
To get started with Kallithea development run the following commands in your
 
bash shell::
 

	
 
        hg clone https://kallithea-scm.org/repos/kallithea
 
        cd kallithea
 
        python3 -m venv venv
 
        . venv/bin/activate
 
        pip install --upgrade pip setuptools
 
        pip install --upgrade pip "setuptools<67"
 
        pip install --upgrade -e . -r dev_requirements.txt python-ldap python-pam
 
        kallithea-cli config-create my.ini
 
        kallithea-cli db-create -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp
 
        kallithea-cli front-end-build
 
        gearbox serve -c my.ini --reload &
 
        firefox http://127.0.0.1:5000/
 

	
 

	
 
Contribution flow
 
-----------------
 

	
 
Starting from an existing Kallithea clone, make sure it is up to date with the
 
latest upstream changes::
 

	
 
        hg pull
 
        hg update
 

	
 
Review the :ref:`contributing-guidelines` and :ref:`coding-guidelines`.
 

	
 
If you are new to Mercurial, refer to Mercurial `Quick Start`_ and `Beginners
 
Guide`_ on the Mercurial wiki.
 

	
 
Now, make some changes and test them (see :ref:`contributing-tests`). Don't
 
forget to add new tests to cover new functionality or bug fixes.
docs/installation.rst
Show inline comments
 
@@ -34,92 +34,92 @@ Git and development packages for the dat
 

	
 
For Debian and Ubuntu, the following command will ensure that a reasonable
 
set of dependencies is installed::
 

	
 
    sudo apt-get install build-essential git libffi-dev python3-dev
 

	
 
For Fedora and RHEL-derivatives, the following command will ensure that a
 
reasonable set of dependencies is installed::
 

	
 
    sudo yum install gcc git libffi-devel python3-devel
 

	
 
.. _installation-source:
 

	
 

	
 
Installation from repository source
 
-----------------------------------
 

	
 
To install Kallithea in a virtualenv using the stable branch of the development
 
repository, use the following commands in your bash shell::
 

	
 
        hg clone https://kallithea-scm.org/repos/kallithea -u stable
 
        cd kallithea
 
        python3 -m venv venv
 
        . venv/bin/activate
 
        pip install --upgrade pip setuptools
 
        pip install --upgrade pip "setuptools<67"
 
        pip install --upgrade -e .
 
        python3 setup.py compile_catalog   # for translation of the UI
 

	
 
.. note::
 
   This will install all Python dependencies into the virtualenv. Kallithea
 
   itself will however only be installed as a pointer to the source location.
 
   The source clone must thus be kept in the same location, and it shouldn't be
 
   updated to other revisions unless you want to upgrade. Edits in the source
 
   tree will have immediate impact (possibly after a restart of the service).
 

	
 
You can now proceed to :ref:`prepare-front-end-files`.
 

	
 
.. _installation-virtualenv:
 

	
 

	
 
Installing a released version in a virtualenv
 
---------------------------------------------
 

	
 
It is highly recommended to use a separate virtualenv for installing Kallithea.
 
This way, all libraries required by Kallithea will be installed separately from your
 
main Python installation and other applications and things will be less
 
problematic when upgrading the system or Kallithea.
 
An additional benefit of virtualenv is that it doesn't require root privileges.
 

	
 
- Don't install as root - install as a dedicated user like ``kallithea``.
 
  If necessary, create the top directory for the virtualenv (like
 
  ``/srv/kallithea/venv``) as root and assign ownership to the user.
 

	
 
  Make a parent folder for the virtualenv (and perhaps also Kallithea
 
  configuration and data files) such as ``/srv/kallithea``. Create the
 
  directory as root if necessary and grant ownership to the ``kallithea`` user.
 

	
 
- Create a new virtual environment, for example in ``/srv/kallithea/venv``,
 
  specifying the right Python binary::
 

	
 
    python3 -m venv /srv/kallithea/venv
 

	
 
- Activate the virtualenv in your current shell session and make sure the
 
  basic requirements are up-to-date by running the following commands in your
 
  bash shell::
 

	
 
    . /srv/kallithea/venv/bin/activate
 
    pip install --upgrade pip setuptools
 
    pip install --upgrade pip "setuptools<67"
 

	
 
.. note:: You can't use UNIX ``sudo`` to source the ``activate`` script; it
 
   will "activate" a shell that terminates immediately.
 

	
 
- Install Kallithea in the activated virtualenv::
 

	
 
    pip install --upgrade kallithea
 

	
 
.. note:: Some dependencies are optional. If you need them, install them in
 
   the virtualenv too::
 

	
 
     pip install --upgrade kallithea python-ldap python-pam psycopg2
 

	
 
   This might require installation of development packages using your
 
   distribution's package manager.
 

	
 
   Alternatively, download a .tar.gz from http://pypi.python.org/pypi/Kallithea,
 
   extract it and install from source by running::
 

	
 
     pip install --upgrade .
 

	
 
- This will install Kallithea together with all other required
 
  Python libraries into the activated virtualenv.
 

	
docs/installation_win.rst
Show inline comments
 
@@ -83,49 +83,49 @@ Step 6 -- Install virtualenv
 
.. note::
 
   A python virtual environment will allow for isolation between the Python packages of your system and those used for Kallithea.
 
   It is strongly recommended to use it to ensure that Kallithea does not change a dependency that other software uses or vice versa.
 

	
 
To create a virtual environment, run::
 

	
 
  python3 -m venv C:\Kallithea\Env
 

	
 
Step 7 -- Install Kallithea
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
In order to install Kallithea, you need to be able to run "pip install kallithea". It will use pip to install the Kallithea Python package and its dependencies.
 
Some Python packages use managed code and need to be compiled.
 
This can be done on Linux without any special steps. On Windows, you will need to install Microsoft Visual C++ compiler for Python 3.8.
 

	
 
Download and install "Microsoft Visual C++ Compiler for Python 3.8" from http://aka.ms/vcpython27
 

	
 
.. note::
 
  You can also install the dependencies using already compiled Windows binaries packages. A good source of compiled Python packages is http://www.lfd.uci.edu/~gohlke/pythonlibs/. However, not all of the necessary packages for Kallithea are on this site and some are hard to find, so we will stick with using the compiler.
 

	
 
In a command prompt type (adapting paths if necessary)::
 

	
 
  cd C:\Kallithea\Env\Scripts
 
  activate
 
  pip install --upgrade pip setuptools
 
  pip install --upgrade pip "setuptools<67"
 

	
 
The prompt will change into "(Env) C:\\Kallithea\\Env\\Scripts" or similar
 
(depending of your folder structure). Then type::
 

	
 
  pip install kallithea
 

	
 
.. note:: This will take some time. Please wait patiently until it is fully
 
          complete. Some warnings will appear. Don't worry, they are
 
          normal.
 

	
 
Step 8 -- Install Git (optional)
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Mercurial being a python package, was installed automatically when doing ``pip install kallithea``.
 

	
 
You need to install Git manually if you want Kallithea to be able to host Git repositories.
 
See http://git-scm.com/book/en/v2/Getting-Started-Installing-Git#Installing-on-Windows for instructions.
 
The location of the Git binaries (like ``c:\path\to\git\bin``) must be
 
added to the ``PATH`` environment variable so ``git.exe`` and other tools like
 
``gzip.exe`` are available.
 

	
 
Step 9 -- Configuring Kallithea
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
docs/installation_win_old.rst
Show inline comments
 
@@ -149,49 +149,49 @@ Step 7 -- Install Kallithea
 
Finally, install Kallithea
 

	
 
Close previously opened command prompt/s, and open a Visual Studio 2008
 
Command Prompt (**IMPORTANT!!**). To do so, go to Start Menu, and then open
 
"Microsoft Visual C++ 2008 Express Edition" -> "Visual Studio Tools" ->
 
"Visual Studio 2008 Command Prompt"
 

	
 
.. note::
 

	
 
   64-bit: For 64-bit you need to modify the shortcut that is used to start the
 
   Visual Studio 2008 Command Prompt. Use right-mouse click to open properties.
 

	
 
Change commandline from::
 

	
 
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86
 

	
 
to::
 

	
 
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" amd64
 

	
 
In that CMD (loaded with VS2008 PATHs) type::
 

	
 
  cd C:\Kallithea\Env\Scripts (or similar)
 
  activate
 
  pip install --upgrade pip setuptools
 
  pip install --upgrade pip "setuptools<67"
 

	
 
The prompt will change into "(Env) C:\\Kallithea\\Env\\Scripts" or similar
 
(depending of your folder structure). Then type::
 

	
 
 pip install kallithea
 

	
 
(long step, please wait until fully complete)
 

	
 
Some warnings will appear, don't worry as they are normal.
 

	
 
Step 8 -- Configuring Kallithea
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
steps taken from http://packages.python.org/Kallithea/setup.html
 

	
 
You have to use the same Visual Studio 2008 command prompt as Step7, so
 
if you closed it reopen it following the same commands (including the
 
"activate" one). When ready, just type::
 

	
 
  cd C:\Kallithea\Bin
 
  kallithea-cli config-create my.ini
 

	
 
Then, you must edit my.ini to fit your needs (network address and
 
port, mail settings, database, whatever). I recommend using NotePad++
scripts/dbmigrate-test
Show inline comments
 
@@ -73,49 +73,49 @@ Upgrade from:   $from_rev_hash (${from_r
 
Upgrade to:     $to_rev_hash (${to_rev:-current})
 
Extra packages: ${EXTRA:-(none)}
 
EOD
 

	
 
mkdir "$temp/repos" # empty
 

	
 
# Enable caching for old pip versions (this will cache the pip upgrade)
 
# Newer pip versions cache automatically, and don't use this variable.
 
if [ ! "$PIP_DOWNLOAD_CACHE" ]; then
 
    export PIP_DOWNLOAD_CACHE=$HOME/.cache/pip/legacy
 
fi
 

	
 
install_kallithea() {
 
    local prefix=$1
 
    local rev=$2
 

	
 
    announce "Installing Kallithea $rev in $prefix..."
 

	
 
    "${VIRTUALENV:-virtualenv}" --quiet "$prefix-env"
 
    HG archive --rev "$rev" "$prefix"
 

	
 
    (
 
        cd "$prefix"
 
        . "$prefix-env/bin/activate"
 
        pip install --quiet --upgrade pip setuptools mercurial $EXTRA
 
        pip install --quiet --upgrade pip "setuptools<67" mercurial $EXTRA
 
        pip install --quiet -e .
 
    )
 
}
 

	
 
install_kallithea "$temp/from" "$from_rev_hash"
 
(
 
    cd "$temp/from"
 
    . "$temp/from-env/bin/activate"
 
    announce "Initializing database..."
 
    quiet_if_ok kallithea-cli db-create -c "$config_file" --repos="$temp/repos" --user=doe --email=doe@example.com --password=123456 --no-public-access --force-yes
 
    alembic -c "$config_file" current -v
 
)
 

	
 
install_kallithea "$temp/to" "$to_rev_hash"
 
(
 
    cd "$temp/to"
 
    . "$temp/to-env/bin/activate"
 

	
 
    announce "Commencing database upgrade from shown Alembic revision to head..."
 
    alembic -c "$config_file" current -v
 
    alembic -c "$config_file" upgrade head
 
    announce "Upgrade complete, now at the shown Alembic revision:"
 
    alembic -c "$config_file" current -v
 
)
scripts/validate-commits
Show inline comments
 
@@ -21,49 +21,49 @@ venv=$(mktemp -d kallithea-validatecommi
 
resultfile=$(mktemp kallithea-validatecommits-result-XXXXXX)
 
echo > "$resultfile"
 

	
 
cleanup()
 
{
 
    rm -rf /tmp/kallithea-test*
 
    rm -rf "$venv"
 
}
 
finish()
 
{
 
    cleanup
 
    # print (possibly intermediate) results
 
    cat "$resultfile"
 
    rm "$resultfile"
 
}
 
trap finish EXIT
 

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

	
 
    cleanup
 
    python3 -m venv "$venv"
 
    source "$venv/bin/activate"
 
    pip install --upgrade pip setuptools
 
    pip install --upgrade pip "setuptools<67"
 
    pip install -e . -r dev_requirements.txt python-ldap python-pam
 

	
 
    # run-all-cleanup
 
    if ! scripts/run-all-cleanup ; then
 
        echo "run-all-cleanup encountered errors!"
 
        result="NOK"
 
    else
 
        if ! hg update --check -q .; then
 
            echo "run-all-cleanup did not give clean results!"
 
            result="NOK"
 
            hg diff
 
            hg revert -a
 
        else
 
            result=" OK"
 
        fi
 
    fi
 
    echo "$result: $rev (run-all-cleanup)" >> "$resultfile"
 

	
 
    # pytest
 
    if py.test; then
 
        result=" OK"
 
    else
 
        result="NOK"
 
    fi
scripts/validate-minimum-dependency-versions
Show inline comments
 
@@ -9,44 +9,44 @@ if [ -n "$VIRTUAL_ENV" ]; then
 
    exit 1
 
fi
 

	
 
cd "$(hg root)"
 

	
 
venv=build/minimum-dependency-versions-venv
 
log=build/minimum-dependency-versions.log
 
min_requirements=build/minimum-dependency-versions-requirements.txt
 
echo "virtualenv: $venv"
 
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"
 

	
 
python3 -m venv "$venv"
 
source "$venv/bin/activate"
 
pip install --upgrade pip setuptools
 
pip install --upgrade pip "setuptools<67"
 
pip install -e . -r "$min_requirements" python-ldap python-pam 2> >(tee "$log" >&2)
 

	
 
# 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"
 
    echo
 
    exit 1
 
fi
 

	
 
freeze_txt=build/minimum-dependency-versions.txt
 
pip freeze > $freeze_txt
 
echo "Installation of minimum packages was successful, providing a set of packages as in $freeze_txt . Now running test suite..."
 

	
 
pytest
 

	
 
echo "Test suite execution was successful."
 
echo "You can now do additional validation using virtual env '$venv'."
0 comments (0 inline, 0 general)