Skip to content

Commit 521f78a

Browse files
author
David Read
committedNov 8, 2019
Add requirements.txt for python 3
Also: * Install-by-source instructions is for python 3 * Adds initial python2->3 upgrade instructions * Initial adjustments to ckan/common.py for import in python3 I'm keen to do 'trunk based development' for python 3 work now. So python 3 is the default in the docs and requirements.txt. I realize that the devs who use master for other work might be a bit surprised/disrupted by these changes. However I think it is worth it because the focus now needs to be python3, and it's better to switch master's default now rather than just before release.
1 parent 66effbd commit 521f78a

11 files changed

+209
-63
lines changed
 

‎.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
4343
# Python Dependencies
4444
pip install -r requirement-setuptools.txt
45-
pip install -r requirements.txt
45+
pip install -r requirements-py2.txt
4646
pip install -r dev-requirements.txt
4747
python setup.py develop
4848

‎Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ RUN mkdir -p $CKAN_VENV $CKAN_CONFIG $CKAN_STORAGE_PATH && \
5050
ADD . $CKAN_VENV/src/ckan/
5151
RUN ckan-pip install -U pip && \
5252
ckan-pip install --upgrade --no-cache-dir -r $CKAN_VENV/src/ckan/requirement-setuptools.txt && \
53-
ckan-pip install --upgrade --no-cache-dir -r $CKAN_VENV/src/ckan/requirements.txt && \
53+
ckan-pip install --upgrade --no-cache-dir -r $CKAN_VENV/src/ckan/requirements-py2.txt && \
5454
ckan-pip install -e $CKAN_VENV/src/ckan/ && \
5555
ln -s $CKAN_VENV/src/ckan/ckan/config/who.ini $CKAN_CONFIG/who.ini && \
5656
cp -v $CKAN_VENV/src/ckan/contrib/docker/ckan-entrypoint.sh /ckan-entrypoint.sh && \

‎bin/travis-install-dependencies

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ sudo -E -u postgres ./bin/postgres_init/2_create_ckan_datastore_db.sh
3030

3131
export PIP_USE_MIRRORS=true
3232
pip install -r requirement-setuptools.txt --allow-all-external
33-
pip install -r requirements.txt --allow-all-external
33+
pip install -r requirements-py2.txt --allow-all-external
3434
pip install -r dev-requirements.txt --allow-all-external
3535

3636
python setup.py develop

‎ckan/common.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@
1111
from collections import MutableMapping
1212

1313
import flask
14-
import pylons
1514
import six
1615

1716
from werkzeug.local import Local, LocalProxy
1817

1918
from flask_babel import (gettext as flask_ugettext,
2019
ngettext as flask_ungettext)
21-
from pylons.i18n import (ugettext as pylons_ugettext,
22-
ungettext as pylons_ungettext)
23-
24-
from pylons import response
2520

2621
import simplejson as json
2722

23+
if six.PY2:
24+
import pylons
25+
from pylons.i18n import (ugettext as pylons_ugettext,
26+
ungettext as pylons_ungettext)
27+
from pylons import response
28+
2829
current_app = flask.current_app
2930

