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
 
def createvirtualenv = ''
 
def activatevirtualenv = ''
 

	
 
node {
 
    properties([[$class: 'BuildDiscarderProperty',
 
                  strategy: [$class: 'LogRotator',
 
                              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
 
    }
 
    stage('pylint') {
 
        sh script: """$activatevirtualenv
 
            pylint -j 0 --disable=C -f parseable kallithea > pylint.out
 
            """, returnStatus: true
 
        archiveArtifacts 'pylint.out'
 
        try {
 
            step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'PyLint', pattern: 'pylint.out']], unHealthy: ''])
 
        } catch (java.lang.IllegalArgumentException exc) {
 
            echo "You need to install the 'Warnings Plug-in' to display the pylint report."
 
            currentBuild.result = 'UNSTABLE'
 
            echo "Caught: ${exc}"
 
        }
 
    }
 
}
 

	
 
def pytests = [:]
 
pytests['sqlite'] = {
 
    node {
 
        ws {
 
            deleteDir()
 
            unstash name: 'kallithea'
 
            if (isUnix()) {
 
                sh script: """$activatevirtualenv
docs/contributing.rst
Show inline comments
 
.. _contributing:
 

	
 
=========================
 
Contributing to Kallithea
 
=========================
 

	
 
Kallithea is developed and maintained by its users. Please join us and scratch
 
your own itch.
 

	
 

	
 
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.
 

	
 
For documentation changes, run ``make html`` from the ``docs`` directory to
 
generate the HTML result, then review them in your browser.
 

	
 
Before submitting any changes, run the cleanup script::
 

	
 
        ./scripts/run-all-cleanup
 

	
 
When you are completely ready, you can send your changes to the community for
 
review and inclusion, via the mailing list (via ``hg email``).
 

	
 
.. _contributing-tests:
 

	
 

	
 
Internal dependencies
 
---------------------
 

	
 
We try to keep the code base clean and modular and avoid circular dependencies.
 
Code should only invoke code in layers below itself.
 

	
 
Imports should import whole modules ``from`` their parent module, perhaps
 
``as`` a shortened name. Avoid imports ``from`` modules.
 

	
 
To avoid cycles and partially initialized modules, ``__init__.py`` should *not*
docs/installation.rst
Show inline comments
 
@@ -10,135 +10,135 @@ The following describes three different 
 
  up-to-date and track any local customizations is to run directly from
 
  source in a Kallithea repository clone, preferably inside a virtualenv
 
  virtual Python environment.
 

	
 
- :ref:`installation-virtualenv`: If you prefer to only use released versions
 
  of Kallithea, the recommended method is to install Kallithea in a virtual
 
  Python environment using `virtualenv`. The advantages of this method over
 
  direct installation is that Kallithea and its dependencies are completely
 
  contained inside the virtualenv (which also means you can have multiple
 
  installations side by side or remove it entirely by just removing the
 
  virtualenv directory) and does not require root privileges.
 

	
 
- Kallithea can also be installed with plain pip - globally or with ``--user``
 
  or similar. The package will be installed in the same location as all other
 
  Python packages you have ever installed. As a result, removing it is not as
 
  straightforward as with a virtualenv, as you'd have to remove its
 
  dependencies manually and make sure that they are not needed by other
 
  packages. We recommend using virtualenv.
 

	
 
Regardless of the installation method you may need to make sure you have
 
appropriate development packages installed, as installation of some of the
 
Kallithea dependencies requires a working C compiler and libffi library
 
headers. Depending on your configuration, you may also need to install
 
Git and development packages for the database of your choice.
 

	
 
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.
 

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

	
 
.. _prepare-front-end-files:
 

	
 

	
 
Prepare front-end files
 
-----------------------
 

	
 
Finally, the front-end files with CSS and JavaScript must be prepared. This
 
depends on having some commands available in the shell search path: ``npm``
 
version 6 or later, and ``node.js`` (version 12 or later) available as
 
``node``. The installation method for these dependencies varies between
 
operating systems and distributions.
 

	
 
Prepare the front-end by running::
 

	
 
    kallithea-cli front-end-build
 

	
 
You can now proceed to :ref:`setup`.
docs/installation_win.rst
Show inline comments
 
@@ -59,97 +59,97 @@ http://sourceforge.net/projects/pywin32/
 
  (x64)
 
  http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win32-py3.8.exe/download
 
  (Win32)
 

	
 
Step 5 -- Kallithea folder structure
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Create a Kallithea folder structure.
 

	
 
This is only an example to install Kallithea. Of course, you can
 
change it. However, this guide will follow the proposed structure, so
 
please later adapt the paths if you change them. Folders without
 
spaces are recommended.
 

	
 
Create the following folder structure::
 

	
 
  C:\Kallithea
 
  C:\Kallithea\Bin
 
  C:\Kallithea\Env
 
  C:\Kallithea\Repos
 

	
 
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
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Steps taken from `<setup.html>`_
 

	
 
You have to use the same command prompt as in Step 7, so if you closed
 
it, reopen it following the same commands (including the "activate"
 
one). When ready, type::
 

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

	
 
Then you must edit my.ini to fit your needs (IP address, IP
 
port, mail settings, database, etc.). `NotePad++`__ or a similar text
 
editor is recommended to properly handle the newline character
 
differences between Unix and Windows.
 

	
 
__ http://notepad-plus-plus.org/
 

	
 
For the sake of simplicity, run it with the default settings. After your edits (if any) in the previous command prompt, type::
 

	
 
  kallithea-cli db-create -c my.ini
 

	
 
.. warning:: This time a *new* database will be installed. You must
 
             follow a different process to later :ref:`upgrade <upgrade>`
 
             to a newer Kallithea version.
 

	
docs/installation_win_old.rst
Show inline comments
 
@@ -125,97 +125,97 @@ Create a Kallithea folder structure
 

	
 
This is only a example to install Kallithea, you can of course change
 
it. However, this guide will follow the proposed structure, so please
 
later adapt the paths if you change them. My recommendation is to use
 
folders with NO SPACES. But you can try if you are brave...
 

	
 
Create the following folder structure::
 

	
 
  C:\Kallithea
 
  C:\Kallithea\Bin
 
  C:\Kallithea\Env
 
  C:\Kallithea\Repos
 

	
 
Step 6 -- Install virtualenv
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Create a virtual Python environment in C:\\Kallithea\\Env (or similar). To
 
do so, open a CMD (Python Path should be included in Step3), and write::
 

	
 
  python3 -m venv C:\Kallithea\Env
 

	
 
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++
 
(free) or similar text editor, as it handles well the EndOfLine
 
character differences between Unix and Windows
 
(http://notepad-plus-plus.org/)
 

	
 
For the sake of simplicity lets run it with the default settings. After
 
your edits (if any), in the previous Command Prompt, type::
 

	
 
  kallithea-cli db-create -c my.ini
 

	
 
.. warning:: This time a *new* database will be installed. You must
 
             follow a different process to later :ref:`upgrade <upgrade>`
 
             to a newer Kallithea version.
 

	
 
The script will ask you for confirmation about creating a NEW database,
 
answer yes (y)
 
The script will ask you for repository path, answer C:\\Kallithea\\Repos
 
(or similar)
 
The script will ask you for admin username and password, answer "admin"
 
+ "123456" (or whatever you want)
 
The script will ask you for admin mail, answer "admin@xxxx.com" (or
 
whatever you want)
 

	
 
If you make some mistake and the script does not end, don't worry, start
 
it again.
scripts/dbmigrate-test
Show inline comments
 
@@ -49,73 +49,73 @@ quiet_if_ok() (
 
    fi
 
)
 

	
 
HG() {
 
    "${HG:-hg}" --repository "$source_repo" "$@"
 
}
 

	
 
# If upgrading to "current revision", warn if working directory is dirty.
 
if [ ! "$to_rev" ] && [ "$(HG status -mard)" ]; then
 
    announce "Warning: Uncommitted changes in working directory will be ignored!"
 
fi
 

	
 
from_rev_hash=$(HG id --id --rev "${from_rev:-.}")
 
to_rev_hash=$(HG id --id --rev "${to_rev:-.}")
 
temp=$(readlink -f "$(mktemp --tmpdir -d 'dbmigrate-test.XXXXXX')")
 

	
 
cat <<EOD
 
Config file:    $config_file
 
EOD
 
sed -n -e 's/^sqlalchemy\.url *= */Database URL:   /p' "$config_file"
 
cat <<EOD
 
Working dir:    $temp
 
Repository:     $source_repo
 
Upgrade from:   $from_rev_hash (${from_rev:-current})
 
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
 
#!/bin/bash
 
# Validate the specified commits against test suite and other checks.
 

	
 
if [ -n "$VIRTUAL_ENV" ]; then
 
    echo "Please run this script from outside a virtualenv."
 
    exit 1
 
fi
 

	
 
if ! hg update --check -q .; then
 
    echo "Working dir is not clean, please commit/revert changes first."
 
    exit 1
 
fi
 

	
 
revset=$1
 
if [ -z "$revset" ]; then
 
    echo "Warning: no revisions specified, checking draft changes up to the current one."
 
    revset='draft() and ancestors(.)'
 
fi
 

	
 
venv=$(mktemp -d kallithea-validatecommits-env-XXXXXX)
 
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
 
    echo "$result: $rev (pytest)" >> "$resultfile"
 

	
 
    deactivate
 
    echo
 
done
scripts/validate-minimum-dependency-versions
Show inline comments
 
#!/bin/bash
 
# Test that installation of all dependencies works fine if versions are set to
 
# the minimum ones.
 

	
 
set -e
 

	
 
if [ -n "$VIRTUAL_ENV" ]; then
 
    echo "This script will create its own virtualenv - please don't run it inside an existing one." >&2
 
    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)