From b1f597deaedefe75343d718e54850eca9af9b43a Mon Sep 17 00:00:00 2001 From: boyska Date: Wed, 29 Oct 2014 00:39:43 +0100 Subject: [PATCH] proper setup.py setup & test --- .gitignore | 3 ++ larigira/__init__.py | 0 celeryconfig.py => larigira/celeryconfig.py | 0 eventutils.py => larigira/eventutils.py | 0 mpc.py => larigira/mpc.py | 5 ++- rpc.py => larigira/rpc.py | 0 task.py => larigira/task.py | 0 .../tests/test_parented.py | 2 +- test_web.py => larigira/tests/test_web.py | 2 +- setup.py | 45 +++++++++++++++++++ 10 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 larigira/__init__.py rename celeryconfig.py => larigira/celeryconfig.py (100%) rename eventutils.py => larigira/eventutils.py (100%) rename mpc.py => larigira/mpc.py (99%) rename rpc.py => larigira/rpc.py (100%) rename task.py => larigira/task.py (100%) rename test_parented.py => larigira/tests/test_parented.py (97%) rename test_web.py => larigira/tests/test_web.py (89%) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 034ed13..288d0f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ *.pyc .*.sw? +/dist/ +/*.egg-info +build diff --git a/larigira/__init__.py b/larigira/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/celeryconfig.py b/larigira/celeryconfig.py similarity index 100% rename from celeryconfig.py rename to larigira/celeryconfig.py diff --git a/eventutils.py b/larigira/eventutils.py similarity index 100% rename from eventutils.py rename to larigira/eventutils.py diff --git a/mpc.py b/larigira/mpc.py similarity index 99% rename from mpc.py rename to larigira/mpc.py index db1ebaa..0bb1a80 100644 --- a/mpc.py +++ b/larigira/mpc.py @@ -80,7 +80,7 @@ def on_player_crash(*args, **kwargs): sys.exit(1) -if __name__ == '__main__': +def main(): p = Player() p.start() p.link_exception(on_player_crash) @@ -90,3 +90,6 @@ if __name__ == '__main__': p.q.put('signal', *args) gevent.signal(signal.SIGHUP, sig, signal.SIGHUP) gevent.wait() + +if __name__ == '__main__': + main() diff --git a/rpc.py b/larigira/rpc.py similarity index 100% rename from rpc.py rename to larigira/rpc.py diff --git a/task.py b/larigira/task.py similarity index 100% rename from task.py rename to larigira/task.py diff --git a/test_parented.py b/larigira/tests/test_parented.py similarity index 97% rename from test_parented.py rename to larigira/tests/test_parented.py index 65a67dc..85a1e77 100644 --- a/test_parented.py +++ b/larigira/tests/test_parented.py @@ -6,7 +6,7 @@ import pytest import gevent -from mpc import Timer, ParentedLet +from larigira.mpc import Timer, ParentedLet # TODO: implement simple children and check that we will receive the expected # messages on the queue diff --git a/test_web.py b/larigira/tests/test_web.py similarity index 89% rename from test_web.py rename to larigira/tests/test_web.py index eb961fa..791c5d9 100644 --- a/test_web.py +++ b/larigira/tests/test_web.py @@ -4,7 +4,7 @@ monkey.patch_all(subprocess=True) import pytest -from rpc import create_app +from larigira.rpc import create_app @pytest.fixture diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..714de56 --- /dev/null +++ b/setup.py @@ -0,0 +1,45 @@ +import sys + +from setuptools import setup +from setuptools.command.test import test as TestCommand + + +class PyTest(TestCommand): + user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] + + def initialize_options(self): + TestCommand.initialize_options(self) + self.pytest_args = [] + + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + + def run_tests(self): + # import here, cause outside the eggs aren't loaded + import pytest + errno = pytest.main(self.pytest_args) + sys.exit(errno) + +setup(name='larigira', + version='0.1', + description='A radio automation based on MPD', + author='boyska', + author_email='piuttosto@logorroici.org', + license='AGPL', + packages=['larigira'], + install_requires=[ + 'gevent', + 'flask', + 'python-mpd2', + 'redis', + 'celery' + ], + tests_require=['pytest'], + cmdclass={'test': PyTest}, + zip_safe=False, + entry_points={ + 'console_scripts': ['larigira=larigira.mpc:main'] + } + )