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