##// END OF EJS Templates
docs: when using venv with a clone, recommend using 'venv' as location...
Mads Kiilerich -
r8385:6bab9174 default
parent child Browse files
Show More
@@ -1,54 +1,55 b''
1 1 syntax: glob
2 2 *.pyc
3 3 *.swp
4 4 *.sqlite
5 5 *.tox
6 6 *.egg-info
7 7 *.egg
8 8 *.mo
9 9 *.orig
10 10 *.rej
11 11 *.bak
12 12 .eggs/
13 13
14 14 syntax: regexp
15 15 ^rcextensions
16 16 ^build
17 17 ^dist/
18 18 ^docs/build/
19 19 ^docs/_build/
20 20 ^data$
21 21 ^sql_dumps/
22 22 ^\.settings$
23 23 ^\.project$
24 24 ^\.pydevproject$
25 25 ^\.coverage$
26 26 ^kallithea/front-end/node_modules$
27 27 ^kallithea/front-end/package-lock\.json$
28 28 ^kallithea/front-end/theme\.less$
29 29 ^kallithea/front-end/tmp$
30 30 ^kallithea/public/codemirror$
31 31 ^kallithea/public/css/select2-spinner\.gif$
32 32 ^kallithea/public/css/select2\.png$
33 33 ^kallithea/public/css/select2x2\.png$
34 34 ^kallithea/public/css/style\.css$
35 35 ^kallithea/public/css/style\.css\.map$
36 36 ^kallithea/public/js/bootstrap\.js$
37 37 ^kallithea/public/js/dataTables\.bootstrap\.js$
38 38 ^kallithea/public/js/jquery\.atwho\.min\.js$
39 39 ^kallithea/public/js/jquery\.caret\.min\.js$
40 40 ^kallithea/public/js/jquery\.dataTables\.js$
41 41 ^kallithea/public/js/jquery\.flot\.js$
42 42 ^kallithea/public/js/jquery\.flot\.selection\.js$
43 43 ^kallithea/public/js/jquery\.flot\.time\.js$
44 44 ^kallithea/public/js/jquery\.min\.js$
45 45 ^kallithea/public/js/select2\.js$
46 46 ^kallithea\.db$
47 47 ^test\.db$
48 48 ^Kallithea\.egg-info$
49 49 ^my\.ini$
50 50 ^fabfile.py
51 51 ^\.idea$
52 52 ^\.cache$
53 53 ^\.pytest_cache$
54 ^venv$
54 55 /__pycache__$
@@ -1,337 +1,337 b''
1 1 .. _contributing:
2 2
3 3 =========================
4 4 Contributing to Kallithea
5 5 =========================
6 6
7 7 Kallithea is developed and maintained by its users. Please join us and scratch
8 8 your own itch.
9 9
10 10
11 11 Infrastructure
12 12 --------------
13 13
14 14 The main repository is hosted on Our Own Kallithea (aka OOK) at
15 15 https://kallithea-scm.org/repos/kallithea/, our self-hosted instance
16 16 of Kallithea.
17 17
18 18 For now, we use Bitbucket_ for `pull requests`_ and `issue tracking`_. The
19 19 issue tracker is for tracking bugs, not for support, discussion, or ideas --
20 20 please use the `mailing list`_ or :ref:`IRC <readme>` to reach the community.
21 21
22 22 We use Weblate_ to translate the user interface messages into languages other
23 23 than English. Join our project on `Hosted Weblate`_ to help us.
24 24 To register, you can use your Bitbucket or GitHub account. See :ref:`translations`
25 25 for more details.
26 26
27 27
28 28 Getting started
29 29 ---------------
30 30
31 31 To get started with Kallithea development run the following commands in your
32 32 bash shell::
33 33
34 34 hg clone https://kallithea-scm.org/repos/kallithea
35 35 cd kallithea
36 python3 -m venv ../kallithea-venv
37 . ../kallithea-venv/bin/activate
36 python3 -m venv venv
37 . venv/bin/activate
38 38 pip install --upgrade pip setuptools
39 39 pip install --upgrade -e . -r dev_requirements.txt python-ldap python-pam
40 40 kallithea-cli config-create my.ini
41 41 kallithea-cli db-create -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp
42 42 kallithea-cli front-end-build
43 43 gearbox serve -c my.ini --reload &
44 44 firefox http://127.0.0.1:5000/
45 45
46 46 If you plan to use Bitbucket_ for sending contributions, you can also fork
47 47 Kallithea on Bitbucket_ first (https://bitbucket.org/conservancy/kallithea) and
48 48 then replace the clone step above by a clone of your fork. In this case, please
49 49 see :ref:`contributing-guidelines` below for configuring your fork correctly.
50 50
51 51
52 52 Contribution flow
53 53 -----------------
54 54
55 55 Starting from an existing Kallithea clone, make sure it is up to date with the
56 56 latest upstream changes::
57 57
58 58 hg pull
59 59 hg update
60 60
61 61 Review the :ref:`contributing-guidelines` and :ref:`coding-guidelines`.
62 62
63 63 If you are new to Mercurial, refer to Mercurial `Quick Start`_ and `Beginners
64 64 Guide`_ on the Mercurial wiki.
65 65
66 66 Now, make some changes and test them (see :ref:`contributing-tests`). Don't
67 67 forget to add new tests to cover new functionality or bug fixes.
68 68
69 69 For documentation changes, run ``make html`` from the ``docs`` directory to
70 70 generate the HTML result, then review them in your browser.
71 71
72 72 Before submitting any changes, run the cleanup script::
73 73
74 74 ./scripts/run-all-cleanup
75 75
76 76 When you are completely ready, you can send your changes to the community for
77 77 review and inclusion. Most commonly used methods are sending patches to the
78 78 mailing list (via ``hg email``) or by creating a pull request on Bitbucket_.
79 79
80 80 .. _contributing-tests:
81 81
82 82
83 83 Running tests
84 84 -------------
85 85
86 86 After finishing your changes make sure all tests pass cleanly. Run the testsuite
87 87 by invoking ``py.test`` from the project root::
88 88
89 89 py.test
90 90
91 91 Note that on unix systems, the temporary directory (``/tmp`` or where
92 92 ``$TMPDIR`` points) must allow executable files; Git hooks must be executable,
93 93 and the test suite creates repositories in the temporary directory. Linux
94 94 systems with /tmp mounted noexec will thus fail.
95 95
96 96 Tests can be run on PostgreSQL like::
97 97
98 98 sudo -u postgres createuser 'kallithea-test' --pwprompt # password password
99 99 sudo -u postgres createdb 'kallithea-test' --owner 'kallithea-test'
100 100 REUSE_TEST_DB='postgresql://kallithea-test:password@localhost/kallithea-test' py.test
101 101
102 102 Tests can be run on MariaDB/MySQL like::
103 103
104 104 echo "GRANT ALL PRIVILEGES ON \`kallithea-test\`.* TO 'kallithea-test'@'localhost' IDENTIFIED BY 'password'" | sudo -u mysql mysql
105 105 TEST_DB='mysql://kallithea-test:password@localhost/kallithea-test?charset=utf8mb4' py.test
106 106
107 107 You can also use ``tox`` to run the tests with all supported Python versions.
108 108
109 109 When running tests, Kallithea generates a `test.ini` based on template values
110 110 in `kallithea/tests/conftest.py` and populates the SQLite database specified
111 111 there.
112 112
113 113 It is possible to avoid recreating the full test database on each invocation of
114 114 the tests, thus eliminating the initial delay. To achieve this, run the tests as::
115 115
116 116 gearbox serve -c /tmp/kallithea-test-XXX/test.ini --pid-file=test.pid --daemon
117 117 KALLITHEA_WHOOSH_TEST_DISABLE=1 KALLITHEA_NO_TMP_PATH=1 py.test
118 118 kill -9 $(cat test.pid)
119 119
120 120 In these commands, the following variables are used::
121 121
122 122 KALLITHEA_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests
123 123 KALLITHEA_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for testing_vcs_operations
124 124
125 125 You can run individual tests by specifying their path as argument to py.test.
126 126 py.test also has many more options, see `py.test -h`. Some useful options
127 127 are::
128 128
129 129 -k EXPRESSION only run tests which match the given substring
130 130 expression. An expression is a python evaluable
131 131 expression where all names are substring-matched
132 132 against test names and their parent classes. Example:
133 133 -x, --exitfirst exit instantly on first error or failed test.
134 134 --lf rerun only the tests that failed at the last run (or
135 135 all if none failed)
136 136 --ff run all tests but run the last failures first. This
137 137 may re-order tests and thus lead to repeated fixture
138 138 setup/teardown
139 139 --pdb start the interactive Python debugger on errors.
140 140 -s, --capture=no don't capture stdout (any stdout output will be
141 141 printed immediately)
142 142
143 143 Performance tests
144 144 ^^^^^^^^^^^^^^^^^
145 145
146 146 A number of performance tests are present in the test suite, but they are
147 147 not run in a standard test run. These tests are useful to
148 148 evaluate the impact of certain code changes with respect to performance.
149 149
150 150 To run these tests::
151 151
152 152 env TEST_PERFORMANCE=1 py.test kallithea/tests/performance
153 153
154 154 To analyze performance, you could install pytest-profiling_, which enables the
155 155 --profile and --profile-svg options to py.test.
156 156
157 157 .. _pytest-profiling: https://github.com/manahl/pytest-plugins/tree/master/pytest-profiling
158 158
159 159 .. _contributing-guidelines:
160 160
161 161
162 162 Contribution guidelines
163 163 -----------------------
164 164
165 165 Kallithea is GPLv3 and we assume all contributions are made by the
166 166 committer/contributor and under GPLv3 unless explicitly stated. We do care a
167 167 lot about preservation of copyright and license information for existing code
168 168 that is brought into the project.
169 169
170 170 Contributions will be accepted in most formats -- such as pull requests on
171 171 Bitbucket, something hosted on your own Kallithea instance, or patches sent by
172 172 email to the `kallithea-general`_ mailing list.
173 173
174 174 When contributing via Bitbucket, please make your fork of
175 175 https://bitbucket.org/conservancy/kallithea/ `non-publishing`_ -- it is one of
176 176 the settings on "Repository details" page. This ensures your commits are in
177 177 "draft" phase and makes it easier for you to address feedback and for project
178 178 maintainers to integrate your changes.
179 179
180 180 .. _non-publishing: https://www.mercurial-scm.org/wiki/Phases#Publishing_Repository
181 181
182 182 Make sure to test your changes both manually and with the automatic tests
183 183 before posting.
184 184
185 185 We care about quality and review and keeping a clean repository history. We
186 186 might give feedback that requests polishing contributions until they are
187 187 "perfect". We might also rebase and collapse and make minor adjustments to your
188 188 changes when we apply them.
189 189
190 190 We try to make sure we have consensus on the direction the project is taking.
191 191 Everything non-sensitive should be discussed in public -- preferably on the
192 192 mailing list. We aim at having all non-trivial changes reviewed by at least
193 193 one other core developer before pushing. Obvious non-controversial changes will
194 194 be handled more casually.
195 195
196 196 There is a main development branch ("default") which is generally stable so that
197 197 it can be (and is) used in production. There is also a "stable" branch that is
198 198 almost exclusively reserved for bug fixes or trivial changes. Experimental
199 199 changes should live elsewhere (for example in a pull request) until they are
200 200 ready.
201 201
202 202 .. _coding-guidelines:
203 203
204 204
205 205 Coding guidelines
206 206 -----------------
207 207
208 208 We don't have a formal coding/formatting standard. We are currently using a mix
209 209 of Mercurial's (https://www.mercurial-scm.org/wiki/CodingStyle), pep8, and
210 210 consistency with existing code. Run ``scripts/run-all-cleanup`` before
211 211 committing to ensure some basic code formatting consistency.
212 212
213 213 We support Python 3.6 and later.
214 214
215 215 We try to support the most common modern web browsers. IE9 is still supported
216 216 to the extent it is feasible, IE8 is not.
217 217
218 218 We primarily support Linux and OS X on the server side but Windows should also work.
219 219
220 220 HTML templates should use 2 spaces for indentation ... but be pragmatic. We
221 221 should use templates cleverly and avoid duplication. We should use reasonable
222 222 semantic markup with element classes and IDs that can be used for styling and testing.
223 223 We should only use inline styles in places where it really is semantic (such as
224 224 ``display: none``).
225 225
226 226 JavaScript must use ``;`` between/after statements. Indentation 4 spaces. Inline
227 227 multiline functions should be indented two levels -- one for the ``()`` and one for
228 228 ``{}``.
229 229 Variables holding jQuery objects should be named with a leading ``$``.
230 230
231 231 Commit messages should have a leading short line summarizing the changes. For
232 232 bug fixes, put ``(Issue #123)`` at the end of this line.
233 233
234 234 Use American English grammar and spelling overall. Use `English title case`_ for
235 235 page titles, button labels, headers, and 'labels' for fields in forms.
236 236
237 237 .. _English title case: https://en.wikipedia.org/wiki/Capitalization#Title_case
238 238
239 239 Template helpers (that is, everything in ``kallithea.lib.helpers``)
240 240 should only be referenced from templates. If you need to call a
241 241 helper from the Python code, consider moving the function somewhere
242 242 else (e.g. to the model).
243 243
244 244 Notes on the SQLAlchemy session
245 245 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
246 246
247 247 Each HTTP request runs inside an independent SQLAlchemy session (as well
248 248 as in an independent database transaction). ``Session`` is the session manager
249 249 and factory. ``Session()`` will create a new session on-demand or return the
250 250 current session for the active thread. Many database operations are methods on
251 251 such session instances. The session will generally be removed by
252 252 TurboGears automatically.
253 253
254 254 Database model objects
255 255 (almost) always belong to a particular SQLAlchemy session, which means
256 256 that SQLAlchemy will ensure that they're kept in sync with the database
257 257 (but also means that they cannot be shared across requests).
258 258
259 259 Objects can be added to the session using ``Session().add``, but this is
260 260 rarely needed:
261 261
262 262 * When creating a database object by calling the constructor directly,
263 263 it must explicitly be added to the session.
264 264
265 265 * When creating an object using a factory function (like
266 266 ``create_repo``), the returned object has already (by convention)
267 267 been added to the session, and should not be added again.
268 268
269 269 * When getting an object from the session (via ``Session().query`` or
270 270 any of the utility functions that look up objects in the database),
271 271 it's already part of the session, and should not be added again.
272 272 SQLAlchemy monitors attribute modifications automatically for all
273 273 objects it knows about and syncs them to the database.
274 274
275 275 SQLAlchemy also flushes changes to the database automatically; manually
276 276 calling ``Session().flush`` is usually only necessary when the Python
277 277 code needs the database to assign an "auto-increment" primary key ID to
278 278 a freshly created model object (before flushing, the ID attribute will
279 279 be ``None``).
280 280
281 281 Debugging
282 282 ^^^^^^^^^
283 283
284 284 A good way to trace what Kallithea is doing is to keep an eye on the output on
285 285 stdout/stderr of the server process. Perhaps change ``my.ini`` to log at
286 286 ``DEBUG`` or ``INFO`` level, especially ``[logger_kallithea]``, but perhaps
287 287 also other loggers. It is often easier to add additional ``log`` or ``print``
288 288 statements than to use a Python debugger.
289 289
290 290 Sometimes it is simpler to disable ``errorpage.enabled`` and perhaps also
291 291 ``trace_errors.enable`` to expose raw errors instead of adding extra
292 292 processing. Enabling ``debug`` can be helpful for showing and exploring
293 293 tracebacks in the browser, but is also insecure and will add extra processing.
294 294
295 295 TurboGears2 DebugBar
296 296 ^^^^^^^^^^^^^^^^^^^^
297 297
298 298 It is possible to enable the TurboGears2-provided DebugBar_, a toolbar overlayed
299 299 over the Kallithea web interface, allowing you to see:
300 300
301 301 * timing information of the current request, including profiling information
302 302 * request data, including GET data, POST data, cookies, headers and environment
303 303 variables
304 304 * a list of executed database queries, including timing and result values
305 305
306 306 DebugBar is only activated when ``debug = true`` is set in the configuration
307 307 file. This is important, because the DebugBar toolbar will be visible for all
308 308 users, and allow them to see information they should not be allowed to see. Like
309 309 is anyway the case for ``debug = true``, do not use this in production!
310 310
311 311 To enable DebugBar, install ``tgext.debugbar`` and ``kajiki`` (typically via
312 312 ``pip``) and restart Kallithea (in debug mode).
313 313
314 314
315 315 "Roadmap"
316 316 ---------
317 317
318 318 We do not have a road map but are waiting for your contributions. Refer to the
319 319 wiki_ for some ideas of places we might want to go -- contributions in these
320 320 areas are very welcome.
321 321
322 322
323 323 Thank you for your contribution!
324 324 --------------------------------
325 325
326 326
327 327 .. _Weblate: http://weblate.org/
328 328 .. _issue tracking: https://bitbucket.org/conservancy/kallithea/issues?status=new&status=open
329 329 .. _pull requests: https://bitbucket.org/conservancy/kallithea/pull-requests
330 330 .. _bitbucket: http://bitbucket.org/
331 331 .. _mailing list: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general
332 332 .. _kallithea-general: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general
333 333 .. _Hosted Weblate: https://hosted.weblate.org/projects/kallithea/kallithea/
334 334 .. _wiki: https://bitbucket.org/conservancy/kallithea/wiki/Home
335 335 .. _DebugBar: https://github.com/TurboGears/tgext.debugbar
336 336 .. _Quick Start: https://www.mercurial-scm.org/wiki/QuickStart
337 337 .. _Beginners Guide: https://www.mercurial-scm.org/wiki/BeginnersGuides
@@ -1,157 +1,159 b''
1 1 .. _installation:
2 2
3 3 ==========================
4 4 Installation on Unix/Linux
5 5 ==========================
6 6
7 7 The following describes three different ways of installing Kallithea:
8 8
9 9 - :ref:`installation-source`: The simplest way to keep the installation
10 10 up-to-date and track any local customizations is to run directly from
11 11 source in a Kallithea repository clone, preferably inside a virtualenv
12 12 virtual Python environment.
13 13
14 14 - :ref:`installation-virtualenv`: If you prefer to only use released versions
15 15 of Kallithea, the recommended method is to install Kallithea in a virtual
16 16 Python environment using `virtualenv`. The advantages of this method over
17 17 direct installation is that Kallithea and its dependencies are completely
18 18 contained inside the virtualenv (which also means you can have multiple
19 19 installations side by side or remove it entirely by just removing the
20 20 virtualenv directory) and does not require root privileges.
21 21
22 22 - :ref:`installation-without-virtualenv`: The alternative method of installing
23 23 a Kallithea release is using standard pip. The package will be installed in
24 24 the same location as all other Python packages you have ever installed. As a
25 25 result, removing it is not as straightforward as with a virtualenv, as you'd
26 26 have to remove its dependencies manually and make sure that they are not
27 27 needed by other packages.
28 28
29 29 Regardless of the installation method you may need to make sure you have
30 30 appropriate development packages installed, as installation of some of the
31 31 Kallithea dependencies requires a working C compiler and libffi library
32 32 headers. Depending on your configuration, you may also need to install
33 33 Git and development packages for the database of your choice.
34 34
35 35 For Debian and Ubuntu, the following command will ensure that a reasonable
36 36 set of dependencies is installed::
37 37
38 38 sudo apt-get install build-essential git libffi-dev python3-dev
39 39
40 40 For Fedora and RHEL-derivatives, the following command will ensure that a
41 41 reasonable set of dependencies is installed::
42 42
43 43 sudo yum install gcc git libffi-devel python3-devel
44 44
45 45 .. _installation-source:
46 46
47 47
48 48 Installation from repository source
49 49 -----------------------------------
50 50
51 51 To install Kallithea in a virtualenv using the stable branch of the development
52 52 repository, use the following commands in your bash shell::
53 53
54 54 hg clone https://kallithea-scm.org/repos/kallithea -u stable
55 55 cd kallithea
56 python3 -m venv ../kallithea-venv
57 . ../kallithea-venv/bin/activate
56 python3 -m venv venv
57 . venv/bin/activate
58 58 pip install --upgrade pip setuptools
59 59 pip install --upgrade -e .
60 60 python3 setup.py compile_catalog # for translation of the UI
61 61
62 62 .. note::
63 63 This will install all Python dependencies into the virtualenv. Kallithea
64 64 itself will however only be installed as a pointer to the source location.
65 65 The source clone must thus be kept in the same location, and it shouldn't be
66 66 updated to other revisions unless you want to upgrade. Edits in the source
67 67 tree will have immediate impact (possibly after a restart of the service).
68 68
69 69 You can now proceed to :ref:`install-front-end`.
70 70
71 71 .. _installation-virtualenv:
72 72
73 73
74 74 Installing a released version in a virtualenv
75 75 ---------------------------------------------
76 76
77 77 It is highly recommended to use a separate virtualenv for installing Kallithea.
78 78 This way, all libraries required by Kallithea will be installed separately from your
79 79 main Python installation and other applications and things will be less
80 80 problematic when upgrading the system or Kallithea.
81 81 An additional benefit of virtualenv is that it doesn't require root privileges.
82 82
83 83 - Don't install as root - install as a dedicated user like ``kallithea``.
84 If necessary, create the top directory for the virtualenv (like
85 ``/srv/kallithea/venv``) as root and assign ownership to the user.
84 86
85 87 - Create a new virtual environment, for example in ``/srv/kallithea/venv``,
86 88 specifying the right Python binary::
87 89
88 90 python3 -m venv /srv/kallithea/venv
89 91
90 92 - Activate the virtualenv in your current shell session and make sure the
91 93 basic requirements are up-to-date by running the following commands in your
92 94 bash shell::
93 95
94 96 . /srv/kallithea/venv/bin/activate
95 97 pip install --upgrade pip setuptools
96 98
97 99 .. note:: You can't use UNIX ``sudo`` to source the ``activate`` script; it
98 100 will "activate" a shell that terminates immediately.
99 101
100 102 - Install Kallithea in the activated virtualenv::
101 103
102 104 pip install --upgrade kallithea
103 105
104 106 .. note:: Some dependencies are optional. If you need them, install them in
105 107 the virtualenv too::
106 108
107 109 pip install --upgrade kallithea python-ldap python-pam psycopg2
108 110
109 111 This might require installation of development packages using your
110 112 distribution's package manager.
111 113
112 114 Alternatively, download a .tar.gz from http://pypi.python.org/pypi/Kallithea,
113 115 extract it and install from source by running::
114 116
115 117 pip install --upgrade .
116 118
117 119 - This will install Kallithea together with all other required
118 120 Python libraries into the activated virtualenv.
119 121
120 122 You can now proceed to :ref:`install-front-end`.
121 123
122 124 .. _installation-without-virtualenv:
123 125
124 126
125 127 Installing a released version without virtualenv
126 128 ------------------------------------------------
127 129
128 130 For installation without virtualenv, 'just' use::
129 131
130 132 pip install kallithea
131 133
132 134 Note that this method requires root privileges and will install packages
133 135 globally without using the system's package manager.
134 136
135 137 To install as a regular user in ``~/.local``, you can use::
136 138
137 139 pip install --user kallithea
138 140
139 141 You can now proceed to :ref:`install-front-end`.
140 142
141 143 .. _install-front-end:
142 144
143 145
144 146 Prepare front-end files
145 147 -----------------------
146 148
147 149 Finally, the front-end files with CSS and JavaScript must be prepared. This
148 150 depends on having some commands available in the shell search path: ``npm``
149 151 version 6 or later, and ``node.js`` (version 12 or later) available as
150 152 ``node``. The installation method for these dependencies varies between
151 153 operating systems and distributions.
152 154
153 155 Prepare the front-end by running::
154 156
155 157 kallithea-cli front-end-build
156 158
157 159 You can now proceed to :ref:`setup`.
@@ -1,270 +1,270 b''
1 1 .. _overview:
2 2
3 3 =====================
4 4 Installation overview
5 5 =====================
6 6
7 7 Some overview and some details that can help understanding the options when
8 8 installing Kallithea.
9 9
10 10 1. **Prepare environment and external dependencies.**
11 11 Kallithea needs:
12 12
13 13 * A filesystem where the Mercurial and Git repositories can be stored.
14 14 * A database where meta data can be stored.
15 15 * A Python environment where the Kallithea application and its dependencies
16 16 can be installed.
17 17 * A web server that can host the Kallithea web application using the WSGI
18 18 API.
19 19
20 20 2. **Install Kallithea software.**
21 21 This makes the ``kallithea-cli`` command line tool available.
22 22
23 23 3. **Prepare front-end files**
24 24 Some front-end files must be fetched or created using ``npm`` and ``node``
25 25 tooling so they can be served to the client as static files.
26 26
27 27 4. **Create low level configuration file.**
28 28 Use ``kallithea-cli config-create`` to create a ``.ini`` file with database
29 29 connection info, mail server information, configuration for the specified
30 30 web server, etc.
31 31
32 32 5. **Populate the database.**
33 33 Use ``kallithea-cli db-create`` with the ``.ini`` file to create the
34 34 database schema and insert the most basic information: the location of the
35 35 repository store and an initial local admin user.
36 36
37 37 6. **Configure the web server.**
38 38 The web server must invoke the WSGI entrypoint for the Kallithea software
39 39 using the ``.ini`` file (and thus the database). This makes the web
40 40 application available so the local admin user can log in and tweak the
41 41 configuration further.
42 42
43 43 7. **Configure users.**
44 44 The initial admin user can create additional local users, or configure how
45 45 users can be created and authenticated from other user directories.
46 46
47 47 See the subsequent sections, the separate OS-specific instructions, and
48 48 :ref:`setup` for details on these steps.
49 49
50 50
51 51 File system location
52 52 --------------------
53 53
54 54 Kallithea can be installed in many different ways. The main parts are:
55 55
56 56 - A location for the Kallithea software and its dependencies. This includes
57 57 the Python code, template files, and front-end code. After installation, this
58 58 will be read-only (except when upgrading).
59 59
60 60 - A location for the ``.ini`` configuration file that tells the Kallithea
61 61 instance which database to use (and thus also the repository location).
62 62 After installation, this will be read-only (except when upgrading).
63 63
64 64 - A location for various data files and caches for the Kallithea instance. This
65 65 is by default in a ``data`` directory next to the ``.ini`` file. This will
66 66 have to be writable by the running Kallithea service.
67 67
68 68 - A database. The ``.ini`` file specifies which database to use. The database
69 69 will be a separate service and live elsewhere in the filesystem if using
70 70 PostgreSQL or MariaDB/MySQL. If using SQLite, it will by default live next to
71 71 the ``.ini`` file, as ``kallithea.db``.
72 72
73 73 - A location for the repositories that are hosted by this Kallithea instance.
74 74 This will have to be writable by the running Kallithea service. The path to
75 75 this location will be configured in the database.
76 76
77 77 For simple setups, it is fine to just use something like a ``kallithea`` user
78 78 with home in ``/home/kallithea`` and place everything there.
79 79
80 80 For experiments, it might be convenient to run everything as yourself and work
81 81 inside a clone of Kallithea, with the ``.ini`` and SQLite database in the root
82 of the clone.
82 of the clone, and a virtualenv in ``venv``.
83 83
84 84
85 85 Python environment
86 86 ------------------
87 87
88 88 **Kallithea** is written entirely in Python_ and requires Python version
89 89 3.6 or higher.
90 90
91 91 Given a Python installation, there are different ways of providing the
92 92 environment for running Python applications. Each of them pretty much
93 93 corresponds to a ``site-packages`` directory somewhere where packages can be
94 94 installed.
95 95
96 96 Kallithea itself can be run from source or be installed, but even when running
97 97 from source, there are some dependencies that must be installed in the Python
98 98 environment used for running Kallithea.
99 99
100 100 - Packages *could* be installed in Python's ``site-packages`` directory ... but
101 101 that would require running pip_ as root and it would be hard to uninstall or
102 102 upgrade and is probably not a good idea unless using a package manager.
103 103
104 104 - Packages could also be installed in ``~/.local`` ... but that is probably
105 105 only a good idea if using a dedicated user per application or instance.
106 106
107 107 - Finally, it can be installed in a virtualenv. That is a very lightweight
108 108 "container" where each Kallithea instance can get its own dedicated and
109 109 self-contained virtual environment.
110 110
111 111 We recommend using virtualenv for installing Kallithea.
112 112
113 113
114 114 Locale environment
115 115 ------------------
116 116
117 117 In order to ensure a correct functioning of Kallithea with respect to non-ASCII
118 118 characters in user names, file paths, commit messages, etc., it is very
119 119 important that Kallithea is run with a correct `locale` configuration.
120 120
121 121 On Unix, environment variables like ``LANG`` or ``LC_ALL`` can specify a language (like
122 122 ``en_US``) and encoding (like ``UTF-8``) to use for code points outside the ASCII
123 123 range. The flexibility of supporting multiple encodings of Unicode has the flip
124 124 side of having to specify which encoding to use - especially for Mercurial.
125 125
126 126 It depends on the OS distribution and system configuration which locales are
127 127 available. For example, some Docker containers based on Debian default to only
128 128 supporting the ``C`` language, while other Linux environments have ``en_US`` but not
129 129 ``C``. The ``locale -a`` command will show which values are available on the
130 130 current system. Regardless of the actual language, you should normally choose a
131 131 locale that has the ``UTF-8`` encoding (note that spellings ``utf8``, ``utf-8``,
132 132 ``UTF8``, ``UTF-8`` are all referring to the same thing)
133 133
134 134 For technical reasons, the locale configuration **must** be provided in the
135 135 environment in which Kallithea runs - it cannot be specified in the ``.ini`` file.
136 136 How to practically do this depends on the web server that is used and the way it
137 137 is started. For example, gearbox is often started by a normal user, either
138 138 manually or via a script. In this case, the required locale environment
139 139 variables can be provided directly in that user's environment or in the script.
140 140 However, web servers like Apache are often started at boot via an init script or
141 141 service file. Modifying the environment for this case would thus require
142 142 root/administrator privileges. Moreover, that environment would dictate the
143 143 settings for all web services running under that web server, Kallithea being
144 144 just one of them. Specifically in the case of Apache with ``mod_wsgi``, the
145 145 locale can be set for a specific service in its ``WSGIDaemonProcess`` directive,
146 146 using the ``lang`` parameter.
147 147
148 148
149 149 Installation methods
150 150 --------------------
151 151
152 152 Kallithea must be installed on a server. Kallithea is installed in a Python
153 153 environment so it can use packages that are installed there and make itself
154 154 available for other packages.
155 155
156 156 Two different cases will pretty much cover the options for how it can be
157 157 installed.
158 158
159 159 - The Kallithea source repository can be cloned and used -- it is kept stable and
160 160 can be used in production. The Kallithea maintainers use the development
161 161 branch in production. The advantage of installation from source and regularly
162 162 updating it is that you take advantage of the most recent improvements. Using
163 163 it directly from a DVCS also means that it is easy to track local customizations.
164 164
165 165 Running ``pip install -e .`` in the source will use pip to install the
166 166 necessary dependencies in the Python environment and create a
167 167 ``.../site-packages/Kallithea.egg-link`` file there that points at the Kallithea
168 168 source.
169 169
170 170 - Kallithea can also be installed from ready-made packages using a package manager.
171 171 The official released versions are available on PyPI_ and can be downloaded and
172 172 installed with all dependencies using ``pip install kallithea``.
173 173
174 174 With this method, Kallithea is installed in the Python environment as any
175 175 other package, usually as a ``.../site-packages/Kallithea-X-py3.8.egg/``
176 176 directory with Python files and everything else that is needed.
177 177
178 178 (``pip install kallithea`` from a source tree will do pretty much the same
179 179 but build the Kallithea package itself locally instead of downloading it.)
180 180
181 181 .. note::
182 182 Kallithea includes front-end code that needs to be processed to prepare
183 183 static files that can be served at run time and used on the client side. The
184 184 tool npm_ is used to download external dependencies and orchestrate the
185 185 processing. The ``npm`` binary must thus be available at install time but is
186 186 not used at run time.
187 187
188 188
189 189 Web server
190 190 ----------
191 191
192 192 Kallithea is (primarily) a WSGI_ application that must be run from a web
193 193 server that serves WSGI applications over HTTP.
194 194
195 195 Kallithea itself is not serving HTTP (or HTTPS); that is the web server's
196 196 responsibility. Kallithea does however need to know its own user facing URL
197 197 (protocol, address, port and path) for each HTTP request. Kallithea will
198 198 usually use its own HTML/cookie based authentication but can also be configured
199 199 to use web server authentication.
200 200
201 201 There are several web server options:
202 202
203 203 - Kallithea uses the Gearbox_ tool as command line interface. Gearbox provides
204 204 ``gearbox serve`` as a convenient way to launch a Python WSGI / web server
205 205 from the command line. That is perfect for development and evaluation.
206 206 Actual use in production might have different requirements and need extra
207 207 work to make it manageable as a scalable system service.
208 208
209 209 Gearbox comes with its own built-in web server for development but Kallithea
210 210 defaults to using Waitress_. Gunicorn_ and Gevent_ are also options. These
211 211 web servers have different limited feature sets.
212 212
213 213 The web server used by ``gearbox serve`` is configured in the ``.ini`` file.
214 214 Create it with ``config-create`` using for example ``http_server=waitress``
215 215 to get a configuration starting point for your choice of web server.
216 216
217 217 (Gearbox will do like ``paste`` and use the WSGI application entry point
218 218 ``kallithea.config.application:make_app`` as specified in ``setup.py``.)
219 219
220 220 - `Apache httpd`_ can serve WSGI applications directly using mod_wsgi_ and a
221 221 simple Python file with the necessary configuration. This is a good option if
222 222 Apache is an option.
223 223
224 224 - uWSGI_ is also a full web server with built-in WSGI module. Use
225 225 ``config-create`` with ``http_server=uwsgi`` to get a ``.ini`` file with
226 226 uWSGI configuration.
227 227
228 228 - IIS_ can also server WSGI applications directly using isapi-wsgi_.
229 229
230 230 - A `reverse HTTP proxy <https://en.wikipedia.org/wiki/Reverse_proxy>`_
231 231 can be put in front of another web server which has WSGI support.
232 232 Such a layered setup can be complex but might in some cases be the right
233 233 option, for example to standardize on one internet-facing web server, to add
234 234 encryption or special authentication or for other security reasons, to
235 235 provide caching of static files, or to provide load balancing or fail-over.
236 236 Nginx_, Varnish_ and HAProxy_ are often used for this purpose, often in front
237 237 of a ``gearbox serve`` that somehow is wrapped as a service.
238 238
239 239 The best option depends on what you are familiar with and the requirements for
240 240 performance and stability. Also, keep in mind that Kallithea mainly is serving
241 241 dynamically generated pages from a relatively slow Python process. Kallithea is
242 242 also often used inside organizations with a limited amount of users and thus no
243 243 continuous hammering from the internet.
244 244
245 245 .. note::
246 246 Kallithea, the libraries it uses, and Python itself do in several places use
247 247 simple caching in memory. Caches and memory are not always released in a way
248 248 that is suitable for long-running processes. They might appear to be leaking
249 249 memory. The worker processes should thus regularly be restarted - for
250 250 example after 1000 requests and/or one hour. This can usually be done by the
251 251 web server or the tool used for running it as a system service.
252 252
253 253
254 254 .. _Python: http://www.python.org/
255 255 .. _Gunicorn: http://gunicorn.org/
256 256 .. _Gevent: http://www.gevent.org/
257 257 .. _Waitress: https://docs.pylonsproject.org/projects/waitress/
258 258 .. _Gearbox: https://turbogears.readthedocs.io/en/latest/turbogears/gearbox.html
259 259 .. _PyPI: https://pypi.python.org/pypi
260 260 .. _Apache httpd: http://httpd.apache.org/
261 261 .. _mod_wsgi: https://modwsgi.readthedocs.io/
262 262 .. _isapi-wsgi: https://github.com/hexdump42/isapi-wsgi
263 263 .. _uWSGI: https://uwsgi-docs.readthedocs.io/
264 264 .. _nginx: http://nginx.org/en/
265 265 .. _iis: http://en.wikipedia.org/wiki/Internet_Information_Services
266 266 .. _pip: http://en.wikipedia.org/wiki/Pip_%28package_manager%29
267 267 .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
268 268 .. _HAProxy: http://www.haproxy.org/
269 269 .. _Varnish: https://www.varnish-cache.org/
270 270 .. _npm: https://www.npmjs.com/
General Comments 0
You need to be logged in to leave comments. Login now