Show More
@@ -1,211 +1,211 b'' | |||
|
1 | 1 | def createvirtualenv = '' |
|
2 | 2 | def activatevirtualenv = '' |
|
3 | 3 | |
|
4 | 4 | node { |
|
5 | 5 | properties([[$class: 'BuildDiscarderProperty', |
|
6 | 6 | strategy: [$class: 'LogRotator', |
|
7 | 7 | artifactDaysToKeepStr: '', |
|
8 | 8 | artifactNumToKeepStr: '10', |
|
9 | 9 | daysToKeepStr: '', |
|
10 | 10 | numToKeepStr: '']]]); |
|
11 | 11 | if (isUnix()) { |
|
12 | 12 | createvirtualenv = 'rm -r $JENKINS_HOME/venv/$JOB_NAME || true && python3 -m venv $JENKINS_HOME/venv/$JOB_NAME' |
|
13 | 13 | activatevirtualenv = '. $JENKINS_HOME/venv/$JOB_NAME/bin/activate' |
|
14 | 14 | } else { |
|
15 | 15 | createvirtualenv = 'rmdir /s /q %JENKINS_HOME%\\venv\\%JOB_NAME% || true && python3 -m venv %JENKINS_HOME%\\venv\\%JOB_NAME%' |
|
16 | 16 | activatevirtualenv = 'call %JENKINS_HOME%\\venv\\%JOB_NAME%\\Scripts\\activate.bat' |
|
17 | 17 | } |
|
18 | 18 | |
|
19 | 19 | stage('checkout') { |
|
20 | 20 | checkout scm |
|
21 | 21 | if (isUnix()) { |
|
22 | 22 | sh 'hg --config extensions.purge= purge --all' |
|
23 | 23 | } else { |
|
24 | 24 | bat 'hg --config extensions.purge= purge --all' |
|
25 | 25 | } |
|
26 | 26 | } |
|
27 | 27 | stage('virtual env') { |
|
28 | 28 | def virtualenvscript = """$createvirtualenv |
|
29 | 29 | $activatevirtualenv |
|
30 | python -m pip install --upgrade pip | |
|
30 | python -m pip install --upgrade "pip<24.1" | |
|
31 | 31 | pip install --upgrade "setuptools<67" |
|
32 | 32 | pip install --upgrade pylint |
|
33 | 33 | pip install --upgrade pytest-cov |
|
34 | 34 | """ |
|
35 | 35 | if (isUnix()) { |
|
36 | 36 | virtualenvscript += """ |
|
37 | 37 | pip install --upgrade python-ldap |
|
38 | 38 | pip install --upgrade python-pam |
|
39 | 39 | """ |
|
40 | 40 | sh virtualenvscript |
|
41 | 41 | } else { |
|
42 | 42 | bat virtualenvscript |
|
43 | 43 | } |
|
44 | 44 | } |
|
45 | 45 | stage('setup') { |
|
46 | 46 | def virtualenvscript = """$activatevirtualenv |
|
47 | 47 | pip install --upgrade -e . -r dev_requirements.txt |
|
48 | 48 | python setup.py compile_catalog |
|
49 | 49 | """ |
|
50 | 50 | if (isUnix()) { |
|
51 | 51 | sh virtualenvscript |
|
52 | 52 | } else { |
|
53 | 53 | bat virtualenvscript |
|
54 | 54 | } |
|
55 | 55 | stash name: 'kallithea', useDefaultExcludes: false |
|
56 | 56 | } |
|
57 | 57 | stage('pylint') { |
|
58 | 58 | sh script: """$activatevirtualenv |
|
59 | 59 | pylint -j 0 --disable=C -f parseable kallithea > pylint.out |
|
60 | 60 | """, returnStatus: true |
|
61 | 61 | archiveArtifacts 'pylint.out' |
|
62 | 62 | try { |
|
63 | 63 | step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'PyLint', pattern: 'pylint.out']], unHealthy: '']) |
|
64 | 64 | } catch (java.lang.IllegalArgumentException exc) { |
|
65 | 65 | echo "You need to install the 'Warnings Plug-in' to display the pylint report." |
|
66 | 66 | currentBuild.result = 'UNSTABLE' |
|
67 | 67 | echo "Caught: ${exc}" |
|
68 | 68 | } |
|
69 | 69 | } |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | def pytests = [:] |
|
73 | 73 | pytests['sqlite'] = { |
|
74 | 74 | node { |
|
75 | 75 | ws { |
|
76 | 76 | deleteDir() |
|
77 | 77 | unstash name: 'kallithea' |
|
78 | 78 | if (isUnix()) { |
|
79 | 79 | sh script: """$activatevirtualenv |
|
80 | 80 | py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea |
|
81 | 81 | """, returnStatus: true |
|
82 | 82 | } else { |
|
83 | 83 | bat script: """$activatevirtualenv |
|
84 | 84 | py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea |
|
85 | 85 | """, returnStatus: true |
|
86 | 86 | } |
|
87 | 87 | sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1SQLITE./g" pytest_sqlite.xml' |
|
88 | 88 | archiveArtifacts 'pytest_sqlite.xml' |
|
89 | 89 | junit 'pytest_sqlite.xml' |
|
90 | 90 | writeFile(file: '.coverage.sqlite', text: readFile('.coverage')) |
|
91 | 91 | stash name: 'coverage.sqlite', includes: '.coverage.sqlite' |
|
92 | 92 | } |
|
93 | 93 | } |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | pytests['de'] = { |
|
97 | 97 | node { |
|
98 | 98 | if (isUnix()) { |
|
99 | 99 | ws { |
|
100 | 100 | deleteDir() |
|
101 | 101 | unstash name: 'kallithea' |
|
102 | 102 | withEnv(['LANG=de_DE.UTF-8', |
|
103 | 103 | 'LANGUAGE=de', |
|
104 | 104 | 'LC_ADDRESS=de_DE.UTF-8', |
|
105 | 105 | 'LC_IDENTIFICATION=de_DE.UTF-8', |
|
106 | 106 | 'LC_MEASUREMENT=de_DE.UTF-8', |
|
107 | 107 | 'LC_MONETARY=de_DE.UTF-8', |
|
108 | 108 | 'LC_NAME=de_DE.UTF-8', |
|
109 | 109 | 'LC_NUMERIC=de_DE.UTF-8', |
|
110 | 110 | 'LC_PAPER=de_DE.UTF-8', |
|
111 | 111 | 'LC_TELEPHONE=de_DE.UTF-8', |
|
112 | 112 | 'LC_TIME=de_DE.UTF-8', |
|
113 | 113 | ]) { |
|
114 | 114 | sh script: """$activatevirtualenv |
|
115 | 115 | py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea |
|
116 | 116 | """, returnStatus: true |
|
117 | 117 | } |
|
118 | 118 | sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1DE./g" pytest_de.xml' |
|
119 | 119 | archiveArtifacts 'pytest_de.xml' |
|
120 | 120 | junit 'pytest_de.xml' |
|
121 | 121 | writeFile(file: '.coverage.de', text: readFile('.coverage')) |
|
122 | 122 | stash name: 'coverage.de', includes: '.coverage.de' |
|
123 | 123 | } |
|
124 | 124 | } |
|
125 | 125 | } |
|
126 | 126 | } |
|
127 | 127 | pytests['mysql'] = { |
|
128 | 128 | node { |
|
129 | 129 | if (isUnix()) { |
|
130 | 130 | ws { |
|
131 | 131 | deleteDir() |
|
132 | 132 | unstash name: 'kallithea' |
|
133 | 133 | sh """$activatevirtualenv |
|
134 | 134 | pip install --upgrade MySQL-python |
|
135 | 135 | """ |
|
136 | 136 | withEnv(['TEST_DB=mysql://kallithea:kallithea@jenkins_mysql/kallithea_test?charset=utf8']) { |
|
137 | 137 | if (isUnix()) { |
|
138 | 138 | sh script: """$activatevirtualenv |
|
139 | 139 | py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea |
|
140 | 140 | """, returnStatus: true |
|
141 | 141 | } else { |
|
142 | 142 | bat script: """$activatevirtualenv |
|
143 | 143 | py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea |
|
144 | 144 | """, returnStatus: true |
|
145 | 145 | } |
|
146 | 146 | } |
|
147 | 147 | sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1MYSQL./g" pytest_mysql.xml' |
|
148 | 148 | archiveArtifacts 'pytest_mysql.xml' |
|
149 | 149 | junit 'pytest_mysql.xml' |
|
150 | 150 | writeFile(file: '.coverage.mysql', text: readFile('.coverage')) |
|
151 | 151 | stash name: 'coverage.mysql', includes: '.coverage.mysql' |
|
152 | 152 | } |
|
153 | 153 | } |
|
154 | 154 | } |
|
155 | 155 | } |
|
156 | 156 | pytests['postgresql'] = { |
|
157 | 157 | node { |
|
158 | 158 | if (isUnix()) { |
|
159 | 159 | ws { |
|
160 | 160 | deleteDir() |
|
161 | 161 | unstash name: 'kallithea' |
|
162 | 162 | sh """$activatevirtualenv |
|
163 | 163 | pip install --upgrade psycopg2 |
|
164 | 164 | """ |
|
165 | 165 | withEnv(['TEST_DB=postgresql://kallithea:kallithea@jenkins_postgresql/kallithea_test']) { |
|
166 | 166 | if (isUnix()) { |
|
167 | 167 | sh script: """$activatevirtualenv |
|
168 | 168 | py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea |
|
169 | 169 | """, returnStatus: true |
|
170 | 170 | } else { |
|
171 | 171 | bat script: """$activatevirtualenv |
|
172 | 172 | py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea |
|
173 | 173 | """, returnStatus: true |
|
174 | 174 | } |
|
175 | 175 | } |
|
176 | 176 | sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1POSTGRES./g" pytest_postgresql.xml' |
|
177 | 177 | archiveArtifacts 'pytest_postgresql.xml' |
|
178 | 178 | junit 'pytest_postgresql.xml' |
|
179 | 179 | writeFile(file: '.coverage.postgresql', text: readFile('.coverage')) |
|
180 | 180 | stash name: 'coverage.postgresql', includes: '.coverage.postgresql' |
|
181 | 181 | } |
|
182 | 182 | } |
|
183 | 183 | } |
|
184 | 184 | } |
|
185 | 185 | stage('Tests') { |
|
186 | 186 | parallel pytests |
|
187 | 187 | node { |
|
188 | 188 | unstash 'coverage.sqlite' |
|
189 | 189 | unstash 'coverage.de' |
|
190 | 190 | unstash 'coverage.mysql' |
|
191 | 191 | unstash 'coverage.postgresql' |
|
192 | 192 | if (isUnix()) { |
|
193 | 193 | sh script: """$activatevirtualenv |
|
194 | 194 | coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql |
|
195 | 195 | coverage xml |
|
196 | 196 | """, returnStatus: true |
|
197 | 197 | } else { |
|
198 | 198 | bat script: """$activatevirtualenv |
|
199 | 199 | coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql |
|
200 | 200 | coverage xml |
|
201 | 201 | """, returnStatus: true |
|
202 | 202 | } |
|
203 | 203 | try { |
|
204 | 204 | step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false]) |
|
205 | 205 | } catch (java.lang.IllegalArgumentException exc) { |
|
206 | 206 | echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report." |
|
207 | 207 | currentBuild.result = 'UNSTABLE' |
|
208 | 208 | echo "Caught: ${exc}" |
|
209 | 209 | } |
|
210 | 210 | } |
|
211 | 211 | } |
@@ -1,397 +1,397 b'' | |||
|
1 | 1 | .. _contributing: |
|
2 | 2 | |
|
3 | 3 | ========================= |
|
4 | 4 | Contributing to Kallithea |
|
5 | 5 | ========================= |
|
6 | 6 | |
|
7 | 7 | Kallithea is developed and maintained by its users. Please join us and scratch |
|
8 | 8 | your own itch. |
|
9 | 9 | |
|
10 | 10 | |
|
11 | 11 | Infrastructure |
|
12 | 12 | -------------- |
|
13 | 13 | |
|
14 | 14 | The main repository is hosted on Our Own Kallithea (aka OOK) at |
|
15 | 15 | https://kallithea-scm.org/repos/kallithea/, our self-hosted instance |
|
16 | 16 | of Kallithea. |
|
17 | 17 | |
|
18 | 18 | Please use the `mailing list`_ to send patches or report issues. |
|
19 | 19 | |
|
20 | 20 | We use Weblate_ to translate the user interface messages into languages other |
|
21 | 21 | than English. Join our project on `Hosted Weblate`_ to help us. |
|
22 | 22 | To register, you can use your Bitbucket or GitHub account. See :ref:`translations` |
|
23 | 23 | for more details. |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | Getting started |
|
27 | 27 | --------------- |
|
28 | 28 | |
|
29 | 29 | To get started with Kallithea development run the following commands in your |
|
30 | 30 | bash shell:: |
|
31 | 31 | |
|
32 | 32 | hg clone https://kallithea-scm.org/repos/kallithea |
|
33 | 33 | cd kallithea |
|
34 | 34 | python3 -m venv venv |
|
35 | 35 | . venv/bin/activate |
|
36 | pip install --upgrade pip "setuptools<67" | |
|
36 | pip install --upgrade "pip<24.1" "setuptools<67" | |
|
37 | 37 | pip install --upgrade -e . -r dev_requirements.txt python-ldap python-pam |
|
38 | 38 | kallithea-cli config-create my.ini |
|
39 | 39 | kallithea-cli db-create -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp |
|
40 | 40 | kallithea-cli front-end-build |
|
41 | 41 | gearbox serve -c my.ini --reload & |
|
42 | 42 | firefox http://127.0.0.1:5000/ |
|
43 | 43 | |
|
44 | 44 | |
|
45 | 45 | Contribution flow |
|
46 | 46 | ----------------- |
|
47 | 47 | |
|
48 | 48 | Starting from an existing Kallithea clone, make sure it is up to date with the |
|
49 | 49 | latest upstream changes:: |
|
50 | 50 | |
|
51 | 51 | hg pull |
|
52 | 52 | hg update |
|
53 | 53 | |
|
54 | 54 | Review the :ref:`contributing-guidelines` and :ref:`coding-guidelines`. |
|
55 | 55 | |
|
56 | 56 | If you are new to Mercurial, refer to Mercurial `Quick Start`_ and `Beginners |
|
57 | 57 | Guide`_ on the Mercurial wiki. |
|
58 | 58 | |
|
59 | 59 | Now, make some changes and test them (see :ref:`contributing-tests`). Don't |
|
60 | 60 | forget to add new tests to cover new functionality or bug fixes. |
|
61 | 61 | |
|
62 | 62 | For documentation changes, run ``make html`` from the ``docs`` directory to |
|
63 | 63 | generate the HTML result, then review them in your browser. |
|
64 | 64 | |
|
65 | 65 | Before submitting any changes, run the cleanup script:: |
|
66 | 66 | |
|
67 | 67 | ./scripts/run-all-cleanup |
|
68 | 68 | |
|
69 | 69 | When you are completely ready, you can send your changes to the community for |
|
70 | 70 | review and inclusion, via the mailing list (via ``hg email``). |
|
71 | 71 | |
|
72 | 72 | .. _contributing-tests: |
|
73 | 73 | |
|
74 | 74 | |
|
75 | 75 | Internal dependencies |
|
76 | 76 | --------------------- |
|
77 | 77 | |
|
78 | 78 | We try to keep the code base clean and modular and avoid circular dependencies. |
|
79 | 79 | Code should only invoke code in layers below itself. |
|
80 | 80 | |
|
81 | 81 | Imports should import whole modules ``from`` their parent module, perhaps |
|
82 | 82 | ``as`` a shortened name. Avoid imports ``from`` modules. |
|
83 | 83 | |
|
84 | 84 | To avoid cycles and partially initialized modules, ``__init__.py`` should *not* |
|
85 | 85 | contain any non-trivial imports. The top level of a module should *not* be a |
|
86 | 86 | facade for the module functionality. |
|
87 | 87 | |
|
88 | 88 | Common code for a module is often in ``base.py``. |
|
89 | 89 | |
|
90 | 90 | The important part of the dependency graph is approximately linear. In the |
|
91 | 91 | following list, modules may only depend on modules below them: |
|
92 | 92 | |
|
93 | 93 | ``tests`` |
|
94 | 94 | Just get the job done - anything goes. |
|
95 | 95 | |
|
96 | 96 | ``bin/`` & ``config/`` & ``alembic/`` |
|
97 | 97 | The main entry points, defined in ``setup.py``. Note: The TurboGears template |
|
98 | 98 | use ``config`` for the high WSGI application - this is not for low level |
|
99 | 99 | configuration. |
|
100 | 100 | |
|
101 | 101 | ``controllers/`` |
|
102 | 102 | The top level web application, with TurboGears using the ``root`` controller |
|
103 | 103 | as entry point, and ``routing`` dispatching to other controllers. |
|
104 | 104 | |
|
105 | 105 | ``templates/**.html`` |
|
106 | 106 | The "view", rendering to HTML. Invoked by controllers which can pass them |
|
107 | 107 | anything from lower layers - especially ``helpers`` available as ``h`` will |
|
108 | 108 | cut through all layers, and ``c`` gives access to global variables. |
|
109 | 109 | |
|
110 | 110 | ``lib/helpers.py`` |
|
111 | 111 | High level helpers, exposing everything to templates as ``h``. It depends on |
|
112 | 112 | everything and has a huge dependency chain, so it should not be used for |
|
113 | 113 | anything else. TODO. |
|
114 | 114 | |
|
115 | 115 | ``controllers/base.py`` |
|
116 | 116 | The base class of controllers, with lots of model knowledge. |
|
117 | 117 | |
|
118 | 118 | ``lib/auth.py`` |
|
119 | 119 | All things related to authentication. TODO. |
|
120 | 120 | |
|
121 | 121 | ``lib/utils.py`` |
|
122 | 122 | High level utils with lots of model knowledge. TODO. |
|
123 | 123 | |
|
124 | 124 | ``lib/hooks.py`` |
|
125 | 125 | Hooks into "everything" to give centralized logging to database, cache |
|
126 | 126 | invalidation, and extension handling. TODO. |
|
127 | 127 | |
|
128 | 128 | ``model/`` |
|
129 | 129 | Convenience business logic wrappers around database models. |
|
130 | 130 | |
|
131 | 131 | ``model/db.py`` |
|
132 | 132 | Defines the database schema and provides some additional logic. |
|
133 | 133 | |
|
134 | 134 | ``model/scm.py`` |
|
135 | 135 | All things related to anything. TODO. |
|
136 | 136 | |
|
137 | 137 | SQLAlchemy |
|
138 | 138 | Database session and transaction in thread-local variables. |
|
139 | 139 | |
|
140 | 140 | ``lib/utils2.py`` |
|
141 | 141 | Low level utils specific to Kallithea. |
|
142 | 142 | |
|
143 | 143 | ``lib/webutils.py`` |
|
144 | 144 | Low level generic utils with awareness of the TurboGears environment. |
|
145 | 145 | |
|
146 | 146 | TurboGears |
|
147 | 147 | Request, response and state like i18n gettext in thread-local variables. |
|
148 | 148 | External dependency with global state - usage should be minimized. |
|
149 | 149 | |
|
150 | 150 | ``lib/vcs/`` |
|
151 | 151 | Previously an independent library. No awareness of web, database, or state. |
|
152 | 152 | |
|
153 | 153 | ``lib/*`` |
|
154 | 154 | Various "pure" functionality not depending on anything else. |
|
155 | 155 | |
|
156 | 156 | ``__init__`` |
|
157 | 157 | Very basic Kallithea constants - some of them are set very early based on ``.ini``. |
|
158 | 158 | |
|
159 | 159 | This is not exactly how it is right now, but we aim for something like that. |
|
160 | 160 | Especially the areas marked as TODO have some problems that need untangling. |
|
161 | 161 | |
|
162 | 162 | |
|
163 | 163 | Running tests |
|
164 | 164 | ------------- |
|
165 | 165 | |
|
166 | 166 | After finishing your changes make sure all tests pass cleanly. Run the testsuite |
|
167 | 167 | by invoking ``py.test`` from the project root:: |
|
168 | 168 | |
|
169 | 169 | py.test |
|
170 | 170 | |
|
171 | 171 | Note that on unix systems, the temporary directory (``/tmp`` or where |
|
172 | 172 | ``$TMPDIR`` points) must allow executable files; Git hooks must be executable, |
|
173 | 173 | and the test suite creates repositories in the temporary directory. Linux |
|
174 | 174 | systems with /tmp mounted noexec will thus fail. |
|
175 | 175 | |
|
176 | 176 | Tests can be run on PostgreSQL like:: |
|
177 | 177 | |
|
178 | 178 | sudo -u postgres createuser 'kallithea-test' --pwprompt # password password |
|
179 | 179 | sudo -u postgres createdb 'kallithea-test' --owner 'kallithea-test' |
|
180 | 180 | REUSE_TEST_DB='postgresql://kallithea-test:password@localhost/kallithea-test' py.test |
|
181 | 181 | |
|
182 | 182 | Tests can be run on MariaDB/MySQL like:: |
|
183 | 183 | |
|
184 | 184 | echo "GRANT ALL PRIVILEGES ON \`kallithea-test\`.* TO 'kallithea-test'@'localhost' IDENTIFIED BY 'password'" | sudo -u mysql mysql |
|
185 | 185 | TEST_DB='mysql://kallithea-test:password@localhost/kallithea-test?charset=utf8mb4' py.test |
|
186 | 186 | |
|
187 | 187 | You can also use ``tox`` to run the tests with all supported Python versions. |
|
188 | 188 | |
|
189 | 189 | When running tests, Kallithea generates a `test.ini` based on template values |
|
190 | 190 | in `kallithea/tests/conftest.py` and populates the SQLite database specified |
|
191 | 191 | there. |
|
192 | 192 | |
|
193 | 193 | It is possible to avoid recreating the full test database on each invocation of |
|
194 | 194 | the tests, thus eliminating the initial delay. To achieve this, run the tests as:: |
|
195 | 195 | |
|
196 | 196 | gearbox serve -c /tmp/kallithea-test-XXX/test.ini --pid-file=test.pid --daemon |
|
197 | 197 | KALLITHEA_WHOOSH_TEST_DISABLE=1 KALLITHEA_NO_TMP_PATH=1 py.test |
|
198 | 198 | kill -9 $(cat test.pid) |
|
199 | 199 | |
|
200 | 200 | In these commands, the following variables are used:: |
|
201 | 201 | |
|
202 | 202 | KALLITHEA_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests |
|
203 | 203 | KALLITHEA_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for testing_vcs_operations |
|
204 | 204 | |
|
205 | 205 | You can run individual tests by specifying their path as argument to py.test. |
|
206 | 206 | py.test also has many more options, see `py.test -h`. Some useful options |
|
207 | 207 | are:: |
|
208 | 208 | |
|
209 | 209 | -k EXPRESSION only run tests which match the given substring |
|
210 | 210 | expression. An expression is a python evaluable |
|
211 | 211 | expression where all names are substring-matched |
|
212 | 212 | against test names and their parent classes. Example: |
|
213 | 213 | -x, --exitfirst exit instantly on first error or failed test. |
|
214 | 214 | --lf rerun only the tests that failed at the last run (or |
|
215 | 215 | all if none failed) |
|
216 | 216 | --ff run all tests but run the last failures first. This |
|
217 | 217 | may re-order tests and thus lead to repeated fixture |
|
218 | 218 | setup/teardown |
|
219 | 219 | --pdb start the interactive Python debugger on errors. |
|
220 | 220 | -s, --capture=no don't capture stdout (any stdout output will be |
|
221 | 221 | printed immediately) |
|
222 | 222 | |
|
223 | 223 | Performance tests |
|
224 | 224 | ^^^^^^^^^^^^^^^^^ |
|
225 | 225 | |
|
226 | 226 | A number of performance tests are present in the test suite, but they are |
|
227 | 227 | not run in a standard test run. These tests are useful to |
|
228 | 228 | evaluate the impact of certain code changes with respect to performance. |
|
229 | 229 | |
|
230 | 230 | To run these tests:: |
|
231 | 231 | |
|
232 | 232 | env TEST_PERFORMANCE=1 py.test kallithea/tests/performance |
|
233 | 233 | |
|
234 | 234 | To analyze performance, you could install pytest-profiling_, which enables the |
|
235 | 235 | --profile and --profile-svg options to py.test. |
|
236 | 236 | |
|
237 | 237 | .. _pytest-profiling: https://github.com/manahl/pytest-plugins/tree/master/pytest-profiling |
|
238 | 238 | |
|
239 | 239 | .. _contributing-guidelines: |
|
240 | 240 | |
|
241 | 241 | |
|
242 | 242 | Contribution guidelines |
|
243 | 243 | ----------------------- |
|
244 | 244 | |
|
245 | 245 | Kallithea is GPLv3 and we assume all contributions are made by the |
|
246 | 246 | committer/contributor and under GPLv3 unless explicitly stated. We do care a |
|
247 | 247 | lot about preservation of copyright and license information for existing code |
|
248 | 248 | that is brought into the project. |
|
249 | 249 | |
|
250 | 250 | Contributions will be accepted in most formats -- such as commits hosted on your |
|
251 | 251 | own Kallithea instance, or patches sent by email to the `kallithea-general`_ |
|
252 | 252 | mailing list. |
|
253 | 253 | |
|
254 | 254 | Make sure to test your changes both manually and with the automatic tests |
|
255 | 255 | before posting. |
|
256 | 256 | |
|
257 | 257 | We care about quality and review and keeping a clean repository history. We |
|
258 | 258 | might give feedback that requests polishing contributions until they are |
|
259 | 259 | "perfect". We might also rebase and collapse and make minor adjustments to your |
|
260 | 260 | changes when we apply them. |
|
261 | 261 | |
|
262 | 262 | We try to make sure we have consensus on the direction the project is taking. |
|
263 | 263 | Everything non-sensitive should be discussed in public -- preferably on the |
|
264 | 264 | mailing list. We aim at having all non-trivial changes reviewed by at least |
|
265 | 265 | one other core developer before pushing. Obvious non-controversial changes will |
|
266 | 266 | be handled more casually. |
|
267 | 267 | |
|
268 | 268 | There is a main development branch ("default") which is generally stable so that |
|
269 | 269 | it can be (and is) used in production. There is also a "stable" branch that is |
|
270 | 270 | almost exclusively reserved for bug fixes or trivial changes. Experimental |
|
271 | 271 | changes should live elsewhere (for example in a pull request) until they are |
|
272 | 272 | ready. |
|
273 | 273 | |
|
274 | 274 | .. _coding-guidelines: |
|
275 | 275 | |
|
276 | 276 | |
|
277 | 277 | Coding guidelines |
|
278 | 278 | ----------------- |
|
279 | 279 | |
|
280 | 280 | We don't have a formal coding/formatting standard. We are currently using a mix |
|
281 | 281 | of Mercurial's (https://www.mercurial-scm.org/wiki/CodingStyle), pep8, and |
|
282 | 282 | consistency with existing code. Run ``scripts/run-all-cleanup`` before |
|
283 | 283 | committing to ensure some basic code formatting consistency. |
|
284 | 284 | |
|
285 | 285 | We support Python 3.6 and later. |
|
286 | 286 | |
|
287 | 287 | We try to support the most common modern web browsers. IE9 is still supported |
|
288 | 288 | to the extent it is feasible, IE8 is not. |
|
289 | 289 | |
|
290 | 290 | We primarily support Linux and OS X on the server side but Windows should also work. |
|
291 | 291 | |
|
292 | 292 | HTML templates should use 2 spaces for indentation ... but be pragmatic. We |
|
293 | 293 | should use templates cleverly and avoid duplication. We should use reasonable |
|
294 | 294 | semantic markup with element classes and IDs that can be used for styling and testing. |
|
295 | 295 | We should only use inline styles in places where it really is semantic (such as |
|
296 | 296 | ``display: none``). |
|
297 | 297 | |
|
298 | 298 | JavaScript must use ``;`` between/after statements. Indentation 4 spaces. Inline |
|
299 | 299 | multiline functions should be indented two levels -- one for the ``()`` and one for |
|
300 | 300 | ``{}``. |
|
301 | 301 | Variables holding jQuery objects should be named with a leading ``$``. |
|
302 | 302 | |
|
303 | 303 | Commit messages should have a leading short line summarizing the changes. For |
|
304 | 304 | bug fixes, put ``(Issue #123)`` at the end of this line. |
|
305 | 305 | |
|
306 | 306 | Use American English grammar and spelling overall. Use `English title case`_ for |
|
307 | 307 | page titles, button labels, headers, and 'labels' for fields in forms. |
|
308 | 308 | |
|
309 | 309 | .. _English title case: https://en.wikipedia.org/wiki/Capitalization#Title_case |
|
310 | 310 | |
|
311 | 311 | Template helpers (that is, everything in ``kallithea.lib.helpers``) |
|
312 | 312 | should only be referenced from templates. If you need to call a |
|
313 | 313 | helper from the Python code, consider moving the function somewhere |
|
314 | 314 | else (e.g. to the model). |
|
315 | 315 | |
|
316 | 316 | Notes on the SQLAlchemy session |
|
317 | 317 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
318 | 318 | |
|
319 | 319 | Each HTTP request runs inside an independent SQLAlchemy session (as well |
|
320 | 320 | as in an independent database transaction). ``Session`` is the session manager |
|
321 | 321 | and factory. ``Session()`` will create a new session on-demand or return the |
|
322 | 322 | current session for the active thread. Many database operations are methods on |
|
323 | 323 | such session instances. The session will generally be removed by |
|
324 | 324 | TurboGears automatically. |
|
325 | 325 | |
|
326 | 326 | Database model objects |
|
327 | 327 | (almost) always belong to a particular SQLAlchemy session, which means |
|
328 | 328 | that SQLAlchemy will ensure that they're kept in sync with the database |
|
329 | 329 | (but also means that they cannot be shared across requests). |
|
330 | 330 | |
|
331 | 331 | Objects can be added to the session using ``Session().add``, but this is |
|
332 | 332 | rarely needed: |
|
333 | 333 | |
|
334 | 334 | * When creating a database object by calling the constructor directly, |
|
335 | 335 | it must explicitly be added to the session. |
|
336 | 336 | |
|
337 | 337 | * When creating an object using a factory function (like |
|
338 | 338 | ``create_repo``), the returned object has already (by convention) |
|
339 | 339 | been added to the session, and should not be added again. |
|
340 | 340 | |
|
341 | 341 | * When getting an object from the session (via ``Session().query`` or |
|
342 | 342 | any of the utility functions that look up objects in the database), |
|
343 | 343 | it's already part of the session, and should not be added again. |
|
344 | 344 | SQLAlchemy monitors attribute modifications automatically for all |
|
345 | 345 | objects it knows about and syncs them to the database. |
|
346 | 346 | |
|
347 | 347 | SQLAlchemy also flushes changes to the database automatically; manually |
|
348 | 348 | calling ``Session().flush`` is usually only necessary when the Python |
|
349 | 349 | code needs the database to assign an "auto-increment" primary key ID to |
|
350 | 350 | a freshly created model object (before flushing, the ID attribute will |
|
351 | 351 | be ``None``). |
|
352 | 352 | |
|
353 | 353 | Debugging |
|
354 | 354 | ^^^^^^^^^ |
|
355 | 355 | |
|
356 | 356 | A good way to trace what Kallithea is doing is to keep an eye on the output on |
|
357 | 357 | stdout/stderr of the server process. Perhaps change ``my.ini`` to log at |
|
358 | 358 | ``DEBUG`` or ``INFO`` level, especially ``[logger_kallithea]``, but perhaps |
|
359 | 359 | also other loggers. It is often easier to add additional ``log`` or ``print`` |
|
360 | 360 | statements than to use a Python debugger. |
|
361 | 361 | |
|
362 | 362 | Sometimes it is simpler to disable ``errorpage.enabled`` and perhaps also |
|
363 | 363 | ``trace_errors.enable`` to expose raw errors instead of adding extra |
|
364 | 364 | processing. Enabling ``debug`` can be helpful for showing and exploring |
|
365 | 365 | tracebacks in the browser, but is also insecure and will add extra processing. |
|
366 | 366 | |
|
367 | 367 | TurboGears2 DebugBar |
|
368 | 368 | ^^^^^^^^^^^^^^^^^^^^ |
|
369 | 369 | |
|
370 | 370 | It is possible to enable the TurboGears2-provided DebugBar_, a toolbar overlayed |
|
371 | 371 | over the Kallithea web interface, allowing you to see: |
|
372 | 372 | |
|
373 | 373 | * timing information of the current request, including profiling information |
|
374 | 374 | * request data, including GET data, POST data, cookies, headers and environment |
|
375 | 375 | variables |
|
376 | 376 | * a list of executed database queries, including timing and result values |
|
377 | 377 | |
|
378 | 378 | DebugBar is only activated when ``debug = true`` is set in the configuration |
|
379 | 379 | file. This is important, because the DebugBar toolbar will be visible for all |
|
380 | 380 | users, and allow them to see information they should not be allowed to see. Like |
|
381 | 381 | is anyway the case for ``debug = true``, do not use this in production! |
|
382 | 382 | |
|
383 | 383 | To enable DebugBar, install ``tgext.debugbar`` and ``kajiki`` (typically via |
|
384 | 384 | ``pip``) and restart Kallithea (in debug mode). |
|
385 | 385 | |
|
386 | 386 | |
|
387 | 387 | Thank you for your contribution! |
|
388 | 388 | -------------------------------- |
|
389 | 389 | |
|
390 | 390 | |
|
391 | 391 | .. _Weblate: http://weblate.org/ |
|
392 | 392 | .. _mailing list: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general |
|
393 | 393 | .. _kallithea-general: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general |
|
394 | 394 | .. _Hosted Weblate: https://hosted.weblate.org/projects/kallithea/kallithea/ |
|
395 | 395 | .. _DebugBar: https://github.com/TurboGears/tgext.debugbar |
|
396 | 396 | .. _Quick Start: https://www.mercurial-scm.org/wiki/QuickStart |
|
397 | 397 | .. _Beginners Guide: https://www.mercurial-scm.org/wiki/BeginnersGuides |
@@ -1,144 +1,144 b'' | |||
|
1 | 1 | .. _installation: |
|
2 | 2 | |
|
3 | 3 | ========================== |
|
4 | 4 | Installation on Unix/Linux |
|
5 | 5 | ========================== |
|
6 | 6 | |
|
7 | 7 | The following describes three different ways of installing Kallithea: |
|
8 | 8 | |
|
9 | 9 | - :ref:`installation-source`: The simplest way to keep the installation |
|
10 | 10 | up-to-date and track any local customizations is to run directly from |
|
11 | 11 | source in a Kallithea repository clone, preferably inside a virtualenv |
|
12 | 12 | virtual Python environment. |
|
13 | 13 | |
|
14 | 14 | - :ref:`installation-virtualenv`: If you prefer to only use released versions |
|
15 | 15 | of Kallithea, the recommended method is to install Kallithea in a virtual |
|
16 | 16 | Python environment using `virtualenv`. The advantages of this method over |
|
17 | 17 | direct installation is that Kallithea and its dependencies are completely |
|
18 | 18 | contained inside the virtualenv (which also means you can have multiple |
|
19 | 19 | installations side by side or remove it entirely by just removing the |
|
20 | 20 | virtualenv directory) and does not require root privileges. |
|
21 | 21 | |
|
22 | 22 | - Kallithea can also be installed with plain pip - globally or with ``--user`` |
|
23 | 23 | or similar. The package will be installed in the same location as all other |
|
24 | 24 | Python packages you have ever installed. As a result, removing it is not as |
|
25 | 25 | straightforward as with a virtualenv, as you'd have to remove its |
|
26 | 26 | dependencies manually and make sure that they are not needed by other |
|
27 | 27 | packages. We recommend using virtualenv. |
|
28 | 28 | |
|
29 | 29 | Regardless of the installation method you may need to make sure you have |
|
30 | 30 | appropriate development packages installed, as installation of some of the |
|
31 | 31 | Kallithea dependencies requires a working C compiler and libffi library |
|
32 | 32 | headers. Depending on your configuration, you may also need to install |
|
33 | 33 | Git and development packages for the database of your choice. |
|
34 | 34 | |
|
35 | 35 | For Debian and Ubuntu, the following command will ensure that a reasonable |
|
36 | 36 | set of dependencies is installed:: |
|
37 | 37 | |
|
38 | 38 | sudo apt-get install build-essential git libffi-dev python3-dev |
|
39 | 39 | |
|
40 | 40 | For Fedora and RHEL-derivatives, the following command will ensure that a |
|
41 | 41 | reasonable set of dependencies is installed:: |
|
42 | 42 | |
|
43 | 43 | sudo yum install gcc git libffi-devel python3-devel |
|
44 | 44 | |
|
45 | 45 | .. _installation-source: |
|
46 | 46 | |
|
47 | 47 | |
|
48 | 48 | Installation from repository source |
|
49 | 49 | ----------------------------------- |
|
50 | 50 | |
|
51 | 51 | To install Kallithea in a virtualenv using the stable branch of the development |
|
52 | 52 | repository, use the following commands in your bash shell:: |
|
53 | 53 | |
|
54 | 54 | hg clone https://kallithea-scm.org/repos/kallithea -u stable |
|
55 | 55 | cd kallithea |
|
56 | 56 | python3 -m venv venv |
|
57 | 57 | . venv/bin/activate |
|
58 | pip install --upgrade pip "setuptools<67" | |
|
58 | pip install --upgrade "pip<24.1" "setuptools<67" | |
|
59 | 59 | pip install --upgrade -e . |
|
60 | 60 | python3 setup.py compile_catalog # for translation of the UI |
|
61 | 61 | |
|
62 | 62 | .. note:: |
|
63 | 63 | This will install all Python dependencies into the virtualenv. Kallithea |
|
64 | 64 | itself will however only be installed as a pointer to the source location. |
|
65 | 65 | The source clone must thus be kept in the same location, and it shouldn't be |
|
66 | 66 | updated to other revisions unless you want to upgrade. Edits in the source |
|
67 | 67 | tree will have immediate impact (possibly after a restart of the service). |
|
68 | 68 | |
|
69 | 69 | You can now proceed to :ref:`prepare-front-end-files`. |
|
70 | 70 | |
|
71 | 71 | .. _installation-virtualenv: |
|
72 | 72 | |
|
73 | 73 | |
|
74 | 74 | Installing a released version in a virtualenv |
|
75 | 75 | --------------------------------------------- |
|
76 | 76 | |
|
77 | 77 | It is highly recommended to use a separate virtualenv for installing Kallithea. |
|
78 | 78 | This way, all libraries required by Kallithea will be installed separately from your |
|
79 | 79 | main Python installation and other applications and things will be less |
|
80 | 80 | problematic when upgrading the system or Kallithea. |
|
81 | 81 | An additional benefit of virtualenv is that it doesn't require root privileges. |
|
82 | 82 | |
|
83 | 83 | - Don't install as root - install as a dedicated user like ``kallithea``. |
|
84 | 84 | If necessary, create the top directory for the virtualenv (like |
|
85 | 85 | ``/srv/kallithea/venv``) as root and assign ownership to the user. |
|
86 | 86 | |
|
87 | 87 | Make a parent folder for the virtualenv (and perhaps also Kallithea |
|
88 | 88 | configuration and data files) such as ``/srv/kallithea``. Create the |
|
89 | 89 | directory as root if necessary and grant ownership to the ``kallithea`` user. |
|
90 | 90 | |
|
91 | 91 | - Create a new virtual environment, for example in ``/srv/kallithea/venv``, |
|
92 | 92 | specifying the right Python binary:: |
|
93 | 93 | |
|
94 | 94 | python3 -m venv /srv/kallithea/venv |
|
95 | 95 | |
|
96 | 96 | - Activate the virtualenv in your current shell session and make sure the |
|
97 | 97 | basic requirements are up-to-date by running the following commands in your |
|
98 | 98 | bash shell:: |
|
99 | 99 | |
|
100 | 100 | . /srv/kallithea/venv/bin/activate |
|
101 | pip install --upgrade pip "setuptools<67" | |
|
101 | pip install --upgrade "pip<24.1" "setuptools<67" | |
|
102 | 102 | |
|
103 | 103 | .. note:: You can't use UNIX ``sudo`` to source the ``activate`` script; it |
|
104 | 104 | will "activate" a shell that terminates immediately. |
|
105 | 105 | |
|
106 | 106 | - Install Kallithea in the activated virtualenv:: |
|
107 | 107 | |
|
108 | 108 | pip install --upgrade kallithea |
|
109 | 109 | |
|
110 | 110 | .. note:: Some dependencies are optional. If you need them, install them in |
|
111 | 111 | the virtualenv too:: |
|
112 | 112 | |
|
113 | 113 | pip install --upgrade kallithea python-ldap python-pam psycopg2 |
|
114 | 114 | |
|
115 | 115 | This might require installation of development packages using your |
|
116 | 116 | distribution's package manager. |
|
117 | 117 | |
|
118 | 118 | Alternatively, download a .tar.gz from http://pypi.python.org/pypi/Kallithea, |
|
119 | 119 | extract it and install from source by running:: |
|
120 | 120 | |
|
121 | 121 | pip install --upgrade . |
|
122 | 122 | |
|
123 | 123 | - This will install Kallithea together with all other required |
|
124 | 124 | Python libraries into the activated virtualenv. |
|
125 | 125 | |
|
126 | 126 | You can now proceed to :ref:`prepare-front-end-files`. |
|
127 | 127 | |
|
128 | 128 | .. _prepare-front-end-files: |
|
129 | 129 | |
|
130 | 130 | |
|
131 | 131 | Prepare front-end files |
|
132 | 132 | ----------------------- |
|
133 | 133 | |
|
134 | 134 | Finally, the front-end files with CSS and JavaScript must be prepared. This |
|
135 | 135 | depends on having some commands available in the shell search path: ``npm`` |
|
136 | 136 | version 6 or later, and ``node.js`` (version 12 or later) available as |
|
137 | 137 | ``node``. The installation method for these dependencies varies between |
|
138 | 138 | operating systems and distributions. |
|
139 | 139 | |
|
140 | 140 | Prepare the front-end by running:: |
|
141 | 141 | |
|
142 | 142 | kallithea-cli front-end-build |
|
143 | 143 | |
|
144 | 144 | You can now proceed to :ref:`setup`. |
@@ -1,193 +1,193 b'' | |||
|
1 | 1 | .. _installation_win: |
|
2 | 2 | |
|
3 | 3 | .. warning:: This section is outdated and needs updating for Python 3. |
|
4 | 4 | |
|
5 | 5 | ==================================================== |
|
6 | 6 | Installation on Windows (7/Server 2008 R2 and newer) |
|
7 | 7 | ==================================================== |
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | First time install |
|
11 | 11 | ------------------ |
|
12 | 12 | |
|
13 | 13 | Target OS: Windows 7 and newer or Windows Server 2008 R2 and newer |
|
14 | 14 | |
|
15 | 15 | Tested on Windows 8.1, Windows Server 2008 R2 and Windows Server 2012 |
|
16 | 16 | |
|
17 | 17 | To install on an older version of Windows, see `<installation_win_old.html>`_ |
|
18 | 18 | |
|
19 | 19 | Step 1 -- Install Python |
|
20 | 20 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
|
21 | 21 | |
|
22 | 22 | Install Python 3. Latest version is recommended. If you need another version, they can run side by side. |
|
23 | 23 | |
|
24 | 24 | - Download Python 3 from http://www.python.org/download/ |
|
25 | 25 | - Choose and click on the version |
|
26 | 26 | - Click on "Windows X86-64 Installer" for x64 or "Windows x86 MSI installer" for Win32. |
|
27 | 27 | - Disable UAC or run the installer with admin privileges. If you chose to disable UAC, do not forget to reboot afterwards. |
|
28 | 28 | |
|
29 | 29 | While writing this guide, the latest version was v3.8.1. |
|
30 | 30 | Remember the specific major and minor versions installed, because they will |
|
31 | 31 | be needed in the next step. In this case, it is "3.8". |
|
32 | 32 | |
|
33 | 33 | Step 2 -- Python BIN |
|
34 | 34 | ^^^^^^^^^^^^^^^^^^^^ |
|
35 | 35 | |
|
36 | 36 | Add Python BIN folder to the path. This can be done manually (editing |
|
37 | 37 | "PATH" environment variable) or by using Windows Support Tools that |
|
38 | 38 | come pre-installed in Windows Vista/7 and later. |
|
39 | 39 | |
|
40 | 40 | Open a CMD and type:: |
|
41 | 41 | |
|
42 | 42 | SETX PATH "%PATH%;[your-python-path]" /M |
|
43 | 43 | |
|
44 | 44 | Please substitute [your-python-path] with your Python installation |
|
45 | 45 | path. Typically this is ``C:\\Python38``. |
|
46 | 46 | |
|
47 | 47 | Step 3 -- Install pywin32 extensions |
|
48 | 48 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
49 | 49 | |
|
50 | 50 | Download pywin32 from: |
|
51 | 51 | http://sourceforge.net/projects/pywin32/files/ |
|
52 | 52 | |
|
53 | 53 | - Click on "pywin32" folder |
|
54 | 54 | - Click on the first folder (in this case, Build 219, maybe newer when you try) |
|
55 | 55 | - Choose the file ending with ".amd64-py3.x.exe" (".win32-py3.x.exe" |
|
56 | 56 | for Win32) where x is the minor version of Python you installed. |
|
57 | 57 | When writing this guide, the file was: |
|
58 | 58 | http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win-amd64-py3.8.exe/download |
|
59 | 59 | (x64) |
|
60 | 60 | http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win32-py3.8.exe/download |
|
61 | 61 | (Win32) |
|
62 | 62 | |
|
63 | 63 | Step 5 -- Kallithea folder structure |
|
64 | 64 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
65 | 65 | |
|
66 | 66 | Create a Kallithea folder structure. |
|
67 | 67 | |
|
68 | 68 | This is only an example to install Kallithea. Of course, you can |
|
69 | 69 | change it. However, this guide will follow the proposed structure, so |
|
70 | 70 | please later adapt the paths if you change them. Folders without |
|
71 | 71 | spaces are recommended. |
|
72 | 72 | |
|
73 | 73 | Create the following folder structure:: |
|
74 | 74 | |
|
75 | 75 | C:\Kallithea |
|
76 | 76 | C:\Kallithea\Bin |
|
77 | 77 | C:\Kallithea\Env |
|
78 | 78 | C:\Kallithea\Repos |
|
79 | 79 | |
|
80 | 80 | Step 6 -- Install virtualenv |
|
81 | 81 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
82 | 82 | |
|
83 | 83 | .. note:: |
|
84 | 84 | A python virtual environment will allow for isolation between the Python packages of your system and those used for Kallithea. |
|
85 | 85 | It is strongly recommended to use it to ensure that Kallithea does not change a dependency that other software uses or vice versa. |
|
86 | 86 | |
|
87 | 87 | To create a virtual environment, run:: |
|
88 | 88 | |
|
89 | 89 | python3 -m venv C:\Kallithea\Env |
|
90 | 90 | |
|
91 | 91 | Step 7 -- Install Kallithea |
|
92 | 92 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
93 | 93 | |
|
94 | 94 | In order to install Kallithea, you need to be able to run "pip install kallithea". It will use pip to install the Kallithea Python package and its dependencies. |
|
95 | 95 | Some Python packages use managed code and need to be compiled. |
|
96 | 96 | This can be done on Linux without any special steps. On Windows, you will need to install Microsoft Visual C++ compiler for Python 3.8. |
|
97 | 97 | |
|
98 | 98 | Download and install "Microsoft Visual C++ Compiler for Python 3.8" from http://aka.ms/vcpython27 |
|
99 | 99 | |
|
100 | 100 | .. note:: |
|
101 | 101 | You can also install the dependencies using already compiled Windows binaries packages. A good source of compiled Python packages is http://www.lfd.uci.edu/~gohlke/pythonlibs/. However, not all of the necessary packages for Kallithea are on this site and some are hard to find, so we will stick with using the compiler. |
|
102 | 102 | |
|
103 | 103 | In a command prompt type (adapting paths if necessary):: |
|
104 | 104 | |
|
105 | 105 | cd C:\Kallithea\Env\Scripts |
|
106 | 106 | activate |
|
107 | pip install --upgrade pip "setuptools<67" | |
|
107 | pip install --upgrade "pip<24.1" "setuptools<67" | |
|
108 | 108 | |
|
109 | 109 | The prompt will change into "(Env) C:\\Kallithea\\Env\\Scripts" or similar |
|
110 | 110 | (depending of your folder structure). Then type:: |
|
111 | 111 | |
|
112 | 112 | pip install kallithea |
|
113 | 113 | |
|
114 | 114 | .. note:: This will take some time. Please wait patiently until it is fully |
|
115 | 115 | complete. Some warnings will appear. Don't worry, they are |
|
116 | 116 | normal. |
|
117 | 117 | |
|
118 | 118 | Step 8 -- Install Git (optional) |
|
119 | 119 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
120 | 120 | |
|
121 | 121 | Mercurial being a python package, was installed automatically when doing ``pip install kallithea``. |
|
122 | 122 | |
|
123 | 123 | You need to install Git manually if you want Kallithea to be able to host Git repositories. |
|
124 | 124 | See http://git-scm.com/book/en/v2/Getting-Started-Installing-Git#Installing-on-Windows for instructions. |
|
125 | 125 | The location of the Git binaries (like ``c:\path\to\git\bin``) must be |
|
126 | 126 | added to the ``PATH`` environment variable so ``git.exe`` and other tools like |
|
127 | 127 | ``gzip.exe`` are available. |
|
128 | 128 | |
|
129 | 129 | Step 9 -- Configuring Kallithea |
|
130 | 130 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
131 | 131 | |
|
132 | 132 | Steps taken from `<setup.html>`_ |
|
133 | 133 | |
|
134 | 134 | You have to use the same command prompt as in Step 7, so if you closed |
|
135 | 135 | it, reopen it following the same commands (including the "activate" |
|
136 | 136 | one). When ready, type:: |
|
137 | 137 | |
|
138 | 138 | cd C:\Kallithea\Bin |
|
139 | 139 | kallithea-cli config-create my.ini |
|
140 | 140 | |
|
141 | 141 | Then you must edit my.ini to fit your needs (IP address, IP |
|
142 | 142 | port, mail settings, database, etc.). `NotePad++`__ or a similar text |
|
143 | 143 | editor is recommended to properly handle the newline character |
|
144 | 144 | differences between Unix and Windows. |
|
145 | 145 | |
|
146 | 146 | __ http://notepad-plus-plus.org/ |
|
147 | 147 | |
|
148 | 148 | For the sake of simplicity, run it with the default settings. After your edits (if any) in the previous command prompt, type:: |
|
149 | 149 | |
|
150 | 150 | kallithea-cli db-create -c my.ini |
|
151 | 151 | |
|
152 | 152 | .. warning:: This time a *new* database will be installed. You must |
|
153 | 153 | follow a different process to later :ref:`upgrade <upgrade>` |
|
154 | 154 | to a newer Kallithea version. |
|
155 | 155 | |
|
156 | 156 | The script will ask you for confirmation about creating a new database, answer yes (y) |
|
157 | 157 | |
|
158 | 158 | The script will ask you for the repository path, answer C:\\Kallithea\\Repos (or similar). |
|
159 | 159 | |
|
160 | 160 | The script will ask you for the admin username and password, answer "admin" + "123456" (or whatever you want) |
|
161 | 161 | |
|
162 | 162 | The script will ask you for admin mail, answer "admin@xxxx.com" (or whatever you want). |
|
163 | 163 | |
|
164 | 164 | If you make a mistake and the script doesn't end, don't worry: start it again. |
|
165 | 165 | |
|
166 | 166 | If you decided not to install Git, you will get errors about it that you can ignore. |
|
167 | 167 | |
|
168 | 168 | Step 10 -- Running Kallithea |
|
169 | 169 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
170 | 170 | |
|
171 | 171 | In the previous command prompt, being in the C:\\Kallithea\\Bin folder, type:: |
|
172 | 172 | |
|
173 | 173 | gearbox serve -c my.ini |
|
174 | 174 | |
|
175 | 175 | Open your web server, and go to http://127.0.0.1:5000 |
|
176 | 176 | |
|
177 | 177 | It works!! :-) |
|
178 | 178 | |
|
179 | 179 | Remark: |
|
180 | 180 | If it does not work the first time, Ctrl-C the CMD process and start it again. Don't forget the "http://" in Internet Explorer. |
|
181 | 181 | |
|
182 | 182 | What this guide does not cover: |
|
183 | 183 | |
|
184 | 184 | - Installing Celery |
|
185 | 185 | - Running Kallithea as a Windows Service. You can investigate here: |
|
186 | 186 | |
|
187 | 187 | - http://pypi.python.org/pypi/wsgisvc |
|
188 | 188 | - http://ryrobes.com/python/running-python-scripts-as-a-windows-service/ |
|
189 | 189 | - http://wiki.pylonshq.com/display/pylonscookbook/How+to+run+Pylons+as+a+Windows+service |
|
190 | 190 | |
|
191 | 191 | - Using Apache. You can investigate here: |
|
192 | 192 | |
|
193 | 193 | - https://groups.google.com/group/rhodecode/msg/c433074e813ffdc4 |
@@ -1,250 +1,250 b'' | |||
|
1 | 1 | .. _installation_win_old: |
|
2 | 2 | |
|
3 | 3 | .. warning:: This section is outdated and needs updating for Python 3. |
|
4 | 4 | |
|
5 | 5 | ========================================================== |
|
6 | 6 | Installation on Windows (XP/Vista/Server 2003/Server 2008) |
|
7 | 7 | ========================================================== |
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | First-time install |
|
11 | 11 | ------------------ |
|
12 | 12 | |
|
13 | 13 | Target OS: Windows XP SP3 32-bit English (Clean installation) |
|
14 | 14 | + All Windows Updates until 24-may-2012 |
|
15 | 15 | |
|
16 | 16 | .. note:: |
|
17 | 17 | |
|
18 | 18 | This installation is for 32-bit systems, for 64-bit Windows you might need |
|
19 | 19 | to download proper 64-bit versions of the different packages (Windows Installer, Win32py extensions) |
|
20 | 20 | plus some extra tweaks. |
|
21 | 21 | These extra steps haven been marked as "64-bit". |
|
22 | 22 | Tested on Windows Server 2008 R2 SP1, 9-feb-2013. |
|
23 | 23 | If you run into any 64-bit related problems, please check these pages: |
|
24 | 24 | |
|
25 | 25 | - http://blog.victorjabur.com/2011/06/05/compiling-python-2-7-modules-on-windows-32-and-64-using-msvc-2008-express/ |
|
26 | 26 | - http://bugs.python.org/issue7511 |
|
27 | 27 | |
|
28 | 28 | Step 1 -- Install Visual Studio 2008 Express |
|
29 | 29 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
30 | 30 | |
|
31 | 31 | Optional: You can also install MinGW, but VS2008 installation is easier. |
|
32 | 32 | |
|
33 | 33 | Download "Visual C++ 2008 Express Edition with SP1" from: |
|
34 | 34 | http://download.microsoft.com/download/E/8/E/E8EEB394-7F42-4963-A2D8-29559B738298/VS2008ExpressWithSP1ENUX1504728.iso |
|
35 | 35 | (if not found or relocated, google for "visual studio 2008 express" for updated link. This link was taken from http://stackoverflow.com/questions/15318560/visual-c-2008-express-download-link-dead) |
|
36 | 36 | |
|
37 | 37 | You can also download full ISO file for offline installation, just |
|
38 | 38 | choose "All -- Offline Install ISO image file" in the previous page and |
|
39 | 39 | choose "Visual C++ 2008 Express" when installing. |
|
40 | 40 | |
|
41 | 41 | .. note:: |
|
42 | 42 | |
|
43 | 43 | Using other versions of Visual Studio will lead to random crashes. |
|
44 | 44 | You must use Visual Studio 2008!" |
|
45 | 45 | |
|
46 | 46 | .. note:: |
|
47 | 47 | |
|
48 | 48 | Silverlight Runtime and SQL Server 2008 Express Edition are not |
|
49 | 49 | required, you can uncheck them |
|
50 | 50 | |
|
51 | 51 | .. note:: |
|
52 | 52 | |
|
53 | 53 | 64-bit: You also need to install the Microsoft Windows SDK for .NET 3.5 SP1 (.NET 4.0 won't work). |
|
54 | 54 | Download from: http://www.microsoft.com/en-us/download/details.aspx?id=3138 |
|
55 | 55 | |
|
56 | 56 | .. note:: |
|
57 | 57 | |
|
58 | 58 | 64-bit: You also need to copy and rename a .bat file to make the Visual C++ compiler work. |
|
59 | 59 | I am not sure why this is not necessary for 32-bit. |
|
60 | 60 | Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat to C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat |
|
61 | 61 | |
|
62 | 62 | Step 2 -- Install Python |
|
63 | 63 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
|
64 | 64 | |
|
65 | 65 | Install Python 3.8.x from: |
|
66 | 66 | http://www.python.org/download/ |
|
67 | 67 | |
|
68 | 68 | Remember the specific major and minor version installed, because it will |
|
69 | 69 | be needed in the next step. In this case, it is "3.8". |
|
70 | 70 | |
|
71 | 71 | .. note:: |
|
72 | 72 | |
|
73 | 73 | 64-bit: Just download and install the 64-bit version of python. |
|
74 | 74 | |
|
75 | 75 | Step 3 -- Install Win32py extensions |
|
76 | 76 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
77 | 77 | |
|
78 | 78 | Download pywin32 from: |
|
79 | 79 | http://sourceforge.net/projects/pywin32/files/ |
|
80 | 80 | |
|
81 | 81 | - Click on "pywin32" folder |
|
82 | 82 | - Click on the first folder (in this case, Build 218, maybe newer when you try) |
|
83 | 83 | - Choose the file ending with ".win32-py3.x.exe" -> x being the minor |
|
84 | 84 | version of Python you installed (in this case, 7) |
|
85 | 85 | When writing this guide, the file was: |
|
86 | 86 | http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win-amd64-py3.8.exe/download |
|
87 | 87 | |
|
88 | 88 | .. note:: |
|
89 | 89 | |
|
90 | 90 | 64-bit: Download and install the 64-bit version. |
|
91 | 91 | At the time of writing you can find this at: |
|
92 | 92 | http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win-amd64-py3.8.exe/download |
|
93 | 93 | |
|
94 | 94 | Step 4 -- Python BIN |
|
95 | 95 | ^^^^^^^^^^^^^^^^^^^^ |
|
96 | 96 | |
|
97 | 97 | Add Python BIN folder to the path |
|
98 | 98 | |
|
99 | 99 | You have to add the Python folder to the path, you can do it manually |
|
100 | 100 | (editing "PATH" environment variable) or using Windows Support Tools |
|
101 | 101 | that came preinstalled in Vista/7 and can be installed in Windows XP. |
|
102 | 102 | |
|
103 | 103 | - Using support tools on WINDOWS XP: |
|
104 | 104 | If you use Windows XP you can install them using Windows XP CD and |
|
105 | 105 | navigating to \SUPPORT\TOOLS. There, execute Setup.EXE (not MSI). |
|
106 | 106 | Afterwards, open a CMD and type:: |
|
107 | 107 | |
|
108 | 108 | SETX PATH "%PATH%;[your-python-path]" -M |
|
109 | 109 | |
|
110 | 110 | Close CMD (the path variable will be updated then) |
|
111 | 111 | |
|
112 | 112 | - Using support tools on WINDOWS Vista/7: |
|
113 | 113 | |
|
114 | 114 | Open a CMD and type:: |
|
115 | 115 | |
|
116 | 116 | SETX PATH "%PATH%;[your-python-path]" /M |
|
117 | 117 | |
|
118 | 118 | Please substitute [your-python-path] with your Python installation path. |
|
119 | 119 | Typically: C:\\Python38 |
|
120 | 120 | |
|
121 | 121 | Step 5 -- Kallithea folder structure |
|
122 | 122 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
123 | 123 | |
|
124 | 124 | Create a Kallithea folder structure |
|
125 | 125 | |
|
126 | 126 | This is only a example to install Kallithea, you can of course change |
|
127 | 127 | it. However, this guide will follow the proposed structure, so please |
|
128 | 128 | later adapt the paths if you change them. My recommendation is to use |
|
129 | 129 | folders with NO SPACES. But you can try if you are brave... |
|
130 | 130 | |
|
131 | 131 | Create the following folder structure:: |
|
132 | 132 | |
|
133 | 133 | C:\Kallithea |
|
134 | 134 | C:\Kallithea\Bin |
|
135 | 135 | C:\Kallithea\Env |
|
136 | 136 | C:\Kallithea\Repos |
|
137 | 137 | |
|
138 | 138 | Step 6 -- Install virtualenv |
|
139 | 139 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
140 | 140 | |
|
141 | 141 | Create a virtual Python environment in C:\\Kallithea\\Env (or similar). To |
|
142 | 142 | do so, open a CMD (Python Path should be included in Step3), and write:: |
|
143 | 143 | |
|
144 | 144 | python3 -m venv C:\Kallithea\Env |
|
145 | 145 | |
|
146 | 146 | Step 7 -- Install Kallithea |
|
147 | 147 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
148 | 148 | |
|
149 | 149 | Finally, install Kallithea |
|
150 | 150 | |
|
151 | 151 | Close previously opened command prompt/s, and open a Visual Studio 2008 |
|
152 | 152 | Command Prompt (**IMPORTANT!!**). To do so, go to Start Menu, and then open |
|
153 | 153 | "Microsoft Visual C++ 2008 Express Edition" -> "Visual Studio Tools" -> |
|
154 | 154 | "Visual Studio 2008 Command Prompt" |
|
155 | 155 | |
|
156 | 156 | .. note:: |
|
157 | 157 | |
|
158 | 158 | 64-bit: For 64-bit you need to modify the shortcut that is used to start the |
|
159 | 159 | Visual Studio 2008 Command Prompt. Use right-mouse click to open properties. |
|
160 | 160 | |
|
161 | 161 | Change commandline from:: |
|
162 | 162 | |
|
163 | 163 | %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86 |
|
164 | 164 | |
|
165 | 165 | to:: |
|
166 | 166 | |
|
167 | 167 | %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" amd64 |
|
168 | 168 | |
|
169 | 169 | In that CMD (loaded with VS2008 PATHs) type:: |
|
170 | 170 | |
|
171 | 171 | cd C:\Kallithea\Env\Scripts (or similar) |
|
172 | 172 | activate |
|
173 | pip install --upgrade pip "setuptools<67" | |
|
173 | pip install --upgrade "pip<24.1" "setuptools<67" | |
|
174 | 174 | |
|
175 | 175 | The prompt will change into "(Env) C:\\Kallithea\\Env\\Scripts" or similar |
|
176 | 176 | (depending of your folder structure). Then type:: |
|
177 | 177 | |
|
178 | 178 | pip install kallithea |
|
179 | 179 | |
|
180 | 180 | (long step, please wait until fully complete) |
|
181 | 181 | |
|
182 | 182 | Some warnings will appear, don't worry as they are normal. |
|
183 | 183 | |
|
184 | 184 | Step 8 -- Configuring Kallithea |
|
185 | 185 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
186 | 186 | |
|
187 | 187 | steps taken from http://packages.python.org/Kallithea/setup.html |
|
188 | 188 | |
|
189 | 189 | You have to use the same Visual Studio 2008 command prompt as Step7, so |
|
190 | 190 | if you closed it reopen it following the same commands (including the |
|
191 | 191 | "activate" one). When ready, just type:: |
|
192 | 192 | |
|
193 | 193 | cd C:\Kallithea\Bin |
|
194 | 194 | kallithea-cli config-create my.ini |
|
195 | 195 | |
|
196 | 196 | Then, you must edit my.ini to fit your needs (network address and |
|
197 | 197 | port, mail settings, database, whatever). I recommend using NotePad++ |
|
198 | 198 | (free) or similar text editor, as it handles well the EndOfLine |
|
199 | 199 | character differences between Unix and Windows |
|
200 | 200 | (http://notepad-plus-plus.org/) |
|
201 | 201 | |
|
202 | 202 | For the sake of simplicity lets run it with the default settings. After |
|
203 | 203 | your edits (if any), in the previous Command Prompt, type:: |
|
204 | 204 | |
|
205 | 205 | kallithea-cli db-create -c my.ini |
|
206 | 206 | |
|
207 | 207 | .. warning:: This time a *new* database will be installed. You must |
|
208 | 208 | follow a different process to later :ref:`upgrade <upgrade>` |
|
209 | 209 | to a newer Kallithea version. |
|
210 | 210 | |
|
211 | 211 | The script will ask you for confirmation about creating a NEW database, |
|
212 | 212 | answer yes (y) |
|
213 | 213 | The script will ask you for repository path, answer C:\\Kallithea\\Repos |
|
214 | 214 | (or similar) |
|
215 | 215 | The script will ask you for admin username and password, answer "admin" |
|
216 | 216 | + "123456" (or whatever you want) |
|
217 | 217 | The script will ask you for admin mail, answer "admin@xxxx.com" (or |
|
218 | 218 | whatever you want) |
|
219 | 219 | |
|
220 | 220 | If you make some mistake and the script does not end, don't worry, start |
|
221 | 221 | it again. |
|
222 | 222 | |
|
223 | 223 | Step 9 -- Running Kallithea |
|
224 | 224 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
225 | 225 | |
|
226 | 226 | In the previous command prompt, being in the C:\\Kallithea\\Bin folder, |
|
227 | 227 | just type:: |
|
228 | 228 | |
|
229 | 229 | gearbox serve -c my.ini |
|
230 | 230 | |
|
231 | 231 | Open yout web server, and go to http://127.0.0.1:5000 |
|
232 | 232 | |
|
233 | 233 | It works!! :-) |
|
234 | 234 | |
|
235 | 235 | Remark: |
|
236 | 236 | If it does not work first time, just Ctrl-C the CMD process and start it |
|
237 | 237 | again. Don't forget the "http://" in Internet Explorer |
|
238 | 238 | |
|
239 | 239 | What this Guide does not cover: |
|
240 | 240 | |
|
241 | 241 | - Installing Celery |
|
242 | 242 | - Running Kallithea as Windows Service. You can investigate here: |
|
243 | 243 | |
|
244 | 244 | - http://pypi.python.org/pypi/wsgisvc |
|
245 | 245 | - http://ryrobes.com/python/running-python-scripts-as-a-windows-service/ |
|
246 | 246 | - http://wiki.pylonshq.com/display/pylonscookbook/How+to+run+Pylons+as+a+Windows+service |
|
247 | 247 | |
|
248 | 248 | - Using Apache. You can investigate here: |
|
249 | 249 | |
|
250 | 250 | - https://groups.google.com/group/rhodecode/msg/c433074e813ffdc4 |
@@ -1,121 +1,121 b'' | |||
|
1 | 1 | #!/bin/sh -e |
|
2 | 2 | |
|
3 | 3 | if [ $# -lt 2 ] || [ $# -gt 3 ]; then |
|
4 | 4 | cat >&2 <<EOD |
|
5 | 5 | usage: $0 CONFIG_FILE FROM_REV [TO_REV] |
|
6 | 6 | |
|
7 | 7 | Runs a database migration from FROM_REV to TO_REV (default: current |
|
8 | 8 | working directory parent), using the specified CONFIG_FILE (.ini file). |
|
9 | 9 | |
|
10 | 10 | Test is run using a clean Kallithea install, in a temporary virtual |
|
11 | 11 | environment. FROM_REV and (optional) TO_REV should be Mercurial revision |
|
12 | 12 | identifiers (e.g. changeset hash or a version number tag). The working |
|
13 | 13 | directory is not touched, but the database referenced in the config file |
|
14 | 14 | will be (re)created. |
|
15 | 15 | |
|
16 | 16 | Only SQLite is available out of the box; for MySQL or PostgreSQL, set |
|
17 | 17 | the EXTRA environment variable to the required package(s), and it'll |
|
18 | 18 | be installed in the virtual environment. (E.g. EXTRA=MySQL-python or |
|
19 | 19 | EXTRA=psycopg2.) |
|
20 | 20 | |
|
21 | 21 | The temporary directory is not removed, allowing follow-up examination |
|
22 | 22 | of the upgrade results. It is, however, created in /tmp by default, |
|
23 | 23 | which many Linux distributions automatically clean at regular intervals. |
|
24 | 24 | EOD |
|
25 | 25 | exit 1 |
|
26 | 26 | fi |
|
27 | 27 | |
|
28 | 28 | config_file=$(readlink -f "$1") |
|
29 | 29 | from_rev=$2 |
|
30 | 30 | to_rev=$3 |
|
31 | 31 | source_repo=$(dirname "$(dirname "$(readlink -f "$0")")") |
|
32 | 32 | |
|
33 | 33 | announce() { |
|
34 | 34 | echo |
|
35 | 35 | echo "$1" |
|
36 | 36 | echo |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | quiet_if_ok() ( |
|
40 | 40 | local output |
|
41 | 41 | local st |
|
42 | 42 | set +e |
|
43 | 43 | output=$("$@" < /dev/null 2>&1) |
|
44 | 44 | st=$? |
|
45 | 45 | if [ $st -ne 0 ]; then |
|
46 | 46 | echo "$output" >&2 |
|
47 | 47 | echo "Command $@ returned exit status $st." >&2 |
|
48 | 48 | exit 1 |
|
49 | 49 | fi |
|
50 | 50 | ) |
|
51 | 51 | |
|
52 | 52 | HG() { |
|
53 | 53 | "${HG:-hg}" --repository "$source_repo" "$@" |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | 56 | # If upgrading to "current revision", warn if working directory is dirty. |
|
57 | 57 | if [ ! "$to_rev" ] && [ "$(HG status -mard)" ]; then |
|
58 | 58 | announce "Warning: Uncommitted changes in working directory will be ignored!" |
|
59 | 59 | fi |
|
60 | 60 | |
|
61 | 61 | from_rev_hash=$(HG id --id --rev "${from_rev:-.}") |
|
62 | 62 | to_rev_hash=$(HG id --id --rev "${to_rev:-.}") |
|
63 | 63 | temp=$(readlink -f "$(mktemp --tmpdir -d 'dbmigrate-test.XXXXXX')") |
|
64 | 64 | |
|
65 | 65 | cat <<EOD |
|
66 | 66 | Config file: $config_file |
|
67 | 67 | EOD |
|
68 | 68 | sed -n -e 's/^sqlalchemy\.url *= */Database URL: /p' "$config_file" |
|
69 | 69 | cat <<EOD |
|
70 | 70 | Working dir: $temp |
|
71 | 71 | Repository: $source_repo |
|
72 | 72 | Upgrade from: $from_rev_hash (${from_rev:-current}) |
|
73 | 73 | Upgrade to: $to_rev_hash (${to_rev:-current}) |
|
74 | 74 | Extra packages: ${EXTRA:-(none)} |
|
75 | 75 | EOD |
|
76 | 76 | |
|
77 | 77 | mkdir "$temp/repos" # empty |
|
78 | 78 | |
|
79 | 79 | # Enable caching for old pip versions (this will cache the pip upgrade) |
|
80 | 80 | # Newer pip versions cache automatically, and don't use this variable. |
|
81 | 81 | if [ ! "$PIP_DOWNLOAD_CACHE" ]; then |
|
82 | 82 | export PIP_DOWNLOAD_CACHE=$HOME/.cache/pip/legacy |
|
83 | 83 | fi |
|
84 | 84 | |
|
85 | 85 | install_kallithea() { |
|
86 | 86 | local prefix=$1 |
|
87 | 87 | local rev=$2 |
|
88 | 88 | |
|
89 | 89 | announce "Installing Kallithea $rev in $prefix..." |
|
90 | 90 | |
|
91 | 91 | "${VIRTUALENV:-virtualenv}" --quiet "$prefix-env" |
|
92 | 92 | HG archive --rev "$rev" "$prefix" |
|
93 | 93 | |
|
94 | 94 | ( |
|
95 | 95 | cd "$prefix" |
|
96 | 96 | . "$prefix-env/bin/activate" |
|
97 | pip install --quiet --upgrade pip "setuptools<67" mercurial $EXTRA | |
|
97 | pip install --quiet --upgrade "pip<24.1" "setuptools<67" mercurial $EXTRA | |
|
98 | 98 | pip install --quiet -e . |
|
99 | 99 | ) |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | install_kallithea "$temp/from" "$from_rev_hash" |
|
103 | 103 | ( |
|
104 | 104 | cd "$temp/from" |
|
105 | 105 | . "$temp/from-env/bin/activate" |
|
106 | 106 | announce "Initializing database..." |
|
107 | 107 | quiet_if_ok kallithea-cli db-create -c "$config_file" --repos="$temp/repos" --user=doe --email=doe@example.com --password=123456 --no-public-access --force-yes |
|
108 | 108 | alembic -c "$config_file" current -v |
|
109 | 109 | ) |
|
110 | 110 | |
|
111 | 111 | install_kallithea "$temp/to" "$to_rev_hash" |
|
112 | 112 | ( |
|
113 | 113 | cd "$temp/to" |
|
114 | 114 | . "$temp/to-env/bin/activate" |
|
115 | 115 | |
|
116 | 116 | announce "Commencing database upgrade from shown Alembic revision to head..." |
|
117 | 117 | alembic -c "$config_file" current -v |
|
118 | 118 | alembic -c "$config_file" upgrade head |
|
119 | 119 | announce "Upgrade complete, now at the shown Alembic revision:" |
|
120 | 120 | alembic -c "$config_file" current -v |
|
121 | 121 | ) |
@@ -1,74 +1,74 b'' | |||
|
1 | 1 | #!/bin/bash |
|
2 | 2 | # Validate the specified commits against test suite and other checks. |
|
3 | 3 | |
|
4 | 4 | if [ -n "$VIRTUAL_ENV" ]; then |
|
5 | 5 | echo "Please run this script from outside a virtualenv." |
|
6 | 6 | exit 1 |
|
7 | 7 | fi |
|
8 | 8 | |
|
9 | 9 | if ! hg update --check -q .; then |
|
10 | 10 | echo "Working dir is not clean, please commit/revert changes first." |
|
11 | 11 | exit 1 |
|
12 | 12 | fi |
|
13 | 13 | |
|
14 | 14 | revset=$1 |
|
15 | 15 | if [ -z "$revset" ]; then |
|
16 | 16 | echo "Warning: no revisions specified, checking draft changes up to the current one." |
|
17 | 17 | revset='draft() and ancestors(.)' |
|
18 | 18 | fi |
|
19 | 19 | |
|
20 | 20 | venv=$(mktemp -d kallithea-validatecommits-env-XXXXXX) |
|
21 | 21 | resultfile=$(mktemp kallithea-validatecommits-result-XXXXXX) |
|
22 | 22 | echo > "$resultfile" |
|
23 | 23 | |
|
24 | 24 | cleanup() |
|
25 | 25 | { |
|
26 | 26 | rm -rf /tmp/kallithea-test* |
|
27 | 27 | rm -rf "$venv" |
|
28 | 28 | } |
|
29 | 29 | finish() |
|
30 | 30 | { |
|
31 | 31 | cleanup |
|
32 | 32 | # print (possibly intermediate) results |
|
33 | 33 | cat "$resultfile" |
|
34 | 34 | rm "$resultfile" |
|
35 | 35 | } |
|
36 | 36 | trap finish EXIT |
|
37 | 37 | |
|
38 | 38 | for rev in $(hg log -r "$revset" -T '{node}\n'); do |
|
39 | 39 | hg log -r "$rev" |
|
40 | 40 | hg update "$rev" |
|
41 | 41 | |
|
42 | 42 | cleanup |
|
43 | 43 | python3 -m venv "$venv" |
|
44 | 44 | source "$venv/bin/activate" |
|
45 | pip install --upgrade pip "setuptools<67" | |
|
45 | pip install --upgrade "pip<24.1" "setuptools<67" | |
|
46 | 46 | pip install -e . -r dev_requirements.txt python-ldap python-pam |
|
47 | 47 | |
|
48 | 48 | # run-all-cleanup |
|
49 | 49 | if ! scripts/run-all-cleanup ; then |
|
50 | 50 | echo "run-all-cleanup encountered errors!" |
|
51 | 51 | result="NOK" |
|
52 | 52 | else |
|
53 | 53 | if ! hg update --check -q .; then |
|
54 | 54 | echo "run-all-cleanup did not give clean results!" |
|
55 | 55 | result="NOK" |
|
56 | 56 | hg diff |
|
57 | 57 | hg revert -a |
|
58 | 58 | else |
|
59 | 59 | result=" OK" |
|
60 | 60 | fi |
|
61 | 61 | fi |
|
62 | 62 | echo "$result: $rev (run-all-cleanup)" >> "$resultfile" |
|
63 | 63 | |
|
64 | 64 | # pytest |
|
65 | 65 | if py.test; then |
|
66 | 66 | result=" OK" |
|
67 | 67 | else |
|
68 | 68 | result="NOK" |
|
69 | 69 | fi |
|
70 | 70 | echo "$result: $rev (pytest)" >> "$resultfile" |
|
71 | 71 | |
|
72 | 72 | deactivate |
|
73 | 73 | echo |
|
74 | 74 | done |
@@ -1,52 +1,52 b'' | |||
|
1 | 1 | #!/bin/bash |
|
2 | 2 | # Test that installation of all dependencies works fine if versions are set to |
|
3 | 3 | # the minimum ones. |
|
4 | 4 | |
|
5 | 5 | set -e |
|
6 | 6 | |
|
7 | 7 | if [ -n "$VIRTUAL_ENV" ]; then |
|
8 | 8 | echo "This script will create its own virtualenv - please don't run it inside an existing one." >&2 |
|
9 | 9 | exit 1 |
|
10 | 10 | fi |
|
11 | 11 | |
|
12 | 12 | cd "$(hg root)" |
|
13 | 13 | |
|
14 | 14 | venv=build/minimum-dependency-versions-venv |
|
15 | 15 | log=build/minimum-dependency-versions.log |
|
16 | 16 | min_requirements=build/minimum-dependency-versions-requirements.txt |
|
17 | 17 | echo "virtualenv: $venv" |
|
18 | 18 | echo "log: $log" |
|
19 | 19 | echo "minimum requirements file: $min_requirements" |
|
20 | 20 | |
|
21 | 21 | # clean up previous runs |
|
22 | 22 | rm -rf "$venv" "$log" |
|
23 | 23 | mkdir -p "$venv" |
|
24 | 24 | |
|
25 | 25 | # Make a light weight parsing of setup.py and dev_requirements.txt, |
|
26 | 26 | # finding all >= requirements and dumping into a custom requirements.txt |
|
27 | 27 | # while fixating the requirement at the lower bound. |
|
28 | 28 | sed -n 's/.*"\(.*\)>=\(.*\)".*/\1==\2/p' setup.py > "$min_requirements" |
|
29 | 29 | sed 's/>=/==/p' dev_requirements.txt >> "$min_requirements" |
|
30 | 30 | |
|
31 | 31 | python3 -m venv "$venv" |
|
32 | 32 | source "$venv/bin/activate" |
|
33 | pip install --upgrade pip "setuptools<67" | |
|
33 | pip install --upgrade "pip<24.1" "setuptools<67" | |
|
34 | 34 | pip install -e . -r "$min_requirements" python-ldap python-pam 2> >(tee "$log" >&2) |
|
35 | 35 | |
|
36 | 36 | # Treat any message on stderr as a problem, for the caller to interpret. |
|
37 | 37 | if [ -s "$log" ]; then |
|
38 | 38 | echo |
|
39 | 39 | echo "Error: pip detected following problems:" |
|
40 | 40 | cat "$log" |
|
41 | 41 | echo |
|
42 | 42 | exit 1 |
|
43 | 43 | fi |
|
44 | 44 | |
|
45 | 45 | freeze_txt=build/minimum-dependency-versions.txt |
|
46 | 46 | pip freeze > $freeze_txt |
|
47 | 47 | echo "Installation of minimum packages was successful, providing a set of packages as in $freeze_txt . Now running test suite..." |
|
48 | 48 | |
|
49 | 49 | pytest |
|
50 | 50 | |
|
51 | 51 | echo "Test suite execution was successful." |
|
52 | 52 | echo "You can now do additional validation using virtual env '$venv'." |
@@ -1,164 +1,164 b'' | |||
|
1 | 1 | #!/usr/bin/env python3 |
|
2 | 2 | # -*- coding: utf-8 -*- |
|
3 | 3 | import os |
|
4 | 4 | import platform |
|
5 | 5 | import re |
|
6 | 6 | import sys |
|
7 | 7 | |
|
8 | 8 | import setuptools |
|
9 | 9 | # monkey patch setuptools to use distutils owner/group functionality |
|
10 | 10 | from setuptools.command import sdist |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | if sys.version_info < (3, 6): |
|
14 | 14 | raise Exception('Kallithea requires Python 3.6 or later') |
|
15 | 15 | |
|
16 | 16 | |
|
17 | 17 | here = os.path.abspath(os.path.dirname(__file__)) |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | def _get_meta_var(name, data, callback_handler=None): |
|
21 | 21 | matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data) |
|
22 | 22 | if matches: |
|
23 | 23 | s = eval(matches.groups()[0]) |
|
24 | 24 | if callable(callback_handler): |
|
25 | 25 | return callback_handler(s) |
|
26 | 26 | return s |
|
27 | 27 | |
|
28 | 28 | _meta = open(os.path.join(here, 'kallithea', '__init__.py'), 'r') |
|
29 | 29 | _metadata = _meta.read() |
|
30 | 30 | _meta.close() |
|
31 | 31 | |
|
32 | 32 | def callback(V): |
|
33 | 33 | return '.'.join(map(str, V[:3])) + '.'.join(V[3:]) |
|
34 | 34 | __version__ = _get_meta_var('VERSION', _metadata, callback) |
|
35 | 35 | __license__ = _get_meta_var('__license__', _metadata) |
|
36 | 36 | __author__ = _get_meta_var('__author__', _metadata) |
|
37 | 37 | __url__ = _get_meta_var('__url__', _metadata) |
|
38 | 38 | # defines current platform |
|
39 | 39 | __platform__ = platform.system() |
|
40 | 40 | |
|
41 | 41 | is_windows = __platform__ in ['Windows'] |
|
42 | 42 | |
|
43 | 43 | requirements = [ |
|
44 | 44 | "alembic >= 1.0.10, < 1.5", |
|
45 | 45 | "gearbox >= 0.1.0, < 1", |
|
46 | 46 | "waitress >= 0.8.8, < 1.5", |
|
47 | 47 | "WebOb >= 1.8, < 1.9", |
|
48 | 48 | "backlash >= 0.1.2, < 1", |
|
49 | 49 | "TurboGears2 >= 2.4, < 2.5", |
|
50 | 50 | "tgext.routes >= 0.2.0, < 1", |
|
51 | 51 | "Beaker >= 1.10.1, < 2", |
|
52 | 52 | "WebHelpers2 >= 2.0, < 2.1", |
|
53 | 53 | "FormEncode >= 1.3.1, < 2.1", |
|
54 | 54 | "SQLAlchemy >= 1.2.9, < 1.4", |
|
55 | 55 | "Mako >= 0.9.1, < 1.2", |
|
56 | 56 | "Pygments >= 2.2.0, < 2.7", |
|
57 | 57 | "Whoosh >= 2.7.1, < 2.8", |
|
58 | 58 | "celery >= 5, < 5.1", |
|
59 | 59 | "Babel >= 1.3, < 2.9", |
|
60 | 60 | "python-dateutil >= 2.1.0, < 2.9", |
|
61 | 61 | "Markdown >= 2.2.1, < 3.2", |
|
62 | 62 | "docutils >= 0.11, < 0.17", |
|
63 | 63 | "URLObject >= 2.3.4, < 2.5", |
|
64 | 64 | "Routes >= 2.0, < 2.5", |
|
65 | 65 | "dulwich >= 0.19.0, < 0.20", |
|
66 | 66 | "mercurial >= 5.2, < 6.2", |
|
67 | 67 | "decorator >= 4.2.1, < 4.5", |
|
68 | 68 | "Paste >= 2.0.3, < 3.5", |
|
69 | 69 | "bleach >= 3.2, < 4.2", |
|
70 | 70 | "Click >= 7.0, < 8", |
|
71 | 71 | "ipaddr >= 2.2.0, < 2.3", |
|
72 | 72 | "paginate >= 0.5, < 0.6", |
|
73 | 73 | "paginate_sqlalchemy >= 0.3.0, < 0.4", |
|
74 | 74 | "bcrypt >= 3.1.0, < 3.2", |
|
75 |
"pip >= 20.0, < |
|
|
75 | "pip >= 20.0, < 24.1", | |
|
76 | 76 | "chardet >= 3", |
|
77 | 77 | ] |
|
78 | 78 | if sys.version_info < (3, 8): |
|
79 | 79 | requirements.append("importlib-metadata < 5") |
|
80 | 80 | |
|
81 | 81 | dependency_links = [ |
|
82 | 82 | ] |
|
83 | 83 | |
|
84 | 84 | classifiers = [ |
|
85 | 85 | 'Development Status :: 4 - Beta', |
|
86 | 86 | 'Environment :: Web Environment', |
|
87 | 87 | 'Framework :: Pylons', |
|
88 | 88 | 'Intended Audience :: Developers', |
|
89 | 89 | 'License :: OSI Approved :: GNU General Public License (GPL)', |
|
90 | 90 | 'Operating System :: OS Independent', |
|
91 | 91 | 'Programming Language :: Python :: 3.6', |
|
92 | 92 | 'Programming Language :: Python :: 3.7', |
|
93 | 93 | 'Programming Language :: Python :: 3.8', |
|
94 | 94 | 'Topic :: Software Development :: Version Control', |
|
95 | 95 | ] |
|
96 | 96 | |
|
97 | 97 | |
|
98 | 98 | # additional files from project that goes somewhere in the filesystem |
|
99 | 99 | # relative to sys.prefix |
|
100 | 100 | data_files = [] |
|
101 | 101 | |
|
102 | 102 | description = ('Kallithea is a fast and powerful management tool ' |
|
103 | 103 | 'for Mercurial and Git with a built in push/pull server, ' |
|
104 | 104 | 'full text search and code-review.') |
|
105 | 105 | |
|
106 | 106 | keywords = ' '.join([ |
|
107 | 107 | 'kallithea', 'mercurial', 'git', 'code review', |
|
108 | 108 | 'repo groups', 'ldap', 'repository management', 'hgweb replacement', |
|
109 | 109 | 'hgwebdir', 'gitweb replacement', 'serving hgweb', |
|
110 | 110 | ]) |
|
111 | 111 | |
|
112 | 112 | # long description |
|
113 | 113 | README_FILE = 'README.rst' |
|
114 | 114 | try: |
|
115 | 115 | long_description = open(README_FILE).read() |
|
116 | 116 | except IOError as err: |
|
117 | 117 | sys.stderr.write( |
|
118 | 118 | "[WARNING] Cannot find file specified as long_description (%s): %s\n" |
|
119 | 119 | % (README_FILE, err) |
|
120 | 120 | ) |
|
121 | 121 | long_description = description |
|
122 | 122 | |
|
123 | 123 | |
|
124 | 124 | sdist_org = sdist.sdist |
|
125 | 125 | class sdist_new(sdist_org): |
|
126 | 126 | def initialize_options(self): |
|
127 | 127 | sdist_org.initialize_options(self) |
|
128 | 128 | self.owner = self.group = 'root' |
|
129 | 129 | sdist.sdist = sdist_new |
|
130 | 130 | |
|
131 | 131 | packages = setuptools.find_packages(exclude=['ez_setup']) |
|
132 | 132 | |
|
133 | 133 | setuptools.setup( |
|
134 | 134 | name='Kallithea', |
|
135 | 135 | version=__version__, |
|
136 | 136 | description=description, |
|
137 | 137 | long_description=long_description, |
|
138 | 138 | keywords=keywords, |
|
139 | 139 | license=__license__, |
|
140 | 140 | author=__author__, |
|
141 | 141 | author_email='kallithea@sfconservancy.org', |
|
142 | 142 | dependency_links=dependency_links, |
|
143 | 143 | url=__url__, |
|
144 | 144 | install_requires=requirements, |
|
145 | 145 | classifiers=classifiers, |
|
146 | 146 | data_files=data_files, |
|
147 | 147 | packages=packages, |
|
148 | 148 | include_package_data=True, |
|
149 | 149 | message_extractors={'kallithea': [ |
|
150 | 150 | ('**.py', 'python', None), |
|
151 | 151 | ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}), |
|
152 | 152 | ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}), |
|
153 | 153 | ('public/**', 'ignore', None)]}, |
|
154 | 154 | zip_safe=False, |
|
155 | 155 | entry_points=""" |
|
156 | 156 | [console_scripts] |
|
157 | 157 | kallithea-api = kallithea.bin.kallithea_api:main |
|
158 | 158 | kallithea-gist = kallithea.bin.kallithea_gist:main |
|
159 | 159 | kallithea-cli = kallithea.bin.kallithea_cli:cli |
|
160 | 160 | |
|
161 | 161 | [paste.app_factory] |
|
162 | 162 | main = kallithea.config.application:make_app |
|
163 | 163 | """, |
|
164 | 164 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now