Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prepare setup for py3

  • Loading branch information...
commit 249a0941f8a72bf529a06f937895dad4f0e5fc4d 1 parent 70ff0bd
@benoitc authored
View
1  MANIFEST.in
@@ -9,3 +9,4 @@ recursive-include debian *
recursive-include examples *
recursive-include tests *
recursive-include doc *
+recursive-include scripts *
View
1  TODO.txt
@@ -1 +0,0 @@
-- Improve Resource mapping
View
1  restkit/tee.py
@@ -149,7 +149,6 @@ def _tee(self, length):
""" fetch partial body"""
buf2 = self.buf
buf2.seek(0, 2)
- print length
chunk = self.stream.read(length)
if chunk:
self.tmp.write(chunk)
View
14 restkit/wrappers.py
@@ -158,20 +158,20 @@ def next(self):
self.close()
raise
- def read(self, size=None):
- data = self.body.read(size=size)
+ def read(self, n=-1):
+ data = self.body.read(n)
if not data:
self.close()
return data
- def readline(self, size=None):
- line = self.body.readline(size=size)
+ def readline(self, limit=-1):
+ line = self.body.readline(limit)
if not line:
self.close()
return line
- def readlines(self, size=None):
- lines = self.body.readlines(size=size)
+ def readlines(self, hint=None):
+ lines = self.body.readlines(hint)
if self.body.close:
self.close()
return lines
@@ -253,7 +253,7 @@ def body_stream(self):
self._already_read = True
- return self._body
+ return BodyWrapper(self, self.connection)
def tee(self):
View
10 scripts/restcli
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of restkit released under the MIT license.
+# See the NOTICE for more information.
+
+from restkit.contrib.console import main
+
+if __name__ == '__main__':
+ main()
View
138 setup.py
@@ -3,7 +3,17 @@
#
# This file is part of restkit released under the MIT license.
# See the NOTICE for more information.
+from __future__ import with_statement
+try:
+ from setuptools import setup
+ use_setuptools = True
+except ImportError:
+ from distutils.core import setup
+ use_setuptools = False
+
+import glob
+from imp import load_source
import os
import sys
@@ -18,48 +28,94 @@
+ " ssl module (http://pypi.python.org/pypi/ssl) "
+ "to be intalled.")
-from setuptools import setup, find_packages
-from restkit import __version__
+CLASSIFIERS = [
+ 'Development Status :: 4 - Beta',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: MIT License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Topic :: Software Development :: Libraries']
+
+MODULES = [
+ "restkit",
+ "restkit.contrib",
+ "restkit.manager"]
+
+SCRIPTS = ['scripts/restcli']
+
+def main():
+ import restkit
+
+ # read long description
+ with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
+ long_description = f.read()
+
+ PACKAGES = {}
+ for name in MODULES:
+ PACKAGES[name] = name.replace(".", "/")
+
+ DATA_FILES = [
+ ('restkit', ["LICENSE", "MANIFEST.in", "NOTICE", "README.rst",
+ "THANKS", "TODO.txt"])
+ ]
+
+ options=dict(
+ name = 'restkit',
+ version = restkit.__version__,
+ description = 'Python REST kit',
+ long_description = long_description,
+ author = 'Benoit Chesneau',
+ author_email = 'benoitc@e-engura.org',
+ license = 'BSD',
+ url = 'http://benoitc.github.com/restkit',
+ zip_safe = True,
+
+ classifiers = CLASSIFIERS,
+
+ packages = PACKAGES.keys(),
+ package_dir = PACKAGES,
+ data_files = DATA_FILES,
+
+ scripts = SCRIPTS,
+
+ entry_points = {
+ 'console_scripts': [
+ 'restcli = restkit.contrib.console:main',
+ ],
+ 'paste.app_factory': [
+ 'proxy = restkit.contrib.wsgi_proxy:make_proxy',
+ 'host_proxy = restkit.contrib.wsgi_proxy:make_host_proxy',
+ 'couchdb_proxy = restkit.contrib.wsgi_proxy:make_couchdb_proxy',
+ ],
+ },
-setup(
- name = 'restkit',
- version = __version__,
- description = 'Python REST kit',
- long_description = file(
- os.path.join(
- os.path.dirname(__file__),
- 'README.rst'
)
- ).read(),
- author = 'Benoit Chesneau',
- author_email = 'benoitc@e-engura.org',
- license = 'BSD',
- url = 'http://benoitc.github.com/restkit',
- zip_safe = True,
-
- classifiers = [
- 'Development Status :: 4 - Beta',
- 'Environment :: Web Environment',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: MIT License',
- 'Operating System :: OS Independent',
- 'Programming Language :: Python',
- 'Topic :: Internet :: WWW/HTTP',
- 'Topic :: Software Development :: Libraries',
- ],
- packages = find_packages(exclude=['tests']),
- entry_points = {
- 'console_scripts': [
- 'restcli = restkit.contrib.console:main',
- ],
- 'paste.app_factory': [
- 'proxy = restkit.contrib.wsgi_proxy:make_proxy',
- 'host_proxy = restkit.contrib.wsgi_proxy:make_host_proxy',
- 'couchdb_proxy = restkit.contrib.wsgi_proxy:make_couchdb_proxy',
- ],
- },
-
- test_suite = 'nose.collector',
-)
+ if use_setuptools:
+ options['entry_points'] = {
+ 'paste.app_factory': [
+ 'proxy = restkit.contrib.wsgi_proxy:make_proxy',
+ 'host_proxy = restkit.contrib.wsgi_proxy:make_host_proxy',
+ 'couchdb_proxy = restkit.contrib.wsgi_proxy:make_couchdb_proxy',
+ ]}
+
+
+ # Python 3: run 2to3
+ try:
+ from distutils.command.build_py import build_py_2to3
+ from distutils.command.build_scripts import build_scripts_2to3
+ except ImportError:
+ pass
+ else:
+ options['cmdclass'] = {
+ 'build_py': build_py_2to3,
+ 'build_scripts': build_scripts_2to3,
+ }
+
+ setup(**options)
+
+if __name__ == "__main__":
+ main()
Please sign in to comment.
Something went wrong with that request. Please try again.