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
 
                    py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
 
                    """, returnStatus: true
 
            } else {
 
                bat script: """$activatevirtualenv
 
                    py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
 
                    """, returnStatus: true
 
            }
 
            sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1SQLITE./g" pytest_sqlite.xml'
 
            archiveArtifacts 'pytest_sqlite.xml'
 
            junit 'pytest_sqlite.xml'
 
            writeFile(file: '.coverage.sqlite', text: readFile('.coverage'))
 
            stash name: 'coverage.sqlite', includes: '.coverage.sqlite'
 
        }
 
    }
 
}
 

	
 
pytests['de'] = {
 
    node {
 
        if (isUnix()) {
 
            ws {
 
                deleteDir()
 
                unstash name: 'kallithea'
 
                withEnv(['LANG=de_DE.UTF-8',
 
                    'LANGUAGE=de',
 
                    'LC_ADDRESS=de_DE.UTF-8',
 
                    'LC_IDENTIFICATION=de_DE.UTF-8',
 
                    'LC_MEASUREMENT=de_DE.UTF-8',
 
                    'LC_MONETARY=de_DE.UTF-8',
 
                    'LC_NAME=de_DE.UTF-8',
 
                    'LC_NUMERIC=de_DE.UTF-8',
 
                    'LC_PAPER=de_DE.UTF-8',
 
                    'LC_TELEPHONE=de_DE.UTF-8',
 
                    'LC_TIME=de_DE.UTF-8',
 
                ]) {
 
                    sh script: """$activatevirtualenv
 
                        py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea
 
                        """, returnStatus: true
 
                }
 
                sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1DE./g" pytest_de.xml'
 
                archiveArtifacts 'pytest_de.xml'
 
                junit 'pytest_de.xml'
 
                writeFile(file: '.coverage.de', text: readFile('.coverage'))
 
                stash name: 'coverage.de', includes: '.coverage.de'
 
            }
 
        }
 
    }
 
}
 
pytests['mysql'] = {
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*
 
contain any non-trivial imports. The top level of a module should *not* be a
 
facade for the module functionality.
 

	
 
Common code for a module is often in ``base.py``.
 

	
 
The important part of the dependency graph is approximately linear. In the
 
following list, modules may only depend on modules below them:
 

	
 
``tests``
 
  Just get the job done - anything goes.
 

	
 
``bin/`` & ``config/`` & ``alembic/``
 
  The main entry points, defined in ``setup.py``. Note: The TurboGears template
 
  use ``config`` for the high WSGI application - this is not for low level
 
  configuration.
 

	
 
``controllers/``
 
  The top level web application, with TurboGears using the ``root`` controller
 
  as entry point, and ``routing`` dispatching to other controllers.
 

	
 
``templates/**.html``
 
  The "view", rendering to HTML. Invoked by controllers which can pass them
 
  anything from lower layers - especially ``helpers`` available as ``h`` will
 
  cut through all layers, and ``c`` gives access to global variables.
 

	
 
``lib/helpers.py``
 
  High level helpers, exposing everything to templates as ``h``. It depends on
 
  everything and has a huge dependency chain, so it should not be used for
 
  anything else. TODO.
 

	
 
``controllers/base.py``
 
  The base class of controllers, with lots of model knowledge.
 

	
 
``lib/auth.py``
 
  All things related to authentication. TODO.
 

	
 
``lib/utils.py``
 
  High level utils with lots of model knowledge. TODO.
 

	
 
``lib/hooks.py``
 
  Hooks into "everything" to give centralized logging to database, cache
 
  invalidation, and extension handling. TODO.
 

	
 
``model/``
 
  Convenience business logic wrappers around database models.
 

	
 
``model/db.py``
 
  Defines the database schema and provides some additional logic.
docs/installation.rst
Show inline comments
 
.. _installation:
 

	
 
==========================
 
Installation on Unix/Linux
 
==========================
 

	
 
The following describes three different ways of installing Kallithea:
 

	
 
- :ref:`installation-source`: The simplest way to keep the installation
 
  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
 
@@ -11,183 +11,183 @@ First time install
 
------------------
 

	
 
Target OS: Windows 7 and newer or Windows Server 2008 R2 and newer
 

	
 
Tested on Windows 8.1, Windows Server 2008 R2 and Windows Server 2012
 

	
 
To install on an older version of Windows, see `<installation_win_old.html>`_
 

	
 
Step 1 -- Install Python
 
^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Install Python 3. Latest version is recommended. If you need another version, they can run side by side.
 

	
 
- Download Python 3 from http://www.python.org/download/
 
- Choose and click on the version
 
- Click on "Windows X86-64 Installer" for x64 or "Windows x86 MSI installer" for Win32.
 
- Disable UAC or run the installer with admin privileges. If you chose to disable UAC, do not forget to reboot afterwards.
 

	
 
While writing this guide, the latest version was v3.8.1.
 
Remember the specific major and minor versions installed, because they will
 
be needed in the next step. In this case, it is "3.8".
 

	
 
Step 2 -- Python BIN
 
^^^^^^^^^^^^^^^^^^^^
 

	
 
Add Python BIN folder to the path. This can be done manually (editing
 
"PATH" environment variable) or by using Windows Support Tools that
 
come pre-installed in Windows Vista/7 and later.
 

	
 
Open a CMD and type::
 

	
 
  SETX PATH "%PATH%;[your-python-path]" /M
 

	
 
Please substitute [your-python-path] with your Python installation
 
path. Typically this is ``C:\\Python38``.
 

	
 
Step 3 -- Install pywin32 extensions
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Download pywin32 from:
 
http://sourceforge.net/projects/pywin32/files/
 

	
 
- Click on "pywin32" folder
 
- Click on the first folder (in this case, Build 219, maybe newer when you try)
 
- Choose the file ending with ".amd64-py3.x.exe" (".win32-py3.x.exe"
 
  for Win32) where x is the minor version of Python you installed.
 
  When writing this guide, the file was:
 
  http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win-amd64-py3.8.exe/download
 
  (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.
 

	
 
The script will ask you for confirmation about creating a new database, answer yes (y)
 

	
 
The script will ask you for the repository path, answer C:\\Kallithea\\Repos (or similar).
 

	
 
The script will ask you for the 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 a mistake and the script doesn't end, don't worry: start it again.
 

	
 
If you decided not to install Git, you will get errors about it that you can ignore.
 

	
 
Step 10 -- Running Kallithea
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
In the previous command prompt, being in the C:\\Kallithea\\Bin folder, type::
 

	
 
  gearbox serve -c my.ini
 

	
 
Open your web server, and go to http://127.0.0.1:5000
 

	
 
It works!! :-)
 

	
 
Remark:
 
If it does not work the first time, Ctrl-C the CMD process and start it again. Don't forget the "http://" in Internet Explorer.
 

	
 
What this guide does not cover:
 

	
 
- Installing Celery
 
- Running Kallithea as a Windows Service. You can investigate here:
 

	
 
  - http://pypi.python.org/pypi/wsgisvc
 
  - http://ryrobes.com/python/running-python-scripts-as-a-windows-service/
 
  - http://wiki.pylonshq.com/display/pylonscookbook/How+to+run+Pylons+as+a+Windows+service
 

	
 
- Using Apache. You can investigate here:
 

	
 
  - https://groups.google.com/group/rhodecode/msg/c433074e813ffdc4
docs/installation_win_old.rst
Show inline comments
 
@@ -77,174 +77,174 @@ Step 3 -- Install Win32py extensions
 

	
 
Download pywin32 from:
 
http://sourceforge.net/projects/pywin32/files/
 

	
 
- Click on "pywin32" folder
 
- Click on the first folder (in this case, Build 218, maybe newer when you try)
 
- Choose the file ending with ".win32-py3.x.exe" -> x being the minor
 
  version of Python you installed (in this case, 7)
 
  When writing this guide, the file was:
 
  http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win-amd64-py3.8.exe/download
 

	
 
  .. note::
 

	
 
     64-bit: Download and install the 64-bit version.
 
     At the time of writing you can find this at:
 
     http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win-amd64-py3.8.exe/download
 

	
 
Step 4 -- Python BIN
 
^^^^^^^^^^^^^^^^^^^^
 

	
 
Add Python BIN folder to the path
 

	
 
You have to add the Python folder to the path, you can do it manually
 
(editing "PATH" environment variable) or using Windows Support Tools
 
that came preinstalled in Vista/7 and can be installed in Windows XP.
 

	
 
- Using support tools on WINDOWS XP:
 
  If you use Windows XP you can install them using Windows XP CD and
 
  navigating to \SUPPORT\TOOLS. There, execute Setup.EXE (not MSI).
 
  Afterwards, open a CMD and type::
 

	
 
    SETX PATH "%PATH%;[your-python-path]" -M
 

	
 
  Close CMD (the path variable will be updated then)
 

	
 
- Using support tools on WINDOWS Vista/7:
 

	
 
  Open a CMD and type::
 

	
 
    SETX PATH "%PATH%;[your-python-path]" /M
 

	
 
  Please substitute [your-python-path] with your Python installation path.
 
  Typically: C:\\Python38
 

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

	
 
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.
 

	
 
Step 9 -- Running Kallithea
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
In the previous command prompt, being in the C:\\Kallithea\\Bin folder,
 
just type::
 

	
 
 gearbox serve -c my.ini
 

	
 
Open yout web server, and go to http://127.0.0.1:5000
 

	
 
It works!! :-)
 

	
 
Remark:
 
If it does not work first time, just Ctrl-C the CMD process and start it
 
again. Don't forget the "http://" in Internet Explorer
 

	
 
What this Guide does not cover:
 

	
 
- Installing Celery
 
- Running Kallithea as Windows Service. You can investigate here:
 

	
 
  - http://pypi.python.org/pypi/wsgisvc
 
  - http://ryrobes.com/python/running-python-scripts-as-a-windows-service/
 
  - http://wiki.pylonshq.com/display/pylonscookbook/How+to+run+Pylons+as+a+Windows+service
 

	
 
- Using Apache. You can investigate here:
 

	
 
  - https://groups.google.com/group/rhodecode/msg/c433074e813ffdc4
scripts/dbmigrate-test
Show inline comments
 
#!/bin/sh -e
 

	
 
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
 
    cat >&2 <<EOD
 
usage: $0 CONFIG_FILE FROM_REV [TO_REV]
 

	
 
Runs a database migration from FROM_REV to TO_REV (default: current
 
working directory parent), using the specified CONFIG_FILE (.ini file).
 

	
 
Test is run using a clean Kallithea install, in a temporary virtual
 
environment. FROM_REV and (optional) TO_REV should be Mercurial revision
 
identifiers (e.g. changeset hash or a version number tag). The working
 
directory is not touched, but the database referenced in the config file
 
will be (re)created.
 

	
 
Only SQLite is available out of the box; for MySQL or PostgreSQL, set
 
the EXTRA environment variable to the required package(s), and it'll
 
be installed in the virtual environment. (E.g. EXTRA=MySQL-python or
 
EXTRA=psycopg2.)
 

	
 
The temporary directory is not removed, allowing follow-up examination
 
of the upgrade results. It is, however, created in /tmp by default,
 
which many Linux distributions automatically clean at regular intervals.
 
EOD
 
    exit 1
 
fi
 

	
 
config_file=$(readlink -f "$1")
 
from_rev=$2
 
to_rev=$3
 
source_repo=$(dirname "$(dirname "$(readlink -f "$0")")")
 

	
 
announce() {
 
    echo
 
    echo "$1"
 
    echo
 
}
 

	
 
quiet_if_ok() (
 
    local output
 
    local st
 
    set +e
 
    output=$("$@" < /dev/null 2>&1)
 
    st=$?
 
    if [ $st -ne 0 ]; then
 
        echo "$output" >&2
 
        echo "Command $@ returned exit status $st." >&2
 
        exit 1
 
    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)