Show More
@@ -1,313 +1,313 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:: |
|
31 | To get started with Kallithea development:: | |
32 |
|
32 | |||
33 | hg clone https://kallithea-scm.org/repos/kallithea |
|
33 | hg clone https://kallithea-scm.org/repos/kallithea | |
34 | cd kallithea |
|
34 | cd kallithea | |
35 | virtualenv ../kallithea-venv |
|
35 | virtualenv ../kallithea-venv | |
36 | source ../kallithea-venv/bin/activate |
|
36 | source ../kallithea-venv/bin/activate | |
37 | pip install --upgrade pip setuptools |
|
37 | pip install --upgrade pip setuptools | |
38 | pip install --upgrade -e . -r dev_requirements.txt |
|
38 | pip install --upgrade -e . -r dev_requirements.txt python-ldap python-pam | |
39 | kallithea-cli config-create my.ini |
|
39 | kallithea-cli config-create my.ini | |
40 | kallithea-cli db-create -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp |
|
40 | kallithea-cli db-create -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp | |
41 | kallithea-cli front-end-build |
|
41 | kallithea-cli front-end-build | |
42 | gearbox serve -c my.ini --reload & |
|
42 | gearbox serve -c my.ini --reload & | |
43 | firefox http://127.0.0.1:5000/ |
|
43 | firefox http://127.0.0.1:5000/ | |
44 |
|
44 | |||
45 | If you plan to use Bitbucket_ for sending contributions, you can also fork |
|
45 | If you plan to use Bitbucket_ for sending contributions, you can also fork | |
46 | Kallithea on Bitbucket_ first (https://bitbucket.org/conservancy/kallithea) and |
|
46 | Kallithea on Bitbucket_ first (https://bitbucket.org/conservancy/kallithea) and | |
47 | then replace the clone step above by a clone of your fork. In this case, please |
|
47 | then replace the clone step above by a clone of your fork. In this case, please | |
48 | see :ref:`contributing-guidelines` below for configuring your fork correctly. |
|
48 | see :ref:`contributing-guidelines` below for configuring your fork correctly. | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | Contribution flow |
|
51 | Contribution flow | |
52 | ----------------- |
|
52 | ----------------- | |
53 |
|
53 | |||
54 | Starting from an existing Kallithea clone, make sure it is up to date with the |
|
54 | Starting from an existing Kallithea clone, make sure it is up to date with the | |
55 | latest upstream changes:: |
|
55 | latest upstream changes:: | |
56 |
|
56 | |||
57 | hg pull |
|
57 | hg pull | |
58 | hg update |
|
58 | hg update | |
59 |
|
59 | |||
60 | Review the :ref:`contributing-guidelines` and :ref:`coding-guidelines`. |
|
60 | Review the :ref:`contributing-guidelines` and :ref:`coding-guidelines`. | |
61 |
|
61 | |||
62 | If you are new to Mercurial, refer to Mercurial `Quick Start`_ and `Beginners |
|
62 | If you are new to Mercurial, refer to Mercurial `Quick Start`_ and `Beginners | |
63 | Guide`_ on the Mercurial wiki. |
|
63 | Guide`_ on the Mercurial wiki. | |
64 |
|
64 | |||
65 | Now, make some changes and test them (see :ref:`contributing-tests`). Don't |
|
65 | Now, make some changes and test them (see :ref:`contributing-tests`). Don't | |
66 | forget to add new tests to cover new functionality or bug fixes. |
|
66 | forget to add new tests to cover new functionality or bug fixes. | |
67 |
|
67 | |||
68 | For documentation changes, run ``make html`` from the ``docs`` directory to |
|
68 | For documentation changes, run ``make html`` from the ``docs`` directory to | |
69 | generate the HTML result, then review them in your browser. |
|
69 | generate the HTML result, then review them in your browser. | |
70 |
|
70 | |||
71 | Before submitting any changes, run the cleanup script:: |
|
71 | Before submitting any changes, run the cleanup script:: | |
72 |
|
72 | |||
73 | ./scripts/run-all-cleanup |
|
73 | ./scripts/run-all-cleanup | |
74 |
|
74 | |||
75 | When you are completely ready, you can send your changes to the community for |
|
75 | When you are completely ready, you can send your changes to the community for | |
76 | review and inclusion. Most commonly used methods are sending patches to the |
|
76 | review and inclusion. Most commonly used methods are sending patches to the | |
77 | mailing list (via ``hg email``) or by creating a pull request on Bitbucket_. |
|
77 | mailing list (via ``hg email``) or by creating a pull request on Bitbucket_. | |
78 |
|
78 | |||
79 | .. _contributing-tests: |
|
79 | .. _contributing-tests: | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | Running tests |
|
82 | Running tests | |
83 | ------------- |
|
83 | ------------- | |
84 |
|
84 | |||
85 | After finishing your changes make sure all tests pass cleanly. Run the testsuite |
|
85 | After finishing your changes make sure all tests pass cleanly. Run the testsuite | |
86 | by invoking ``py.test`` from the project root:: |
|
86 | by invoking ``py.test`` from the project root:: | |
87 |
|
87 | |||
88 | py.test |
|
88 | py.test | |
89 |
|
89 | |||
90 | Note that on unix systems, the temporary directory (``/tmp`` or where |
|
90 | Note that on unix systems, the temporary directory (``/tmp`` or where | |
91 | ``$TMPDIR`` points) must allow executable files; Git hooks must be executable, |
|
91 | ``$TMPDIR`` points) must allow executable files; Git hooks must be executable, | |
92 | and the test suite creates repositories in the temporary directory. Linux |
|
92 | and the test suite creates repositories in the temporary directory. Linux | |
93 | systems with /tmp mounted noexec will thus fail. |
|
93 | systems with /tmp mounted noexec will thus fail. | |
94 |
|
94 | |||
95 | You can also use ``tox`` to run the tests with all supported Python versions |
|
95 | You can also use ``tox`` to run the tests with all supported Python versions | |
96 | (currently only Python 2.7). |
|
96 | (currently only Python 2.7). | |
97 |
|
97 | |||
98 | When running tests, Kallithea generates a `test.ini` based on template values |
|
98 | When running tests, Kallithea generates a `test.ini` based on template values | |
99 | in `kallithea/tests/conftest.py` and populates the SQLite database specified |
|
99 | in `kallithea/tests/conftest.py` and populates the SQLite database specified | |
100 | there. |
|
100 | there. | |
101 |
|
101 | |||
102 | It is possible to avoid recreating the full test database on each invocation of |
|
102 | It is possible to avoid recreating the full test database on each invocation of | |
103 | the tests, thus eliminating the initial delay. To achieve this, run the tests as:: |
|
103 | the tests, thus eliminating the initial delay. To achieve this, run the tests as:: | |
104 |
|
104 | |||
105 | gearbox serve -c /tmp/kallithea-test-XXX/test.ini --pid-file=test.pid --daemon |
|
105 | gearbox serve -c /tmp/kallithea-test-XXX/test.ini --pid-file=test.pid --daemon | |
106 | KALLITHEA_WHOOSH_TEST_DISABLE=1 KALLITHEA_NO_TMP_PATH=1 py.test |
|
106 | KALLITHEA_WHOOSH_TEST_DISABLE=1 KALLITHEA_NO_TMP_PATH=1 py.test | |
107 | kill -9 $(cat test.pid) |
|
107 | kill -9 $(cat test.pid) | |
108 |
|
108 | |||
109 | In these commands, the following variables are used:: |
|
109 | In these commands, the following variables are used:: | |
110 |
|
110 | |||
111 | KALLITHEA_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests |
|
111 | KALLITHEA_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests | |
112 | KALLITHEA_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for testing_vcs_operations |
|
112 | KALLITHEA_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for testing_vcs_operations | |
113 |
|
113 | |||
114 | You can run individual tests by specifying their path as argument to py.test. |
|
114 | You can run individual tests by specifying their path as argument to py.test. | |
115 | py.test also has many more options, see `py.test -h`. Some useful options |
|
115 | py.test also has many more options, see `py.test -h`. Some useful options | |
116 | are:: |
|
116 | are:: | |
117 |
|
117 | |||
118 | -k EXPRESSION only run tests which match the given substring |
|
118 | -k EXPRESSION only run tests which match the given substring | |
119 | expression. An expression is a python evaluable |
|
119 | expression. An expression is a python evaluable | |
120 | expression where all names are substring-matched |
|
120 | expression where all names are substring-matched | |
121 | against test names and their parent classes. Example: |
|
121 | against test names and their parent classes. Example: | |
122 | -x, --exitfirst exit instantly on first error or failed test. |
|
122 | -x, --exitfirst exit instantly on first error or failed test. | |
123 | --lf rerun only the tests that failed at the last run (or |
|
123 | --lf rerun only the tests that failed at the last run (or | |
124 | all if none failed) |
|
124 | all if none failed) | |
125 | --ff run all tests but run the last failures first. This |
|
125 | --ff run all tests but run the last failures first. This | |
126 | may re-order tests and thus lead to repeated fixture |
|
126 | may re-order tests and thus lead to repeated fixture | |
127 | setup/teardown |
|
127 | setup/teardown | |
128 | --pdb start the interactive Python debugger on errors. |
|
128 | --pdb start the interactive Python debugger on errors. | |
129 | -s, --capture=no don't capture stdout (any stdout output will be |
|
129 | -s, --capture=no don't capture stdout (any stdout output will be | |
130 | printed immediately) |
|
130 | printed immediately) | |
131 |
|
131 | |||
132 | Performance tests |
|
132 | Performance tests | |
133 | ^^^^^^^^^^^^^^^^^ |
|
133 | ^^^^^^^^^^^^^^^^^ | |
134 |
|
134 | |||
135 | A number of performance tests are present in the test suite, but they are |
|
135 | A number of performance tests are present in the test suite, but they are | |
136 | not run in a standard test run. These tests are useful to |
|
136 | not run in a standard test run. These tests are useful to | |
137 | evaluate the impact of certain code changes with respect to performance. |
|
137 | evaluate the impact of certain code changes with respect to performance. | |
138 |
|
138 | |||
139 | To run these tests:: |
|
139 | To run these tests:: | |
140 |
|
140 | |||
141 | env TEST_PERFORMANCE=1 py.test kallithea/tests/performance |
|
141 | env TEST_PERFORMANCE=1 py.test kallithea/tests/performance | |
142 |
|
142 | |||
143 | To analyze performance, you could install pytest-profiling_, which enables the |
|
143 | To analyze performance, you could install pytest-profiling_, which enables the | |
144 | --profile and --profile-svg options to py.test. |
|
144 | --profile and --profile-svg options to py.test. | |
145 |
|
145 | |||
146 | .. _pytest-profiling: https://github.com/manahl/pytest-plugins/tree/master/pytest-profiling |
|
146 | .. _pytest-profiling: https://github.com/manahl/pytest-plugins/tree/master/pytest-profiling | |
147 |
|
147 | |||
148 | .. _contributing-guidelines: |
|
148 | .. _contributing-guidelines: | |
149 |
|
149 | |||
150 |
|
150 | |||
151 | Contribution guidelines |
|
151 | Contribution guidelines | |
152 | ----------------------- |
|
152 | ----------------------- | |
153 |
|
153 | |||
154 | Kallithea is GPLv3 and we assume all contributions are made by the |
|
154 | Kallithea is GPLv3 and we assume all contributions are made by the | |
155 | committer/contributor and under GPLv3 unless explicitly stated. We do care a |
|
155 | committer/contributor and under GPLv3 unless explicitly stated. We do care a | |
156 | lot about preservation of copyright and license information for existing code |
|
156 | lot about preservation of copyright and license information for existing code | |
157 | that is brought into the project. |
|
157 | that is brought into the project. | |
158 |
|
158 | |||
159 | Contributions will be accepted in most formats -- such as pull requests on |
|
159 | Contributions will be accepted in most formats -- such as pull requests on | |
160 | Bitbucket, something hosted on your own Kallithea instance, or patches sent by |
|
160 | Bitbucket, something hosted on your own Kallithea instance, or patches sent by | |
161 | email to the `kallithea-general`_ mailing list. |
|
161 | email to the `kallithea-general`_ mailing list. | |
162 |
|
162 | |||
163 | When contributing via Bitbucket, please make your fork of |
|
163 | When contributing via Bitbucket, please make your fork of | |
164 | https://bitbucket.org/conservancy/kallithea/ `non-publishing`_ -- it is one of |
|
164 | https://bitbucket.org/conservancy/kallithea/ `non-publishing`_ -- it is one of | |
165 | the settings on "Repository details" page. This ensures your commits are in |
|
165 | the settings on "Repository details" page. This ensures your commits are in | |
166 | "draft" phase and makes it easier for you to address feedback and for project |
|
166 | "draft" phase and makes it easier for you to address feedback and for project | |
167 | maintainers to integrate your changes. |
|
167 | maintainers to integrate your changes. | |
168 |
|
168 | |||
169 | .. _non-publishing: https://www.mercurial-scm.org/wiki/Phases#Publishing_Repository |
|
169 | .. _non-publishing: https://www.mercurial-scm.org/wiki/Phases#Publishing_Repository | |
170 |
|
170 | |||
171 | Make sure to test your changes both manually and with the automatic tests |
|
171 | Make sure to test your changes both manually and with the automatic tests | |
172 | before posting. |
|
172 | before posting. | |
173 |
|
173 | |||
174 | We care about quality and review and keeping a clean repository history. We |
|
174 | We care about quality and review and keeping a clean repository history. We | |
175 | might give feedback that requests polishing contributions until they are |
|
175 | might give feedback that requests polishing contributions until they are | |
176 | "perfect". We might also rebase and collapse and make minor adjustments to your |
|
176 | "perfect". We might also rebase and collapse and make minor adjustments to your | |
177 | changes when we apply them. |
|
177 | changes when we apply them. | |
178 |
|
178 | |||
179 | We try to make sure we have consensus on the direction the project is taking. |
|
179 | We try to make sure we have consensus on the direction the project is taking. | |
180 | Everything non-sensitive should be discussed in public -- preferably on the |
|
180 | Everything non-sensitive should be discussed in public -- preferably on the | |
181 | mailing list. We aim at having all non-trivial changes reviewed by at least |
|
181 | mailing list. We aim at having all non-trivial changes reviewed by at least | |
182 | one other core developer before pushing. Obvious non-controversial changes will |
|
182 | one other core developer before pushing. Obvious non-controversial changes will | |
183 | be handled more casually. |
|
183 | be handled more casually. | |
184 |
|
184 | |||
185 | There is a main development branch ("default") which is generally stable so that |
|
185 | There is a main development branch ("default") which is generally stable so that | |
186 | it can be (and is) used in production. There is also a "stable" branch that is |
|
186 | it can be (and is) used in production. There is also a "stable" branch that is | |
187 | almost exclusively reserved for bug fixes or trivial changes. Experimental |
|
187 | almost exclusively reserved for bug fixes or trivial changes. Experimental | |
188 | changes should live elsewhere (for example in a pull request) until they are |
|
188 | changes should live elsewhere (for example in a pull request) until they are | |
189 | ready. |
|
189 | ready. | |
190 |
|
190 | |||
191 | .. _coding-guidelines: |
|
191 | .. _coding-guidelines: | |
192 |
|
192 | |||
193 |
|
193 | |||
194 | Coding guidelines |
|
194 | Coding guidelines | |
195 | ----------------- |
|
195 | ----------------- | |
196 |
|
196 | |||
197 | We don't have a formal coding/formatting standard. We are currently using a mix |
|
197 | We don't have a formal coding/formatting standard. We are currently using a mix | |
198 | of Mercurial's (https://www.mercurial-scm.org/wiki/CodingStyle), pep8, and |
|
198 | of Mercurial's (https://www.mercurial-scm.org/wiki/CodingStyle), pep8, and | |
199 | consistency with existing code. Run ``scripts/run-all-cleanup`` before |
|
199 | consistency with existing code. Run ``scripts/run-all-cleanup`` before | |
200 | committing to ensure some basic code formatting consistency. |
|
200 | committing to ensure some basic code formatting consistency. | |
201 |
|
201 | |||
202 | We currently only support Python 2.7.x and nothing else. For now we don't care |
|
202 | We currently only support Python 2.7.x and nothing else. For now we don't care | |
203 | about Python 3 compatibility. |
|
203 | about Python 3 compatibility. | |
204 |
|
204 | |||
205 | We try to support the most common modern web browsers. IE9 is still supported |
|
205 | We try to support the most common modern web browsers. IE9 is still supported | |
206 | to the extent it is feasible, IE8 is not. |
|
206 | to the extent it is feasible, IE8 is not. | |
207 |
|
207 | |||
208 | We primarily support Linux and OS X on the server side but Windows should also work. |
|
208 | We primarily support Linux and OS X on the server side but Windows should also work. | |
209 |
|
209 | |||
210 | HTML templates should use 2 spaces for indentation ... but be pragmatic. We |
|
210 | HTML templates should use 2 spaces for indentation ... but be pragmatic. We | |
211 | should use templates cleverly and avoid duplication. We should use reasonable |
|
211 | should use templates cleverly and avoid duplication. We should use reasonable | |
212 | semantic markup with element classes and IDs that can be used for styling and testing. |
|
212 | semantic markup with element classes and IDs that can be used for styling and testing. | |
213 | We should only use inline styles in places where it really is semantic (such as |
|
213 | We should only use inline styles in places where it really is semantic (such as | |
214 | ``display: none``). |
|
214 | ``display: none``). | |
215 |
|
215 | |||
216 | JavaScript must use ``;`` between/after statements. Indentation 4 spaces. Inline |
|
216 | JavaScript must use ``;`` between/after statements. Indentation 4 spaces. Inline | |
217 | multiline functions should be indented two levels -- one for the ``()`` and one for |
|
217 | multiline functions should be indented two levels -- one for the ``()`` and one for | |
218 | ``{}``. |
|
218 | ``{}``. | |
219 | Variables holding jQuery objects should be named with a leading ``$``. |
|
219 | Variables holding jQuery objects should be named with a leading ``$``. | |
220 |
|
220 | |||
221 | Commit messages should have a leading short line summarizing the changes. For |
|
221 | Commit messages should have a leading short line summarizing the changes. For | |
222 | bug fixes, put ``(Issue #123)`` at the end of this line. |
|
222 | bug fixes, put ``(Issue #123)`` at the end of this line. | |
223 |
|
223 | |||
224 | Use American English grammar and spelling overall. Use `English title case`_ for |
|
224 | Use American English grammar and spelling overall. Use `English title case`_ for | |
225 | page titles, button labels, headers, and 'labels' for fields in forms. |
|
225 | page titles, button labels, headers, and 'labels' for fields in forms. | |
226 |
|
226 | |||
227 | .. _English title case: https://en.wikipedia.org/wiki/Capitalization#Title_case |
|
227 | .. _English title case: https://en.wikipedia.org/wiki/Capitalization#Title_case | |
228 |
|
228 | |||
229 | Template helpers (that is, everything in ``kallithea.lib.helpers``) |
|
229 | Template helpers (that is, everything in ``kallithea.lib.helpers``) | |
230 | should only be referenced from templates. If you need to call a |
|
230 | should only be referenced from templates. If you need to call a | |
231 | helper from the Python code, consider moving the function somewhere |
|
231 | helper from the Python code, consider moving the function somewhere | |
232 | else (e.g. to the model). |
|
232 | else (e.g. to the model). | |
233 |
|
233 | |||
234 | Notes on the SQLAlchemy session |
|
234 | Notes on the SQLAlchemy session | |
235 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
235 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
236 |
|
236 | |||
237 | Each HTTP request runs inside an independent SQLAlchemy session (as well |
|
237 | Each HTTP request runs inside an independent SQLAlchemy session (as well | |
238 | as in an independent database transaction). ``Session`` is the session manager |
|
238 | as in an independent database transaction). ``Session`` is the session manager | |
239 | and factory. ``Session()`` will create a new session on-demand or return the |
|
239 | and factory. ``Session()`` will create a new session on-demand or return the | |
240 | current session for the active thread. Many database operations are methods on |
|
240 | current session for the active thread. Many database operations are methods on | |
241 | such session instances - only ``Session.remove()`` should be called directly on |
|
241 | such session instances - only ``Session.remove()`` should be called directly on | |
242 | the manager. |
|
242 | the manager. | |
243 |
|
243 | |||
244 | Database model objects |
|
244 | Database model objects | |
245 | (almost) always belong to a particular SQLAlchemy session, which means |
|
245 | (almost) always belong to a particular SQLAlchemy session, which means | |
246 | that SQLAlchemy will ensure that they're kept in sync with the database |
|
246 | that SQLAlchemy will ensure that they're kept in sync with the database | |
247 | (but also means that they cannot be shared across requests). |
|
247 | (but also means that they cannot be shared across requests). | |
248 |
|
248 | |||
249 | Objects can be added to the session using ``Session().add``, but this is |
|
249 | Objects can be added to the session using ``Session().add``, but this is | |
250 | rarely needed: |
|
250 | rarely needed: | |
251 |
|
251 | |||
252 | * When creating a database object by calling the constructor directly, |
|
252 | * When creating a database object by calling the constructor directly, | |
253 | it must explicitly be added to the session. |
|
253 | it must explicitly be added to the session. | |
254 |
|
254 | |||
255 | * When creating an object using a factory function (like |
|
255 | * When creating an object using a factory function (like | |
256 | ``create_repo``), the returned object has already (by convention) |
|
256 | ``create_repo``), the returned object has already (by convention) | |
257 | been added to the session, and should not be added again. |
|
257 | been added to the session, and should not be added again. | |
258 |
|
258 | |||
259 | * When getting an object from the session (via ``Session().query`` or |
|
259 | * When getting an object from the session (via ``Session().query`` or | |
260 | any of the utility functions that look up objects in the database), |
|
260 | any of the utility functions that look up objects in the database), | |
261 | it's already part of the session, and should not be added again. |
|
261 | it's already part of the session, and should not be added again. | |
262 | SQLAlchemy monitors attribute modifications automatically for all |
|
262 | SQLAlchemy monitors attribute modifications automatically for all | |
263 | objects it knows about and syncs them to the database. |
|
263 | objects it knows about and syncs them to the database. | |
264 |
|
264 | |||
265 | SQLAlchemy also flushes changes to the database automatically; manually |
|
265 | SQLAlchemy also flushes changes to the database automatically; manually | |
266 | calling ``Session().flush`` is usually only necessary when the Python |
|
266 | calling ``Session().flush`` is usually only necessary when the Python | |
267 | code needs the database to assign an "auto-increment" primary key ID to |
|
267 | code needs the database to assign an "auto-increment" primary key ID to | |
268 | a freshly created model object (before flushing, the ID attribute will |
|
268 | a freshly created model object (before flushing, the ID attribute will | |
269 | be ``None``). |
|
269 | be ``None``). | |
270 |
|
270 | |||
271 | TurboGears2 DebugBar |
|
271 | TurboGears2 DebugBar | |
272 | ^^^^^^^^^^^^^^^^^^^^ |
|
272 | ^^^^^^^^^^^^^^^^^^^^ | |
273 |
|
273 | |||
274 | It is possible to enable the TurboGears2-provided DebugBar_, a toolbar overlayed |
|
274 | It is possible to enable the TurboGears2-provided DebugBar_, a toolbar overlayed | |
275 | over the Kallithea web interface, allowing you to see: |
|
275 | over the Kallithea web interface, allowing you to see: | |
276 |
|
276 | |||
277 | * timing information of the current request, including profiling information |
|
277 | * timing information of the current request, including profiling information | |
278 | * request data, including GET data, POST data, cookies, headers and environment |
|
278 | * request data, including GET data, POST data, cookies, headers and environment | |
279 | variables |
|
279 | variables | |
280 | * a list of executed database queries, including timing and result values |
|
280 | * a list of executed database queries, including timing and result values | |
281 |
|
281 | |||
282 | DebugBar is only activated when ``debug = true`` is set in the configuration |
|
282 | DebugBar is only activated when ``debug = true`` is set in the configuration | |
283 | file. This is important, because the DebugBar toolbar will be visible for all |
|
283 | file. This is important, because the DebugBar toolbar will be visible for all | |
284 | users, and allow them to see information they should not be allowed to see. Like |
|
284 | users, and allow them to see information they should not be allowed to see. Like | |
285 | is anyway the case for ``debug = true``, do not use this in production! |
|
285 | is anyway the case for ``debug = true``, do not use this in production! | |
286 |
|
286 | |||
287 | To enable DebugBar, install ``tgext.debugbar`` and ``kajiki`` (typically via |
|
287 | To enable DebugBar, install ``tgext.debugbar`` and ``kajiki`` (typically via | |
288 | ``pip``) and restart Kallithea (in debug mode). |
|
288 | ``pip``) and restart Kallithea (in debug mode). | |
289 |
|
289 | |||
290 |
|
290 | |||
291 | "Roadmap" |
|
291 | "Roadmap" | |
292 | --------- |
|
292 | --------- | |
293 |
|
293 | |||
294 | We do not have a road map but are waiting for your contributions. Refer to the |
|
294 | We do not have a road map but are waiting for your contributions. Refer to the | |
295 | wiki_ for some ideas of places we might want to go -- contributions in these |
|
295 | wiki_ for some ideas of places we might want to go -- contributions in these | |
296 | areas are very welcome. |
|
296 | areas are very welcome. | |
297 |
|
297 | |||
298 |
|
298 | |||
299 | Thank you for your contribution! |
|
299 | Thank you for your contribution! | |
300 | -------------------------------- |
|
300 | -------------------------------- | |
301 |
|
301 | |||
302 |
|
302 | |||
303 | .. _Weblate: http://weblate.org/ |
|
303 | .. _Weblate: http://weblate.org/ | |
304 | .. _issue tracking: https://bitbucket.org/conservancy/kallithea/issues?status=new&status=open |
|
304 | .. _issue tracking: https://bitbucket.org/conservancy/kallithea/issues?status=new&status=open | |
305 | .. _pull requests: https://bitbucket.org/conservancy/kallithea/pull-requests |
|
305 | .. _pull requests: https://bitbucket.org/conservancy/kallithea/pull-requests | |
306 | .. _bitbucket: http://bitbucket.org/ |
|
306 | .. _bitbucket: http://bitbucket.org/ | |
307 | .. _mailing list: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general |
|
307 | .. _mailing list: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general | |
308 | .. _kallithea-general: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general |
|
308 | .. _kallithea-general: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general | |
309 | .. _Hosted Weblate: https://hosted.weblate.org/projects/kallithea/kallithea/ |
|
309 | .. _Hosted Weblate: https://hosted.weblate.org/projects/kallithea/kallithea/ | |
310 | .. _wiki: https://bitbucket.org/conservancy/kallithea/wiki/Home |
|
310 | .. _wiki: https://bitbucket.org/conservancy/kallithea/wiki/Home | |
311 | .. _DebugBar: https://github.com/TurboGears/tgext.debugbar |
|
311 | .. _DebugBar: https://github.com/TurboGears/tgext.debugbar | |
312 | .. _Quick Start: https://www.mercurial-scm.org/wiki/QuickStart |
|
312 | .. _Quick Start: https://www.mercurial-scm.org/wiki/QuickStart | |
313 | .. _Beginners Guide: https://www.mercurial-scm.org/wiki/BeginnersGuides |
|
313 | .. _Beginners Guide: https://www.mercurial-scm.org/wiki/BeginnersGuides |
@@ -1,139 +1,138 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 python-pip python-virtualenv libffi-dev python-dev |
|
38 | sudo apt-get install build-essential git python-pip python-virtualenv libffi-dev python-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 python-pip python-virtualenv libffi-devel python-devel |
|
43 | sudo yum install gcc git python-pip python-virtualenv libffi-devel python-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, follow the instructions below:: |
|
52 | repository, follow the instructions below:: | |
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 | virtualenv ../kallithea-venv |
|
56 | virtualenv ../kallithea-venv | |
57 | . ../kallithea-venv/bin/activate |
|
57 | . ../kallithea-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 | python2 setup.py compile_catalog # for translation of the UI |
|
60 | python2 setup.py compile_catalog # for translation of the UI | |
61 |
|
61 | |||
62 | You can now proceed to :ref:`setup`. |
|
62 | You can now proceed to :ref:`setup`. | |
63 |
|
63 | |||
64 | .. _installation-virtualenv: |
|
64 | .. _installation-virtualenv: | |
65 |
|
65 | |||
66 |
|
66 | |||
67 | Installing a released version in a virtualenv |
|
67 | Installing a released version in a virtualenv | |
68 | --------------------------------------------- |
|
68 | --------------------------------------------- | |
69 |
|
69 | |||
70 | It is highly recommended to use a separate virtualenv_ for installing Kallithea. |
|
70 | It is highly recommended to use a separate virtualenv_ for installing Kallithea. | |
71 | This way, all libraries required by Kallithea will be installed separately from your |
|
71 | This way, all libraries required by Kallithea will be installed separately from your | |
72 | main Python installation and other applications and things will be less |
|
72 | main Python installation and other applications and things will be less | |
73 | problematic when upgrading the system or Kallithea. |
|
73 | problematic when upgrading the system or Kallithea. | |
74 | An additional benefit of virtualenv_ is that it doesn't require root privileges. |
|
74 | An additional benefit of virtualenv_ is that it doesn't require root privileges. | |
75 |
|
75 | |||
76 | - Assuming you have installed virtualenv_, create a new virtual environment |
|
76 | - Assuming you have installed virtualenv_, create a new virtual environment | |
77 | for example, in `/srv/kallithea/venv`, using the virtualenv command:: |
|
77 | for example, in `/srv/kallithea/venv`, using the virtualenv command:: | |
78 |
|
78 | |||
79 | virtualenv /srv/kallithea/venv |
|
79 | virtualenv /srv/kallithea/venv | |
80 |
|
80 | |||
81 | - Activate the virtualenv_ in your current shell session and make sure the |
|
81 | - Activate the virtualenv_ in your current shell session and make sure the | |
82 | basic requirements are up-to-date by running:: |
|
82 | basic requirements are up-to-date by running:: | |
83 |
|
83 | |||
84 | . /srv/kallithea/venv/bin/activate |
|
84 | . /srv/kallithea/venv/bin/activate | |
85 | pip install --upgrade pip setuptools |
|
85 | pip install --upgrade pip setuptools | |
86 |
|
86 | |||
87 | .. note:: You can't use UNIX ``sudo`` to source the ``virtualenv`` script; it |
|
87 | .. note:: You can't use UNIX ``sudo`` to source the ``virtualenv`` script; it | |
88 | will "activate" a shell that terminates immediately. It is also perfectly |
|
88 | will "activate" a shell that terminates immediately. It is also perfectly | |
89 | acceptable (and desirable) to create a virtualenv as a normal user. |
|
89 | acceptable (and desirable) to create a virtualenv as a normal user. | |
90 |
|
90 | |||
91 | .. note:: Some dependencies are optional. If you need them, install them in |
|
|||
92 | the virtualenv too:: |
|
|||
93 |
|
||||
94 | pip install --upgrade psycopg2 |
|
|||
95 | pip install --upgrade python-ldap |
|
|||
96 |
|
||||
97 | This might require installation of development packages using your |
|
|||
98 | distribution's package manager. |
|
|||
99 |
|
||||
100 | - Make a folder for Kallithea data files, and configuration somewhere on the |
|
91 | - Make a folder for Kallithea data files, and configuration somewhere on the | |
101 | filesystem. For example:: |
|
92 | filesystem. For example:: | |
102 |
|
93 | |||
103 | mkdir /srv/kallithea |
|
94 | mkdir /srv/kallithea | |
104 |
|
95 | |||
105 | - Go into the created directory and run this command to install Kallithea:: |
|
96 | - Go into the created directory and run this command to install Kallithea:: | |
106 |
|
97 | |||
107 | pip install --upgrade kallithea |
|
98 | pip install --upgrade kallithea | |
108 |
|
99 | |||
|
100 | .. note:: Some dependencies are optional. If you need them, install them in | |||
|
101 | the virtualenv too:: | |||
|
102 | ||||
|
103 | pip install --upgrade kallithea python-ldap python-pam psycopg2 | |||
|
104 | ||||
|
105 | This might require installation of development packages using your | |||
|
106 | distribution's package manager. | |||
|
107 | ||||
109 | Alternatively, download a .tar.gz from http://pypi.python.org/pypi/Kallithea, |
|
108 | Alternatively, download a .tar.gz from http://pypi.python.org/pypi/Kallithea, | |
110 | extract it and run:: |
|
109 | extract it and install from source by running:: | |
111 |
|
110 | |||
112 | pip install --upgrade . |
|
111 | pip install --upgrade . | |
113 |
|
112 | |||
114 | - This will install Kallithea together with all other required |
|
113 | - This will install Kallithea together with all other required | |
115 | Python libraries into the activated virtualenv. |
|
114 | Python libraries into the activated virtualenv. | |
116 |
|
115 | |||
117 | You can now proceed to :ref:`setup`. |
|
116 | You can now proceed to :ref:`setup`. | |
118 |
|
117 | |||
119 | .. _installation-without-virtualenv: |
|
118 | .. _installation-without-virtualenv: | |
120 |
|
119 | |||
121 |
|
120 | |||
122 | Installing a released version without virtualenv |
|
121 | Installing a released version without virtualenv | |
123 | ------------------------------------------------ |
|
122 | ------------------------------------------------ | |
124 |
|
123 | |||
125 | For installation without virtualenv, 'just' use:: |
|
124 | For installation without virtualenv, 'just' use:: | |
126 |
|
125 | |||
127 | pip install kallithea |
|
126 | pip install kallithea | |
128 |
|
127 | |||
129 | Note that this method requires root privileges and will install packages |
|
128 | Note that this method requires root privileges and will install packages | |
130 | globally without using the system's package manager. |
|
129 | globally without using the system's package manager. | |
131 |
|
130 | |||
132 | To install as a regular user in ``~/.local``, you can use:: |
|
131 | To install as a regular user in ``~/.local``, you can use:: | |
133 |
|
132 | |||
134 | pip install --user kallithea |
|
133 | pip install --user kallithea | |
135 |
|
134 | |||
136 | You can now proceed to :ref:`setup`. |
|
135 | You can now proceed to :ref:`setup`. | |
137 |
|
136 | |||
138 |
|
137 | |||
139 | .. _virtualenv: http://pypi.python.org/pypi/virtualenv |
|
138 | .. _virtualenv: http://pypi.python.org/pypi/virtualenv |
General Comments 0
You need to be logged in to leave comments.
Login now