diff options
author | Ask Solem <ask@celeryproject.org> | 2013-01-17 14:09:43 +0000 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2013-01-17 14:09:43 +0000 |
commit | d6d6562670a863caf70f3ee747ba7aa323e46fa6 (patch) | |
tree | 764d1163c564b2c9bc31f07ad24ce6143abb54dc | |
parent | 310a318db5317428a84040f966812a67ee4ef08a (diff) | |
download | librabbitmq-d6d6562670a863caf70f3ee747ba7aa323e46fa6.tar.gz |
Cosmetics
-rw-r--r-- | benchmark.py | 53 | ||||
-rw-r--r-- | librabbitmq/__init__.py | 91 | ||||
-rw-r--r-- | librabbitmq/tests/test_functional.py | 93 | ||||
-rw-r--r-- | pavement.py | 98 | ||||
-rw-r--r-- | setup.py | 37 |
5 files changed, 198 insertions, 174 deletions
diff --git a/benchmark.py b/benchmark.py index 7f17813..15d956e 100644 --- a/benchmark.py +++ b/benchmark.py @@ -1,75 +1,74 @@ import timeit -QS = ("amqplib.benchmark", "librabbit.benchmark") +QS = ('amqplib.benchmark', 'librabbit.benchmark') INIT_COMMON = """ -connection = amqp.Connection(hostname="localhost", userid="guest", -password="guest", virtual_host="/") +connection = amqp.Connection(hostname='localhost', userid='guest', +password='guest', virtual_host='/') channel = connection.channel() -channel.exchange_declare(Q, "direct") +channel.exchange_declare(Q, 'direct') channel.queue_declare(Q) channel.queue_bind(Q, Q, Q) """ INIT_AMQPLIB = """ from amqplib import client_0_8 as amqp -Q = "amqplib.benchmark" +Q = 'amqplib.benchmark' %s """ % INIT_COMMON INIT_LIBRABBIT = """ import librabbitmq as amqp -Q = "librabbit.benchmark" +Q = 'librabbit.benchmark' %s """ % INIT_COMMON PUBLISH = """ -message = amqp.Message("x" * %d) +message = amqp.Message('x' * %d) channel.basic_publish(message, exchange=Q, routing_key=Q) """ PUBLISH_LIBRABBIT = """ -connection._basic_publish(1, "x" * %d, Q, Q, {}) +connection._basic_publish(1, 'x' * %d, Q, Q, {}) """ CONSUME = """ -method = getattr(channel, "wait", None) or connection.drain_events +method = getattr(channel, 'wait', None) or connection.drain_events def callback(m): - channel.basic_ack(m.delivery_info["delivery_tag"]) + channel.basic_ack(m.delivery_info['delivery_tag']) channel.basic_consume(Q, callback=callback) for i in range(%(its)d): method() """ -def bench_basic_publish(iterations=10000, bytes=256): +def bench_basic_publish(its=10000, bytes=256): t_publish_amqplib = timeit.Timer(stmt=PUBLISH % bytes, - setup=INIT_AMQPLIB) + setup=INIT_AMQPLIB) t_publish_librabbit = timeit.Timer(stmt=PUBLISH_LIBRABBIT % bytes, setup=INIT_LIBRABBIT) - print("basic.publish: (%s byte messages)" % bytes) - print(" amqplib: %.2f usec/pass" % ( - iterations * t_publish_amqplib.timeit(number=iterations)/iterations)) - print(" librabbit: %.2f usec/pass" % ( - iterations * t_publish_librabbit.timeit(number=iterations)/iterations)) + print('basic.publish: (%s byte messages)' % bytes) + print(' amqplib: %.2f usec/pass' % ( + its * t_publish_amqplib.timeit(number=its) / its)) + print(' librabbit: %.2f usec/pass' % ( + its * t_publish_librabbit.timeit(number=its) / its)) + -def bench_basic_consume(iterations=10000): - context = {"its": (iterations/2)/10} +def bench_basic_consume(its=10000): + context = {'its': (its / 2) / 10} t_consume_amqplib = timeit.Timer(stmt=CONSUME % context, setup=INIT_AMQPLIB) t_consume_librabbit = timeit.Timer(stmt=CONSUME % context, setup=INIT_LIBRABBIT) - print("basic.consume (%s msg/pass) " % context["its"]) - print(" amqplib: %.2f usec/pass" % ( - 10 * t_consume_amqplib.timeit(number=10)/10)) - print(" librabbit: %.2f usec/pass" % ( - 10 * t_consume_librabbit.timeit(number=10)/10)) + print('basic.consume (%s msg/pass) ' % context['its']) + print(' amqplib: %.2f usec/pass' % ( + 10 * t_consume_amqplib.timeit(number=10) / 10)) + print(' librabbit: %.2f usec/pass' % ( + 10 * t_consume_librabbit.timeit(number=10) / 10)) benchmarks = [bench_basic_publish, bench_basic_consume] -if __name__ == "__main__": +if __name__ == '__main__': for benchmark in benchmarks: benchmark(100000) - - diff --git a/librabbitmq/__init__.py b/librabbitmq/__init__.py index e0716a7..2be98b3 100644 --- a/librabbitmq/__init__.py +++ b/librabbitmq/__init__.py @@ -1,5 +1,4 @@ import itertools -import socket import _librabbitmq @@ -51,8 +50,9 @@ class Channel(object): self.close() def basic_qos(self, prefetch_size=0, prefetch_count=0, _global=False): - return self.connection._basic_qos(self.channel_id, - prefetch_size, prefetch_count, _global) + return self.connection._basic_qos( + self.channel_id, prefetch_size, prefetch_count, _global, + ) def flow(self, active): return self.connection._flow(self.channel_id, active) @@ -69,25 +69,28 @@ class Channel(object): frame['body'])) def basic_consume(self, queue='', consumer_tag=None, no_local=False, - no_ack=False, exclusive=False, callback=None, arguments=None, - nowait=False): + no_ack=False, exclusive=False, callback=None, + arguments=None, nowait=False): if consumer_tag is None: consumer_tag = self.next_consumer_tag() - consumer_tag = self.connection._basic_consume(self.channel_id, - queue, str(consumer_tag), no_local, no_ack, exclusive, - arguments or {}) + consumer_tag = self.connection._basic_consume( + self.channel_id, queue, str(consumer_tag), no_local, + no_ack, exclusive, arguments or {}, + ) self.connection.callbacks[self.channel_id][consumer_tag] = callback if no_ack: self.no_ack_consumers.add(consumer_tag) return consumer_tag def basic_ack(self, delivery_tag, multiple=False): - return self.connection._basic_ack(self.channel_id, - delivery_tag, multiple) + return self.connection._basic_ack( + self.channel_id, delivery_tag, multiple, + ) def basic_reject(self, delivery_tag, requeue=True): - return self.connection._basic_reject(self.channel_id, - delivery_tag, requeue) + return self.connection._basic_reject( + self.channel_id, delivery_tag, requeue, + ) def basic_cancel(self, consumer_tag, **kwargs): self.no_ack_consumers.discard(consumer_tag) @@ -95,55 +98,63 @@ class Channel(object): self.connection._basic_cancel(self.channel_id, consumer_tag) def basic_publish(self, body, exchange='', routing_key='', - mandatory=False, immediate=False, **properties): + mandatory=False, immediate=False, **properties): if isinstance(body, tuple): body, properties = body elif isinstance(body, self.Message): body, properties = body.body, body.properties - return self.connection._basic_publish(self.channel_id, - body, exchange, routing_key, properties, - mandatory or False, immediate or False) + return self.connection._basic_publish( + self.channel_id, body, exchange, routing_key, + properties, mandatory or False, immediate or False, + ) def queue_purge(self, queue, nowait=False): return self.connection._queue_purge(self.channel_id, queue, nowait) - def exchange_declare(self, exchange='', type='direct', - passive=False, durable=False, auto_delete=False, arguments=None, - nowait=False): + def exchange_declare(self, exchange='', type='direct', passive=False, + durable=False, auto_delete=False, arguments=None, + nowait=False): """Declare exchange. :keyword auto_delete: Not recommended and so it is ignored. """ - return self.connection._exchange_declare(self.channel_id, - exchange, type, passive, durable, auto_delete, arguments or {}) + return self.connection._exchange_declare( + self.channel_id, exchange, type, passive, + durable, auto_delete, arguments or {}, + ) def exchange_delete(self, exchange='', if_unused=False): - return self.connection._exchange_delete(self.channel_id, - exchange, if_unused) + return self.connection._exchange_delete( + self.channel_id, exchange, if_unused, + ) def queue_declare(self, queue='', passive=False, durable=False, - exclusive=False, auto_delete=False, arguments=None, - nowait=False): - return self.connection._queue_declare(self.channel_id, - queue, passive, durable, exclusive, auto_delete, - arguments or {}) + exclusive=False, auto_delete=False, arguments=None, + nowait=False): + return self.connection._queue_declare( + self.channel_id, queue, passive, durable, + exclusive, auto_delete, arguments or {}, + ) def queue_bind(self, queue='', exchange='', routing_key='', - arguments=None, nowait=False): - return self.connection._queue_bind(self.channel_id, - queue, exchange, routing_key, arguments or {}) + arguments=None, nowait=False): + return self.connection._queue_bind( + self.channel_id, queue, exchange, routing_key, arguments or {}, + ) def queue_unbind(self, queue='', exchange='', routing_key='', - arguments=None, nowait=False): - return self.connection._queue_unbind(self.channel_id, - queue, exchange, routing_key, arguments or {}) + arguments=None, nowait=False): + return self.connection._queue_unbind( + self.channel_id, queue, exchange, routing_key, arguments or {}, + ) - def queue_delete(self, queue='', if_unused=False, if_empty=False, - nowait=False): + def queue_delete(self, queue='', + if_unused=False, if_empty=False, nowait=False): """nowait argument is not supported.""" - return self.connection._queue_delete(self.channel_id, - queue, if_unused, if_empty) + return self.connection._queue_delete( + self.channel_id, queue, if_unused, if_empty, + ) def close(self): self.connection._remove_channel(self) @@ -161,8 +172,8 @@ class Connection(_librabbitmq.Connection): Channel = Channel def __init__(self, host='localhost', userid='guest', password='guest', - virtual_host='/', port=5672, channel_max=0xffff, - frame_max=131072, heartbeat=0, lazy=False, **kwargs): + virtual_host='/', port=5672, channel_max=0xffff, + frame_max=131072, heartbeat=0, lazy=False, **kwargs): if ':' in host: host, port = host.split(':') super(Connection, self).__init__(hostname=host, port=int(port), diff --git a/librabbitmq/tests/test_functional.py b/librabbitmq/tests/test_functional.py index 7fbd459..68d979b 100644 --- a/librabbitmq/tests/test_functional.py +++ b/librabbitmq/tests/test_functional.py @@ -2,21 +2,25 @@ import socket import unittest2 as unittest from librabbitmq import Message, Connection, ConnectionError, ChannelError -TEST_QUEUE = "pyrabbit.testq" +TEST_QUEUE = 'pyrabbit.testq' class test_Channel(unittest.TestCase): def setUp(self): - self.connection = Connection(host="localhost:5672", userid="guest", - password="guest", virtual_host="/") + self.connection = Connection(host='localhost:5672', userid='guest', + password='guest', virtual_host='/') self.channel = self.connection.channel() self._queue_declare() def test_send_message(self): - message = Message("the quick brown fox jumps over the lazy dog", - properties=dict(content_type="application/json", - content_encoding="utf-8")) + message = Message( + 'the quick brown fox jumps over the lazy dog', + properties={ + 'content_type': 'application/json', + 'content_encoding': 'utf-8', + }, + ) self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) @@ -26,17 +30,21 @@ class test_Channel(unittest.TestCase): self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) def _queue_declare(self): - self.channel.exchange_declare(TEST_QUEUE, "direct") + self.channel.exchange_declare(TEST_QUEUE, 'direct') x = self.channel.queue_declare(TEST_QUEUE) - self.assertIn("message_count", x) - self.assertIn("consumer_count", x) - self.assertEqual(x["queue"], TEST_QUEUE) + self.assertIn('message_count', x) + self.assertIn('consumer_count', x) + self.assertEqual(x['queue'], TEST_QUEUE) self.channel.queue_bind(TEST_QUEUE, TEST_QUEUE, TEST_QUEUE) def test_basic_get_ack(self): - message = Message("the quick brown fox jumps over the lazy dog", - properties=dict(content_type="application/json", - content_encoding="utf-8")) + message = Message( + 'the quick brown fox jumps over the lazy dog', + properties={ + 'content_type': 'application/json', + 'content_encoding': 'utf-8', + }, + ) self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) @@ -45,12 +53,12 @@ class test_Channel(unittest.TestCase): if x: break self.assertIs(self.channel, x.channel) - self.assertIn("message_count", x.delivery_info) - self.assertIn("redelivered", x.delivery_info) - self.assertEqual(x.delivery_info["routing_key"], TEST_QUEUE) - self.assertEqual(x.delivery_info["exchange"], TEST_QUEUE) - self.assertTrue(x.delivery_info["delivery_tag"]) - self.assertTrue(x.properties["content_type"]) + self.assertIn('message_count', x.delivery_info) + self.assertIn('redelivered', x.delivery_info) + self.assertEqual(x.delivery_info['routing_key'], TEST_QUEUE) + self.assertEqual(x.delivery_info['exchange'], TEST_QUEUE) + self.assertTrue(x.delivery_info['delivery_tag']) + self.assertTrue(x.properties['content_type']) self.assertTrue(x.body) x.ack() @@ -59,9 +67,9 @@ class test_Channel(unittest.TestCase): that we can fetch them with a timeout without needing to receive any more messages.""" - message = Message("the quick brown fox jumps over the lazy dog", - properties=dict(content_type="application/json", - content_encoding="utf-8")) + message = Message('the quick brown fox jumps over the lazy dog', + properties=dict(content_type='application/json', + content_encoding='utf-8')) for i in xrange(100): self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) @@ -81,9 +89,9 @@ class test_Channel(unittest.TestCase): def test_timeout(self): """Check that our ``drain_events`` call actually times out if there are no messages.""" - message = Message("the quick brown fox jumps over the lazy dog", - properties=dict(content_type="application/json", - content_encoding="utf-8")) + message = Message('the quick brown fox jumps over the lazy dog', + properties=dict(content_type='application/json', + content_encoding='utf-8')) self.channel.basic_publish(message, TEST_QUEUE, TEST_QUEUE) @@ -96,8 +104,9 @@ class test_Channel(unittest.TestCase): self.channel.basic_consume(TEST_QUEUE, callback=cb) self.connection.drain_events(timeout=0.1) - self.assertRaises(socket.timeout, - self.connection.drain_events, timeout=0.1) + self.assertRaises( + socket.timeout, self.connection.drain_events, timeout=0.1, + ) self.assertEquals(len(messages), 1) def tearDown(self): @@ -110,44 +119,46 @@ class test_Channel(unittest.TestCase): except ConnectionError: pass + class test_Delete(unittest.TestCase): def setUp(self): - self.connection = Connection(host="localhost:5672", userid="guest", - password="guest", virtual_host="/") + self.connection = Connection(host='localhost:5672', userid='guest', + password='guest', virtual_host='/') self.channel = self.connection.channel() - self.TEST_QUEUE = "pyrabbitmq.testq2" + self.TEST_QUEUE = 'pyrabbitmq.testq2' def test_delete(self): """Test that we can declare a channel delete it, and then declare with different properties""" - res = self.channel.exchange_declare(self.TEST_QUEUE, "direct") - res =self.channel.queue_declare(self.TEST_QUEUE) - res = self.channel.queue_bind(self.TEST_QUEUE, self.TEST_QUEUE, - self.TEST_QUEUE) + self.channel.exchange_declare(self.TEST_QUEUE, 'direct') + self.channel.queue_declare(self.TEST_QUEUE) + self.channel.queue_bind( + self.TEST_QUEUE, self.TEST_QUEUE, self.TEST_QUEUE, + ) # Delete the queue self.channel.queue_delete(self.TEST_QUEUE) # Declare it again x = self.channel.queue_declare(self.TEST_QUEUE, durable=True) - self.assertIn("message_count", x) - self.assertIn("consumer_count", x) - self.assertEqual(x["queue"], self.TEST_QUEUE) + self.assertIn('message_count', x) + self.assertIn('consumer_count', x) + self.assertEqual(x['queue'], self.TEST_QUEUE) self.channel.queue_delete(self.TEST_QUEUE) def test_delete_empty(self): """Test that the queue doesn't get deleted if it is not empty""" - self.channel.exchange_declare(self.TEST_QUEUE, "direct") + self.channel.exchange_declare(self.TEST_QUEUE, 'direct') self.channel.queue_declare(self.TEST_QUEUE) self.channel.queue_bind(self.TEST_QUEUE, self.TEST_QUEUE, self.TEST_QUEUE) - message = Message("the quick brown fox jumps over the lazy dog", - properties=dict(content_type="application/json", - content_encoding="utf-8")) + message = Message('the quick brown fox jumps over the lazy dog', + properties=dict(content_type='application/json', + content_encoding='utf-8')) self.channel.basic_publish(message, self.TEST_QUEUE, self.TEST_QUEUE) diff --git a/pavement.py b/pavement.py index 16cc9fb..ec13526 100644 --- a/pavement.py +++ b/pavement.py @@ -3,12 +3,12 @@ from paver import doctools # noqa from paver.setuputils import setup # noqa options( - sphinx=Bunch(builddir=".build"), + sphinx=Bunch(builddir='.build'), ) def sphinx_builddir(options): - return path("docs") / options.sphinx.builddir / "html" + return path('docs') / options.sphinx.builddir / 'html' @task @@ -17,68 +17,68 @@ def clean_docs(options): @task -@needs("clean_docs", "paver.doctools.html") +@needs('clean_docs', 'paver.doctools.html') def html(options): - destdir = path("Documentation") + destdir = path('Documentation') destdir.rmtree() builtdocs = sphinx_builddir(options) builtdocs.move(destdir) @task -@needs("paver.doctools.html") +@needs('paver.doctools.html') def qhtml(options): - destdir = path("Documentation") + destdir = path('Documentation') builtdocs = sphinx_builddir(options) - sh("rsync -az %s/ %s" % (builtdocs, destdir)) + sh('rsync -az %s/ %s' % (builtdocs, destdir)) @task -@needs("clean_docs", "paver.doctools.html") +@needs('clean_docs', 'paver.doctools.html') def ghdocs(options): builtdocs = sphinx_builddir(options) - sh("git checkout gh-pages && \ + sh('git checkout gh-pages && \ cp -r %s/* . && \ - git commit . -m 'Rendered documentation for Github Pages.' && \ + git commit . -m "Rendered documentation for Github Pages." && \ git push origin gh-pages && \ - git checkout master" % builtdocs) + git checkout master' % builtdocs) @task -@needs("clean_docs", "paver.doctools.html") +@needs('clean_docs', 'paver.doctools.html') def upload_pypi_docs(options): - builtdocs = path("docs") / options.builddir / "html" - sh("python setup.py upload_sphinx --upload-dir='%s'" % (builtdocs)) + builtdocs = path('docs') / options.builddir / 'html' + sh('python setup.py upload_sphinx --upload-dir="%s"' % (builtdocs)) @task -@needs("upload_pypi_docs", "ghdocs") +@needs('upload_pypi_docs', 'ghdocs') def upload_docs(options): pass @task def autodoc(options): - sh("contrib/release/doc4allmods librabbitmq") + sh('contrib/release/doc4allmods librabbitmq') @task def verifyindex(options): - sh("contrib/release/verify-reference-index.sh") + sh('contrib/release/verify-reference-index.sh') @task def clean_readme(options): - path("README").unlink() - path("README.rst").unlink() + path('README').unlink() + path('README.rst').unlink() @task -@needs("clean_readme") +@needs('clean_readme') def readme(options): - sh("python contrib/release/sphinx-to-rst.py docs/templates/readme.txt \ - > README.rst") - sh("ln -sf README.rst README") + sh('python contrib/release/sphinx-to-rst.py docs/templates/readme.txt \ + > README.rst') + sh('ln -sf README.rst README') @task @@ -89,18 +89,18 @@ def bump(options): @task @cmdopts([ - ("coverage", "c", "Enable coverage"), - ("quick", "q", "Quick test"), - ("verbose", "V", "Make more noise"), + ('coverage', 'c', 'Enable coverage'), + ('quick', 'q', 'Quick test'), + ('verbose', 'V', 'Make more noise'), ]) def test(options): - cmd = "nosetests" - if getattr(options, "coverage", False): - cmd += " --with-coverage3" - if getattr(options, "quick", False): - cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd - if getattr(options, "verbose", False): - cmd += " --verbosity=2" + cmd = 'nosetests' + if getattr(options, 'coverage', False): + cmd += ' --with-coverage3' + if getattr(options, 'quick', False): + cmd = 'QUICKTEST=1 SKIP_RLIMITS=1 %s' % cmd + if getattr(options, 'verbose', False): + cmd += ' --verbosity=2' sh(cmd) @@ -111,26 +111,26 @@ def funtest(options): @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def flake8(options): - noerror = getattr(options, "noerror", False) - sh("""flake8 librabbitmq""", ignore_error=noerror) + noerror = getattr(options, 'noerror', False) + sh('flake8 librabbitmq' ignore_error=noerror) @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def flakeplus(options): - noerror = getattr(options, "noerror", False) - sh("python contrib/release/flakeplus.py librabbitmq", + noerror = getattr(options, 'noerror', False) + sh('python contrib/release/flakeplus.py librabbitmq', ignore_error=noerror) @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def flakes(options): flake8(options) @@ -139,38 +139,38 @@ def flakes(options): @task @cmdopts([ - ("noerror", "E", "Ignore errors"), + ('noerror', 'E', 'Ignore errors'), ]) def pep8(options): - noerror = getattr(options, "noerror", False) + noerror = getattr(options, 'noerror', False) return sh("""find librabbitmq -name "*.py" | xargs pep8 | perl -nle'\ print; $a=1 if $_}{exit($a)'""", ignore_error=noerror) @task def removepyc(options): - sh("find . -name '*.pyc' | xargs rm") + sh('find . -name "*.pyc" | xargs rm') @task -@needs("removepyc") +@needs('removepyc') def gitclean(options): - sh("git clean -xdn") + sh('git clean -xdn') @task -@needs("removepyc") +@needs('removepyc') def gitcleanforce(options): - sh("git clean -xdf") + sh('git clean -xdf') @task -@needs("flakes", "test", "gitclean") +@needs('flakes', 'test', 'gitclean') def releaseok(options): pass @task -@needs("releaseok", "removepyc", "upload_docs") +@needs('releaseok', 'removepyc', 'upload_docs') def release(options): pass @@ -1,7 +1,6 @@ import os import platform import sys -from glob import glob from setuptools import setup, find_packages # --with-librabbitmq=<dir>: path to librabbitmq package if needed @@ -11,6 +10,11 @@ LRMQSRC = lambda *x: LRMQDIST('librabbitmq', *x) SPECPATH = lambda *x: os.path.join('rabbitmq-codegen', *x) PYCP = lambda *x: os.path.join('Modules', '_librabbitmq', *x) +CMD_CONFIGURE = """\ +/bin/sh configure --disable-tools \ + --disable-docs \ + --disable-dependency-tracking \ +""" def senv(*k__v, **kwargs): @@ -40,13 +44,12 @@ def codegen(): os.environ.update(restore) - def create_builder(): from setuptools import Extension from distutils.command.build import build as _build cmd = None pkgdirs = [] # incdirs and libdirs get these - libs = []#'rabbitmq'] + libs = [] defs = [] incdirs = [] libdirs = [] @@ -92,13 +95,15 @@ def create_builder(): incdirs.append(LRMQSRC('unix')) librabbit_files.append(LRMQSRC('unix', 'socket.c')) - librabbitmq_ext = Extension('_librabbitmq', - sources=PyC_files + librabbit_files, - libraries=libs, include_dirs=incdirs, - library_dirs=libdirs, define_macros=defs) - #depends=(glob(PYCP('*.h')) + ['setup.py'])) + librabbitmq_ext = Extension( + '_librabbitmq', + sources=PyC_files + librabbit_files, + libraries=libs, include_dirs=incdirs, + library_dirs=libdirs, define_macros=defs, + ) - # Hidden secret: if environment variable GEN_SETUP is set, generate Setup file. + # Hidden secret: if environment variable GEN_SETUP is set + # then generate Setup file. if cmd == 'gen-setup': line = ' '.join(( librabbitmq_ext.name, @@ -120,18 +125,18 @@ def create_builder(): def run(self): here = os.path.abspath(os.getcwd()) - H = lambda *x: os.path.join(here, *x) from distutils import sysconfig config = sysconfig.get_config_vars() try: - restore = senv(('CFLAGS', config['CFLAGS']), - ('LDFLAGS', config['LDFLAGS'])) + restore = senv( + ('CFLAGS', config['CFLAGS']), + ('LDFLAGS', config['LDFLAGS']), + ) try: os.chdir(LRMQDIST()) if not os.path.isfile('config.h'): print('- configure rabbitmq-c...') - os.system('/bin/sh configure --disable-tools \ - --disable-docs --disable-dependency-tracking') + os.system(CMD_CONFIGURE) #print('- make rabbitmq-c...') #os.chdir(LRMQSRC()) #os.system(''%s' all' % find_make()) @@ -166,8 +171,6 @@ author = distmeta[1].strip() contact = distmeta[2].strip() homepage = distmeta[3].strip() - - ext_modules = [] cmdclass = {} packages = [] @@ -187,7 +190,7 @@ elif find_make(): print('Couldn not create builder: %r' % (exc, )) else: goahead = True - ext_modules= [librabbitmq_ext] + ext_modules = [librabbitmq_ext] cmdclass = {'build': build} packages = find_packages(exclude=['ez_setup', 'tests', 'tests.*']) |