From 69d10d0f55740591a43f4f49e90e09785ab0675f Mon Sep 17 00:00:00 2001
From: kaliko <efrim@azylum.org>
Date: Wed, 8 Jan 2014 20:29:12 +0100
Subject: [PATCH] Packaging refactoring

---
 mpd-sima                 | 10 ++++++++++
 setup.py                 | 32 +++++++++-----------------------
 sima/__init__.py         |  2 --
 sima/core.py             |  4 ----
 sima/info.py             | 22 ++++++++++++++++++++++
 launch => sima/launch.py | 22 ++++++++++------------
 6 files changed, 51 insertions(+), 41 deletions(-)
 create mode 100644 mpd-sima
 create mode 100644 sima/info.py
 rename launch => sima/launch.py (88%)
 mode change 100755 => 100644

diff --git a/mpd-sima b/mpd-sima
new file mode 100644
index 0000000..e6157a2
--- /dev/null
+++ b/mpd-sima
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Script starts here
+from sima.launch import main
+main()
+
+# VIM MODLINE
+# vim: ai ts=4 sw=4 sts=4 expandtab
+
diff --git a/setup.py b/setup.py
index 2768347..eb8501c 100755
--- a/setup.py
+++ b/setup.py
@@ -3,23 +3,12 @@
 
 import glob
 
-from setuptools import setup
-#from distutils.core import setup
+from setuptools import setup, find_packages  # >= 2.0.2
 from os import listdir
 from os.path import isfile, isdir
 
-from sima.core import __version__ as VERSION
-
-DESCRIPTION = """
-sima is a Python application meant to feed your MPD playlist with tracks
-from artists similar to your currently playing track, provided that these
-artists are found in MPD library. Similar artists are fetched from last.fm.
-
-sima can queue track, top track or whole album for similar artists.
-
-This client allows you to never run out of music when your playlist
-queue is getting short.
-"""
+from sima.info import __version__ as VERSION, __author__ as AUTHOR
+from sima.info import __doc__ as DESCRIPTION, __email__ as EMAIL
 
 data_files = [
     #('share/man/man1', ['data/mpd-sima.1', 'data/simadb_cli.1',]),
@@ -44,22 +33,19 @@ setup(name='sima',
       download_url='http://codingteam.net/project/sima/download',
       url='http://codingteam.net/project/sima',
       description='Automagically add titles to MPD playlist',
-      author='Jack Kaliko',
-      author_email='Jack Kaliko <kaliko@azylum.org>',
+      author=AUTHOR,
+      author_email= EMAIL,
       license='GPLv3',
       keywords='MPD',
       long_description=DESCRIPTION,
       classifiers=classifiers,
-      install_requires=['distribute', 'python-musicpd'],
-      packages=['sima','sima.lib', 'sima.utils',
-                'sima.plugins.core',
-                'sima.plugins.internal',
-                'sima.plugins.contrib'],
+      install_requires=['python-musicpd'],
+      packages=find_packages(),
       include_package_data=True,
       data_files=data_files,
-      scripts=['launch'],
+      #scripts=['mpd-sima'],
       entry_points={
-          'console_scripts': ['sima = launch:mainc',]
+          'console_scripts': ['mpd-sima = sima.launch:main',]
           },
 )
 
diff --git a/sima/__init__.py b/sima/__init__.py
index bd387be..f78f634 100644
--- a/sima/__init__.py
+++ b/sima/__init__.py
@@ -1,6 +1,4 @@
 # -*- coding: utf-8 -*-
 
-
 # VIM MODLINE
 # vim: ai ts=4 sw=4 sts=4 expandtab
-
diff --git a/sima/core.py b/sima/core.py
index bf098bb..adbefa2 100644
--- a/sima/core.py
+++ b/sima/core.py
@@ -2,10 +2,6 @@
 """Core Object dealing with plugins and player client
 """
 
-__version__ = '0.12.0pr1'
-__author__ = 'kaliko jack'
-__url__ = 'git://git.kaliko.me/sima.git'
-
 import sys
 import time
 
diff --git a/sima/info.py b/sima/info.py
new file mode 100644
index 0000000..3b6d369
--- /dev/null
+++ b/sima/info.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+"""
+sima is a Python application meant to feed your MPD playlist with tracks
+from artists similar to your currently playing track, provided that these
+artists are found in MPD library. Similar artists are fetched from last.fm.
+
+sima can queue track, top track or whole album for similar artists.
+
+This client allows you to never run out of music when your playlist
+queue is getting short.
+"""
+
+
+__version__ = '0.12.0pr2'
+__author__ = 'kaliko jack'
+__email__ = 'kaliko@azylum.org'
+__url__ = 'git://git.kaliko.me/sima.git'
+
+
+# VIM MODLINE
+# vim: ai ts=4 sw=4 sts=4 expandtab
+
diff --git a/launch b/sima/launch.py
old mode 100755
new mode 100644
similarity index 88%
rename from launch
rename to sima/launch.py
index 9d12fda..dbd1525
--- a/launch
+++ b/sima/launch.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 """Sima
 """
@@ -15,15 +14,15 @@ from os.path import isfile
 ##
 
 # local import
-from sima import core
-from sima.lib.logger import set_logger
-from sima.lib.simadb import SimaDB
-from sima.utils.config import ConfMan
-from sima.utils.startopt import StartOpt
-from sima.utils.utils import exception_log, SigHup
+from . import core, info
+from .lib.logger import set_logger
+from .lib.simadb import SimaDB
+from .utils.config import ConfMan
+from .utils.startopt import StartOpt
+from .utils.utils import exception_log, SigHup
  # core plugins
-from sima.plugins.core.history import History
-from sima.plugins.core.mpdoptions import MpdOptions
+from .plugins.core.history import History
+from .plugins.core.mpdoptions import MpdOptions
 ##
 
 
@@ -99,7 +98,6 @@ def start(sopt, restart=False):
             logger.info('Daemonize process...')
             sima.start()
 
-    logger.error('starting')
     try:
         sima.foreground()
     except KeyboardInterrupt:
@@ -122,10 +120,10 @@ def run(sopt, restart=False):
 
 # Script starts here
 def main():
-    info = dict({'version': core.__version__,
+    nfo = dict({'version': info.__version__,
                  'prog': 'sima'})
     # StartOpt gathers options from command line call (in StartOpt().options)
-    sopt = StartOpt(info)
+    sopt = StartOpt(nfo)
     run(sopt)
 
 
-- 
2.39.5