Skip to content

Commit 5c5c87c

Browse files
committed
Fixed some installation problems spotted by Mika Saaranen.
http://morozov.ca/django-pdf-msword-excel-templates.html#disqus_thread
1 parent ab77893 commit 5c5c87c

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ env:
55
LO_VERSION=5.1.1.3
66
LO_PATH=/opt/libreoffice5.1/program
77
matrix:
8-
- TOXENV=py27
9-
- TOXENV=py34
8+
- TOXENV=py27-django18
9+
- TOXENV=py27-django19
10+
- TOXENV=py34-django18
11+
- TOXENV=py34-django19
1012
- TOXENV=flake8
1113
install: pip install -U tox
1214
before_install:

example/manage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/usr/bin/env python
22

33
import os
4+
import os.path
45
import sys
56

67
if __name__ == "__main__":
7-
sys.path.append('..')
8+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9+
sys.path.append(BASE_DIR)
810
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
911
from django.core.management import execute_from_command_line
1012
execute_from_command_line(sys.argv)

setup.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44

5-
from setuptools import setup
5+
from setuptools import setup, find_packages
66

77

88
with open('README.rst') as readme_file:
@@ -23,17 +23,13 @@
2323
setup(
2424
name='templated_docs',
2525
version='0.2.7',
26-
description=('Templated-docs generates templated documents '
27-
'in any format supported by LibreOffice'),
26+
description=('Generate PDF, MS Word and Excel documents from templates '
27+
'in Django.'),
2828
long_description=readme + '\n\n' + history,
2929
author="Alex Morozov",
3030
author_email='alex@morozov.ca',
3131
url='https://github.com/alexmorozov/templated-docs',
32-
packages=[
33-
'templated_docs',
34-
],
35-
package_dir={'templated_docs':
36-
'templated_docs'},
32+
packages=find_packages(),
3733
include_package_data=True,
3834
install_requires=requirements,
3935
license="MIT license",
@@ -44,6 +40,8 @@
4440
'Intended Audience :: Developers',
4541
'License :: OSI Approved :: MIT License',
4642
'Natural Language :: English',
43+
'Programming Language :: Python :: 2',
44+
'Programming Language :: Python :: 2.7',
4745
'Programming Language :: Python :: 3',
4846
'Programming Language :: Python :: 3.3',
4947
'Programming Language :: Python :: 3.4',

templated_docs/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77

88
from django.conf import settings
99
from django.template import Template
10-
from django.template.exceptions import TemplateDoesNotExist
10+
11+
try:
12+
# Django 1.9+
13+
from django.template.exceptions import TemplateDoesNotExist
14+
except ImportError:
15+
from django.template import TemplateDoesNotExist
16+
1117
from django.template import Context, engines
1218

1319
from django.utils.encoding import smart_bytes, smart_str
@@ -63,8 +69,9 @@ def find_template_file(template_name):
6369
"""
6470
for loader in _get_template_loaders():
6571
for origin in loader.get_template_sources(template_name, None):
66-
if os.path.exists(origin.name):
67-
return origin.name
72+
path = getattr(origin, 'name', origin) # Django <1.9 compatibility
73+
if os.path.exists(path):
74+
return path
6875
raise TemplateDoesNotExist(template_name)
6976

7077

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[tox]
2-
envlist = py27, py34, flake8
2+
envlist = py{27,34}-django{18,19}, flake8
33

44
[testenv:flake8]
55
deps=flake8
66
commands=flake8 templated_docs
77

88
[testenv]
99
passenv = LO_PATH
10+
deps =
11+
django18: Django>=1.8,<1.9
12+
django19: Django>=1.9,<1.10
1013
commands = python tests/manage.py test
14+
python example/manage.py check

0 commit comments

Comments
 (0)