Skip to content

Commit

Permalink
Merge branch 'dev-v2.7' of github.com:ckan/ckan into dev-v2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Oct 25, 2017
2 parents 75ab01a + 232ae16 commit 31bce8b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 38 deletions.
2 changes: 1 addition & 1 deletion doc/.gitignore
@@ -1 +1 @@
_latest_release.rst
_substitutions.rst
50 changes: 30 additions & 20 deletions doc/conf.py
Expand Up @@ -168,13 +168,24 @@ def latest_package_name(distro='trusty'):
version=latest_minor_version, distro=distro)


def write_latest_release_file():
'''Write a file in the doc/ dir containing reStructuredText substitutions
for the latest release tag name and version number.
def min_setuptools_version():
'''
Get the minimum setuptools version as defined in requirement-setuptools.txt.
'''
filename = os.path.join(os.path.dirname(__file__), '..',
'requirement-setuptools.txt')
with open(filename) as f:
return f.read().split('==')[1].strip()


def write_substitutions_file(**kwargs):
'''
Write a file in the doc/ dir containing reStructuredText substitutions.
Any keyword argument is stored as a substitution.
'''
filename = '_latest_release.rst'
template = ''':orphan:
filename = '_substitutions.rst'
header = ''':orphan:
.. Some common reStructuredText substitutions.
Expand All @@ -189,22 +200,21 @@ def write_latest_release_file():
|latest_release_version|
.. |latest_release_tag| replace:: {latest_tag}
.. |latest_release_version| replace:: {latest_version}
.. |latest_package_name_precise| replace:: {package_name_precise}
.. |latest_package_name_trusty| replace:: {package_name_trusty}
'''
open(filename, 'w').write(template.format(
filename=filename,
latest_tag=latest_release_tag(),
latest_version=latest_release_version(),
package_name_precise=latest_package_name('precise'),
package_name_trusty=latest_package_name('trusty'),
))


write_latest_release_file()
with open(filename, 'w') as f:
f.write(header.format(filename=filename))
for name, substitution in kwargs.items():
f.write('.. |{name}| replace:: {substitution}\n'.format(
name=name, substitution=substitution))


write_substitutions_file(
latest_release_tag=latest_release_tag(),
latest_release_version=latest_release_version(),
latest_package_name_precise=latest_package_name('precise'),
latest_package_name_trusty=latest_package_name('trusty'),
min_setuptools_version=min_setuptools_version(),
)


# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
2 changes: 1 addition & 1 deletion doc/maintaining/installing/install-from-package.rst
@@ -1,4 +1,4 @@
.. include:: /_latest_release.rst
.. include:: /_substitutions.rst

============================
Installing CKAN from package
Expand Down
6 changes: 3 additions & 3 deletions doc/maintaining/installing/install-from-source.rst
@@ -1,4 +1,4 @@
.. include:: /_latest_release.rst
.. include:: /_substitutions.rst

===========================
Installing CKAN from source
Expand Down Expand Up @@ -98,11 +98,11 @@ a. Create a Python `virtual environment <http://www.virtualenv.org>`_
|activate|
b. Install the recommended version of 'setuptools':
b. Install the recommended ``setuptools`` version:

.. parsed-literal::
pip install -r |virtualenv|/src/ckan/requirement-setuptools.txt
pip install setuptools==\ |min_setuptools_version|
c. Install the CKAN source code into your virtualenv.
To install the latest stable release of CKAN (CKAN |latest_release_version|),
Expand Down
36 changes: 23 additions & 13 deletions setup.py
@@ -1,7 +1,9 @@
# encoding: utf-8

# Avoid problem releasing to pypi from vagrant
import os
import os.path

# Avoid problem releasing to pypi from vagrant
if os.environ.get('USER', '') == 'vagrant':
del os.link

Expand All @@ -17,18 +19,26 @@
from ckan import (__version__, __description__, __long_description__,
__license__)

MIN_SETUPTOOLS_VERSION = 20.4
assert setuptools_version >= str(MIN_SETUPTOOLS_VERSION) and \
int(setuptools_version.split('.')[0]) >= int(MIN_SETUPTOOLS_VERSION),\
('setuptools version error'
'\nYou need a newer version of setuptools.\n'
'You have {current}, you need at least {minimum}'
'\nInstall the recommended version:\n'
' pip install -r requirement-setuptools.txt\n'
'and then try again to install ckan into your python environment.'.format(
current=setuptools_version,
minimum=MIN_SETUPTOOLS_VERSION
))

#
# Check setuptools version
#

def parse_version(s):
return map(int, s.split('.'))

HERE = os.path.dirname(__file__)
with open(os.path.join(HERE, 'requirement-setuptools.txt')) as f:
setuptools_requirement = f.read().strip()
min_setuptools_version = parse_version(setuptools_requirement.split('==')[1])
if parse_version(setuptools_version) < min_setuptools_version:
raise AssertionError(
'setuptools version error\n'
'You need a newer version of setuptools.\n'
'Install the recommended version:\n'
' pip install -r requirement-setuptools.txt\n'
'and then try again to install ckan into your python environment.'
)


entry_points = {
Expand Down

0 comments on commit 31bce8b

Please sign in to comment.