3031
try:
@@ -38,6 +39,8 @@ def is_flask_request():
3839
A centralized way to determine whether we are in the context of a
3940
request being served by Flask or Pylons
4041
'''
42+
if six.PY3:
43+
return True
4144
try:
4245
pylons.request.environ
4346
pylons_request_available = True

‎doc/maintaining/installing/install-from-source.rst

+34-25
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ work on CKAN.
2222
If you're using a Debian-based operating system (such as Ubuntu) install the
2323
required packages with this command::
2424

25-
sudo apt-get install python-dev postgresql libpq-dev python-pip python-virtualenv git-core solr-jetty openjdk-8-jdk redis-server
25+
sudo apt-get install python3-dev postgresql libpq-dev python3-pip python3-venv git-core solr-jetty openjdk-8-jdk redis-server
26+
27+
.. note::
28+
29+
For Python 2 (deprecated, but compatible with CKAN 2.9 and earlier), do
30+
this instead:
31+
32+
sudo apt-get install python-dev postgresql libpq-dev python-pip python-virtualenv git-core solr-jetty openjdk-8-jdk redis-server
2633

2734
If you're not using a Debian-based operating system, find the best way to
2835
install the following packages on your operating system (see
@@ -32,16 +39,16 @@ wiki page for help):
3239
===================== ===============================================
3340
Package Description
3441
===================== ===============================================
35-
Python `The Python programming language, v2.7 <http://www.python.org/getit/>`_
36-
|postgres| `The PostgreSQL database system, v9.3 or newer <http://www.postgresql.org/download/>`_
42+
Python `The Python programming language, v3.6 or newer (or v2.7) <https://www.python.org/getit/>`_
43+
|postgres| `The PostgreSQL database system, v9.3 or newer <https://www.postgresql.org/docs/9.5/libpq.html>`_
3744
libpq `The C programmer's interface to PostgreSQL <http://www.postgresql.org/docs/8.1/static/libpq.html>`_
38-
pip `A tool for installing and managing Python packages <http://www.pip-installer.org>`_
39-
virtualenv `The virtual Python environment builder <http://www.virtualenv.org>`_
40-
Git `A distributed version control system <http://book.git-scm.com/2_installing_git.html>`_
41-
Apache Solr `A search platform <http://lucene.apache.org/solr>`_
42-
Jetty `An HTTP server <http://www.eclipse.org/jetty/>`_ (used for Solr).
43-
OpenJDK JDK `The Java Development Kit <http://openjdk.java.net/install/>`_ (used by Jetty)
44-
Redis `An in-memory data structure store <http://redis.io/>`_
45+
pip `A tool for installing and managing Python packages <https://pip.pypa.io/en/stable/>`_
46+
python3-venv `The Python3 virtual environment builder (or for Python 2 use 'virtualenv' instead) <https://virtualenv.pypa.io/en/latest/>`_
47+
Git `A distributed version control system <https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>`_
48+
Apache Solr `A search platform <https://lucene.apache.org/solr/>`_
49+
Jetty `An HTTP server <https://www.eclipse.org/jetty/>`_ (used for Solr).
50+
OpenJDK JDK `The Java Development Kit <https://openjdk.java.net/install/>`_ (used by Jetty)
51+
Redis `An in-memory data structure store <https://redis.io/>`_
4552
===================== ===============================================
4653

4754

@@ -66,28 +73,16 @@ Redis `An in-memory data structure store <http://redis.io/>`_
6673
mkdir -p ~/ckan/etc
6774
sudo ln -s ~/ckan/etc |config_parent_dir|
6875
69-
a. Create a Python `virtual environment <http://www.virtualenv.org>`_
76+
a. Create a Python `virtual environment <https://virtualenv.pypa.io/en/latest/>`_
7077
(virtualenv) to install CKAN into, and activate it:
7178

7279
.. parsed-literal::
7380
7481
sudo mkdir -p |virtualenv|
7582
sudo chown \`whoami\` |virtualenv|
76-
virtualenv --no-site-packages |virtualenv|
83+
python3 -m venv |virtualenv|
7784
|activate|
7885
79-
.. note::
80-
81-
If your system uses Python3 by default (e.g. Ubuntu 18.04) make sure to create
82-
the virtualenv using the Python2.7 executable with the ``--python`` option:
83-
84-
.. parsed-literal::
85-
86-
sudo mkdir -p |virtualenv|
87-
sudo chown \`whoami\` |virtualenv|
88-
virtualenv --python=/usr/bin/python2.7 --no-site-packages |virtualenv|
89-
|activate|
90-
9186
.. important::
9287

9388
The final command above activates your virtualenv. The virtualenv has to
@@ -105,11 +100,21 @@ a. Create a Python `virtual environment <http://www.virtualenv.org>`_
105100
106101
|activate|
107102
108-
b. Install the recommended ``setuptools`` version:
103+
.. note::
104+
105+
For Python 2 then replace the `python3 -m venv` command with:
106+
107+
.. parsed-literal::
108+
109+
virtualenv --python=/usr/bin/python2.7 --no-site-packages |virtualenv|
110+
|activate|
111+
112+
b. Install the recommended ``setuptools`` version and up-to-date pip:
109113

110114
.. parsed-literal::
111115
112116
pip install setuptools==\ |min_setuptools_version|
117+
pip install --upgrade pip
113118
114119
c. Install the CKAN source code into your virtualenv.
115120

@@ -140,6 +145,10 @@ d. Install the Python modules that CKAN requires into your virtualenv:
140145
141146
pip install -r |virtualenv|/src/ckan/requirements.txt
142147
148+
.. note::
149+
150+
For Python 2 adjust the filename to: `requirements-py2.txt`
151+
143152
e. Deactivate and reactivate your virtualenv, to make sure you're using the
144153
virtualenv's copies of commands like ``paster`` rather than any system-wide
145154
installed copies:

‎doc/maintaining/upgrading/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ appropriate one of these documents:
128128
upgrade-package-to-minor-release
129129
upgrade-source
130130
upgrade-postgres
131+
upgrade-to-python3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
==================================================
2+
Upgrading a CKAN install from Python 2 to Python 3
3+
==================================================
4+
5+
These instructions describe how to upgrade a source install of CKAN 2.9 from
6+
Python 2 to Python 3, which is necessary because Python 2 is end of life, as of
7+
January 1st, 2020.
8+
9+
Preparation
10+
-----------
11+
12+
* Backup your CKAN source, virtualenv and databases, just in case.
13+
* Upgrade to CKAN 2.9, if you've not done already.
14+
15+
Upgrade
16+
-------
17+
18+
You'll probably need to deactivate your existing virtual environment::
19+
20+
deactivate
21+
22+
The existing setup has the virtual environment here: |virtualenv|
23+
and the CKAN source code underneath in `/usr/lib/ckan/default/src`. We'll move
24+
that aside in case we need to roll-back:
25+
26+
.. parsed-literal::
27+
28+
sudo mv |virtualenv| /usr/lib/ckan/py2
29+
30+
From this doc: :doc:`/maintaining/installing/install-from-source` you need to
31+
do these sections:
32+
33+
* 1. Install the required packages
34+
* 2. Install CKAN into a Python virtual environment
35+
* 6. Link to who.ini

‎requirements-py2.in

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The file contains the direct ckan requirements.
2+
# Use pip-compile to create a requirements.txt file from this
3+
alembic==1.0.0
4+
Babel==2.3.4
5+
bleach==3.0.2
6+
click==6.7
7+
fanstatic==0.12
8+
Flask==1.1.1
9+
Flask-Babel==0.11.2
10+
Jinja2==2.10.1
11+
Markdown==2.6.7
12+
passlib==1.6.5
13+
paste==1.7.5.1
14+
PasteScript==2.0.2
15+
polib==1.0.7
16+
psycopg2==2.8.2
17+
python-magic==0.4.15
18+
pysolr==3.6.0
19+
Pylons==0.9.7
20+
python-dateutil>=1.5.0
21+
pytz==2016.7
22+
PyUtilib==5.7.1
23+
pyyaml # needed by webassets. latest should be fine.
24+
repoze.who-friendlyform==1.0.8
25+
repoze.who==2.3
26+
requests==2.22.0
27+
Routes==1.13
28+
rq==1.0
29+
simplejson==3.10.0
30+
sqlalchemy-migrate==0.12.0
31+
SQLAlchemy==1.3.5
32+
sqlparse==0.2.2
33+
tzlocal==1.3
34+
unicodecsv>=0.9
35+
webassets==0.12.1
36+
WebHelpers==1.3
37+
WebOb==1.0.8
38+
WebTest==1.4.3 # need to pin this so that Pylons does not install a newer version that conflicts with WebOb==1.0.8
39+
werkzeug==0.15.5
40+
zope.interface==4.3.2

‎requirements-py2.txt

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#
2+
# This file is autogenerated by pip-compile
3+
# To update, run:
4+
#
5+
# pip-compile --output-file requirements=py2.txt requirements-py2.in
6+
#
7+
alembic==1.0.0
8+
babel==2.3.4
9+
beaker==1.10.1 # via pylons
10+
bleach==3.0.2
11+
certifi==2019.3.9 # via requests
12+
chardet==3.0.4 # via requests
13+
click==6.7
14+
decorator==4.4.0 # via pylons, sqlalchemy-migrate
15+
fanstatic==0.12
16+
flask-babel==0.11.2
17+
Flask==1.1.1
18+
formencode==1.3.1 # via pylons
19+
funcsigs==1.0.2 # via beaker
20+
idna==2.8 # via requests
21+
itsdangerous==1.1.0 # via flask
22+
jinja2==2.10.1
23+
mako==1.0.9 # via alembic, pylons
24+
markdown==2.6.7
25+
markupsafe==1.1.1 # via jinja2, mako, webhelpers
26+
nose==1.3.7 # via pylons
27+
passlib==1.6.5
28+
paste==1.7.5.1
29+
pastedeploy==2.0.1 # via pastescript, pylons
30+
pastescript==2.0.2
31+
pbr==5.2.0 # via sqlalchemy-migrate
32+
polib==1.0.7
33+
psycopg2==2.8.2
34+
pygments==2.3.1 # via weberror
35+
pylons==0.9.7
36+
pysolr==3.6.0
37+
python-dateutil==2.8.0
38+
python-editor==1.0.4 # via alembic
39+
python-magic==0.4.15
40+
pytz==2016.7
41+
PyUtilib==5.7.1
42+
pyyaml==5.1
43+
redis==3.2.1 # via rq
44+
repoze.lru==0.7 # via routes
45+
repoze.who-friendlyform==1.0.8
46+
repoze.who==2.3
47+
requests==2.22.0
48+
routes==1.13
49+
rq==1.0
50+
simplejson==3.10.0
51+
six==1.12.0 # via bleach, pastescript, python-dateutil, pyutilib.component.core, sqlalchemy-migrate
52+
sqlalchemy-migrate==0.12.0
53+
sqlalchemy==1.3.5
54+
sqlparse==0.2.2
55+
tempita==0.5.2 # via pylons, sqlalchemy-migrate, weberror
56+
tzlocal==1.3
57+
unicodecsv==0.14.1
58+
urllib3==1.25.2 # via requests
59+
webassets==0.12.1
60+
webencodings==0.5.1 # via bleach
61+
weberror==0.13.1 # via pylons
62+
webhelpers==1.3
63+
webob==1.0.8
64+
webtest==1.4.3
65+
werkzeug==0.15.5
66+
zope.interface==4.3.2

‎requirements.in

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The file contains the direct ckan requirements.
1+
# The file contains the direct ckan requirements (python3).
22
# Use pip-compile to create a requirements.txt file from this
33
alembic==1.0.0
44
Babel==2.3.4
@@ -16,12 +16,12 @@ polib==1.0.7
1616
psycopg2==2.8.2
1717
python-magic==0.4.15
1818
pysolr==3.6.0
19-
Pylons==0.9.7
19+
# Pylons==0.9.7 - not python3 compatible
2020
python-dateutil>=1.5.0
2121
pytz==2016.7
2222
PyUtilib==5.7.1
2323
pyyaml # needed by webassets. latest should be fine.
24-
repoze.who-friendlyform==1.0.8
24+
# repoze.who-friendlyform==1.0.8 - not python3 compatible
2525
repoze.who==2.3
2626
requests==2.22.0
2727
Routes==1.13
@@ -33,8 +33,8 @@ sqlparse==0.2.2
3333
tzlocal==1.3
3434
unicodecsv>=0.9
3535
webassets==0.12.1
36-
WebHelpers==1.3
37-
WebOb==1.0.8
38-
WebTest==1.4.3 # need to pin this so that Pylons does not install a newer version that conflicts with WebOb==1.0.8
36+
# WebHelpers==1.3 - not python3 compatible
37+
# WebOb==1.0.8 - pylons dependency
38+
WebTest==1.4.3
3939
werkzeug==0.15.5
4040
zope.interface==4.3.2

‎requirements.txt

+16-24
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,53 @@
66
#
77
alembic==1.0.0
88
babel==2.3.4
9-
beaker==1.10.1 # via pylons
109
bleach==3.0.2
11-
certifi==2019.3.9 # via requests
10+
certifi==2019.9.11 # via requests
1211
chardet==3.0.4 # via requests
1312
click==6.7
14-
decorator==4.4.0 # via pylons, sqlalchemy-migrate
13+
decorator==4.4.1 # via sqlalchemy-migrate
1514
fanstatic==0.12
1615
flask-babel==0.11.2
17-
Flask==1.1.1
18-
formencode==1.3.1 # via pylons
19-
funcsigs==1.0.2 # via beaker
16+
flask==1.1.1
2017
idna==2.8 # via requests
2118
itsdangerous==1.1.0 # via flask
2219
jinja2==2.10.1
23-
mako==1.0.9 # via alembic, pylons
20+
mako==1.1.0 # via alembic
2421
markdown==2.6.7
25-
markupsafe==1.1.1 # via jinja2, mako, webhelpers
26-
nose==1.3.7 # via pylons
22+
markupsafe==1.1.1 # via jinja2, mako
23+
nose==1.3.7 # via pyutilib
2724
passlib==1.6.5
2825
paste==1.7.5.1
29-
pastedeploy==2.0.1 # via pastescript, pylons
26+
pastedeploy==2.0.1 # via pastescript
3027
pastescript==2.0.2
31-
pbr==5.2.0 # via sqlalchemy-migrate
28+
pbr==5.4.3 # via sqlalchemy-migrate
3229
polib==1.0.7
3330
psycopg2==2.8.2
34-
pygments==2.3.1 # via weberror
35-
pylons==0.9.7
3631
pysolr==3.6.0
37-
python-dateutil==2.8.0
32+
python-dateutil==2.8.1
3833
python-editor==1.0.4 # via alembic
3934
python-magic==0.4.15
4035
pytz==2016.7
41-
PyUtilib==5.7.1
42-
pyyaml==5.1
43-
redis==3.2.1 # via rq
36+
pyutilib==5.7.1
37+
pyyaml==5.1.2
38+
redis==3.3.11 # via rq
4439
repoze.lru==0.7 # via routes
45-
repoze.who-friendlyform==1.0.8
4640
repoze.who==2.3
4741
requests==2.22.0
4842
routes==1.13
4943
rq==1.0
5044
simplejson==3.10.0
51-
six==1.12.0 # via bleach, pastescript, python-dateutil, pyutilib.component.core, sqlalchemy-migrate
45+
six==1.13.0 # via bleach, pastescript, python-dateutil, pyutilib, sqlalchemy-migrate
5246
sqlalchemy-migrate==0.12.0
5347
sqlalchemy==1.3.5
5448
sqlparse==0.2.2
55-
tempita==0.5.2 # via pylons, sqlalchemy-migrate, weberror
49+
tempita==0.5.2 # via sqlalchemy-migrate
5650
tzlocal==1.3
5751
unicodecsv==0.14.1
58-
urllib3==1.25.2 # via requests
52+
urllib3==1.25.6 # via requests
5953
webassets==0.12.1
6054
webencodings==0.5.1 # via bleach
61-
weberror==0.13.1 # via pylons
62-
webhelpers==1.3
63-
webob==1.0.8
55+
webob==1.0.8 # via fanstatic, repoze.who, webtest
6456
webtest==1.4.3
6557
werkzeug==0.15.5
6658
zope.interface==4.3.2

0 commit comments

Comments
 (0)
Please sign in to comment.