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