Skip to content

Commit

Permalink
Merge branch 'feature/upgrade-setuptools' into develop
Browse files Browse the repository at this point in the history
 [SVCS-140]
 Closes: #301, #248
  • Loading branch information
felliott committed Mar 2, 2018
2 parents 936f762 + 27c3c8b commit 536fff8
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ before_install:

install:
- travis_retry pip install --upgrade pip
- travis_retry pip install setuptools==30.4.0
- travis_retry pip install setuptools==37.0.0
- travis_retry pip install wheel==0.26.0
- travis_retry pip install invoke==0.13.0
- travis_retry invoke wheelhouse --develop
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ RUN usermod -d /home www-data \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -U pip \
&& pip uninstall -y setuptools \
&& rm -f /usr/local/lib/python3.5/site-packages/mfr-nspkg.pth \
&& pip install setuptools==30.4.0 \
&& pip install setuptools==37.0.0 \
&& mkdir -p /code

ENV LIBREOFFICE_VERSION 6.0.1.1
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ After installing python3.5, create the virtual environment with the following co
pip install virtualenv
pip install virtualenvwrapper
mkvirtualenv --python=`which python3.5` mfr
pip install setuptools==30.4.0

pip install setuptools==37.0.0
pip install invoke==0.13.0

invoke install
invoke server
```
Expand Down Expand Up @@ -86,8 +88,7 @@ invoke test

### Known issues

- Running `invoke install -d` with setuptools v31 or greater can break MFR. The symptom error message is: `"AttributeError: module 'mfr' has no attribute '__version__'".` If you encounter this, you will need to remove the file
`mfr-nspkg.pth` from your virtualenv directory, run `pip install setuptools==30.4.0`, then re-run `invoke install -d`.
- **Updated, 2018-03-01:** *MFR has been updated to work with setuptools==37.0.0 as of MFR release v0.25. The following issue should not happen for new installs, but may occur if you downgrade to an older version.* Running `invoke install -d` with setuptools v31 or greater can break MFR. The symptom error message is: `"AttributeError: module 'mfr' has no attribute '__version__'".` If you encounter this, you will need to remove the file `mfr-nspkg.pth` from your virtualenv directory, run `pip install setuptools==30.4.0`, then re-run `invoke install -d`.

- The error `def create_default_context(purpose=ssl.Purpose.SERVER_AUTH, *, cafile=None, capath=None, cadata=None): SyntaxError: invalid syntax` is caused by inadvertently running the wrong version of Python. This can be caused by hashing the alias `inv`. To fix this run the command `hash -d inv` then run `inv server`.

Expand Down
14 changes: 8 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# -*- coding: utf-8 -*-
#
# mfr documentation build configuration file.
# MFR documentation build configuration file.
#
# This file is execfile()d with the current directory set to its containing dir.
# This file is generated by execfile() with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
# Note that not all possible configuration values are present in this auto-
# generated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os

from mfr.version import __version__

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
import mfr # noqa
sys.path.append(os.path.abspath("_themes"))

# -- General configuration -----------------------------------------------------
Expand Down Expand Up @@ -52,7 +54,7 @@
# built documents.
#
# The short X.Y version.
version = release = mfr.__version__
version = release = __version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Install the versions of ``setuptools`` and ``invoke`` found in the requirements.

.. code-block:: bash
pip install setuptools==30.4.0
pip install setuptools==37.0.0
pip install invoke==0.13.0
Install requirements:
Expand Down
4 changes: 3 additions & 1 deletion mfr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
__version__ = '0.24.2'
# This is a namespace package, don't put any functional code in here besides the
# declare_namespace call, or it will disappear on install. See:
# https://setuptools.readthedocs.io/en/latest/setuptools.html#namespace-packages
__import__('pkg_resources').declare_namespace(__name__)
8 changes: 2 additions & 6 deletions mfr/core/remote_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import logging

import aiohttp
# from geoip import geolite2

import mfr
from mfr.server import settings

# import waterbutler
from mfr.version import __version__
from waterbutler.core.utils import async_retry


Expand All @@ -22,8 +19,7 @@ async def log_analytics(request, metrics, is_error=False):

keen_payload = copy.deepcopy(metrics)
keen_payload['meta'] = {
'mfr_version': mfr.__version__,
# 'wb_version': waterbutler.__version__,
'mfr_version': __version__,
'epoch': 1,
}
keen_payload.update(request)
Expand Down
8 changes: 4 additions & 4 deletions mfr/server/app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import signal
import asyncio
import logging
from functools import partial

import tornado.web
import tornado.httpserver
import tornado.platform.asyncio
import logging

from raven.contrib.tornado import AsyncSentryClient

import mfr
from mfr import settings
from mfr.server import settings as server_settings
from mfr.server.handlers.export import ExportHandler
Expand All @@ -18,6 +16,7 @@
from mfr.server.handlers.exporters import ExportersHandler
from mfr.server.handlers.renderers import RenderersHandler
from mfr.server.handlers.core import ExtensionsStaticFileHandler
from mfr.version import __version__

logger = logging.getLogger(__name__)

Expand All @@ -33,6 +32,7 @@ def stop_loop():

io_loop.add_callback_from_signal(stop_loop)


def make_app(debug):
app = tornado.web.Application(
[
Expand All @@ -46,7 +46,7 @@ def make_app(debug):
],
debug=debug,
)
app.sentry_client = AsyncSentryClient(settings.SENTRY_DSN, release=mfr.__version__)
app.sentry_client = AsyncSentryClient(settings.SENTRY_DSN, release=__version__)
return app


Expand Down
5 changes: 3 additions & 2 deletions mfr/server/handlers/status.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import tornado.web

import mfr
from mfr.version import __version__


class StatusHandler(tornado.web.RequestHandler):

def get(self):
"""List information about modular-file-renderer status"""
self.write({
'status': 'up',
'version': mfr.__version__
'version': __version__
})
1 change: 1 addition & 0 deletions mfr/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.24.2'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ humanfriendly==2.1
invoke==0.13.0
mako==1.0.1
raven==5.27.0
setuptools==30.4.0
setuptools==37.0.0
stevedore==1.2.0
tornado==4.3

Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from setuptools import setup, find_packages

from mfr import __version__


def parse_requirements(requirements):
with open(requirements) as f:
Expand All @@ -10,9 +8,14 @@ def parse_requirements(requirements):

requirements = parse_requirements('requirements.txt')

# Taken from option 3 of https://packaging.python.org/guides/single-sourcing-package-version/
version = {}
with open('mfr/version.py') as fp:
exec(fp.read(), version)

setup(
name='mfr',
version=__version__,
version=version['__version__'],
namespace_packages=['mfr', 'mfr.extensions', 'mfr.providers'],
description='Modular File Renderer',
author='Center for Open Science',
Expand Down
12 changes: 8 additions & 4 deletions tests/server/handlers/test_status.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import mfr
import json
from tests import utils
from http import HTTPStatus

from tornado import testing

from mfr.version import __version__

from tests import utils


class TestStatusHandler(utils.HandlerTestCase):
@testing.gen_test
def test_get_status(self):
resp = yield self.http_client.fetch(self.get_url('/status'))

data = json.loads(resp.body.decode('utf-8'))
assert resp.code == 200
assert resp.code == HTTPStatus.OK
assert data['status'] == 'up'
assert data['version'] == mfr.__version__
assert data['version'] == __version__

0 comments on commit 536fff8

Please sign in to comment.