Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 5ddf4d4

Browse files
committed
Refactored setup.py and tests to be more compact and work together. Fixes #100.
1 parent 5ebdae1 commit 5ddf4d4

7 files changed

Lines changed: 25 additions & 96 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.tox/
2-
scratch.py
2+
tests/scratch.py
33
_sources/*
44
sphinx/*
55
doctrees/*

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
language: python
22
python:
3-
- '2.6'
43
- '2.7'
5-
- '3.2'
64
- '3.3'
75
- '3.4'
86
install:
97
- pip install -r requirements.txt
108
script:
119
- pep8 documentcloud
1210
- pyflakes documentcloud
13-
- coverage run test.py
11+
- coverage run setup test
1412
after_success:
1513
- coveralls
1614
env:

setup.py

Lines changed: 23 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,27 @@
1-
"""
2-
Tricks lifted from Django's own setup.py and django_debug_toolbar.
1+
from setuptools import setup
32

4-
Still not sure why the templates install with this particular config
5-
and not with some of the others I tried.
6-
"""
7-
8-
from distutils.core import setup
9-
from setuptools import setup, find_packages
10-
from distutils.command.install_data import install_data
11-
from distutils.command.install import INSTALL_SCHEMES
12-
import os
13-
import sys
14-
15-
class osx_install_data(install_data):
16-
# On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
17-
# which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
18-
# for this in distutils.command.install_data#306. It fixes install_lib but not
19-
# install_data, which is why we roll our own install_data class.
20-
21-
def finalize_options(self):
22-
# By the time finalize_options is called, install.install_lib is set to the
23-
# fixed directory, so we set the installdir to install_lib. The
24-
# install_data class uses ('install_data', 'install_dir') instead.
25-
self.set_undefined_options('install', ('install_lib', 'install_dir'))
26-
install_data.finalize_options(self)
27-
28-
if sys.platform == "darwin":
29-
cmdclasses = {'install_data': osx_install_data}
30-
else:
31-
cmdclasses = {'install_data': install_data}
32-
33-
def fullsplit(path, result=None):
34-
"""
35-
Split a pathname into components (the opposite of os.path.join) in a
36-
platform-neutral way.
37-
"""
38-
if result is None:
39-
result = []
40-
head, tail = os.path.split(path)
41-
if head == '':
42-
return [tail] + result
43-
if head == path:
44-
return result
45-
return fullsplit(head, [tail] + result)
46-
47-
# Tell distutils to put the data_files in platform-specific installation
48-
# locations. See here for an explanation:
49-
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
50-
for scheme in INSTALL_SCHEMES.values():
51-
scheme['data'] = scheme['purelib']
52-
53-
# Compile the list of packages available, because distutils doesn't have
54-
# an easy way to do this.
55-
packages, data_files = [], []
56-
root_dir = os.path.dirname(__file__)
57-
if root_dir != '':
58-
os.chdir(root_dir)
59-
60-
django_dir = 'documentcloud'
61-
62-
for dirpath, dirnames, filenames in os.walk(django_dir):
63-
# Ignore dirnames that start with '.'
64-
for i, dirname in enumerate(dirnames):
65-
if dirname.startswith('.'): del dirnames[i]
66-
if '__init__.py' in filenames:
67-
packages.append('.'.join(fullsplit(dirpath)))
68-
elif filenames:
69-
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
70-
71-
# Small hack for working with bdist_wininst.
72-
# See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
73-
if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst':
74-
for file_info in data_files:
75-
file_info[0] = '\\PURELIB\\%s' % file_info[0]
76-
77-
dependencies = [
78-
'python-dateutil>=2.1',
79-
'simplejson>=3.3.1',
80-
'six>=1.4.1',
81-
'rfc3987',
82-
]
833

844
setup(
85-
name='python-documentcloud',
86-
version='1.0.1',
87-
description='A simple Python wrapper for the DocumentCloud API',
88-
author='Ben Welsh',
89-
author_email='ben.welsh@gmail.com',
90-
url='http://datadesk.github.com/python-documentcloud/',
91-
packages=packages,
92-
cmdclass = cmdclasses,
93-
data_files=data_files,
94-
include_package_data=True,
95-
install_requires=dependencies,
5+
name='python-documentcloud',
6+
version='1.0.1',
7+
description='A simple Python wrapper for the DocumentCloud API',
8+
author='Ben Welsh',
9+
author_email='ben.welsh@gmail.com',
10+
url='http://datadesk.github.com/python-documentcloud/',
11+
license="MIT",
12+
packages=("documentcloud",),
13+
test_suite = "tests.test_all",
14+
include_package_data=True,
15+
install_requires=(
16+
'python-dateutil>=2.1',
17+
'simplejson>=3.3.1',
18+
'six>=1.4.1',
19+
'rfc3987',
20+
),
21+
classifiers=(
22+
'Programming Language :: Python',
23+
'Programming Language :: Python :: 2.7',
24+
'Programming Language :: Python :: 3.3',
25+
'Programming Language :: Python :: 3.4',
26+
),
9627
)

tests/__init__.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)