diff options
author | mathieui <mathieui@mathieui.net> | 2013-05-26 20:07:12 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-05-26 20:13:39 +0200 |
commit | 2b42c6a3ead7c2bd35bbea1c6d704a4f89a4c8a2 (patch) | |
tree | 10a77ef05670ec575e2c3357e0b3df9b0847a261 | |
parent | 1b9dc72d14f52d55a936d92311c18912567359a4 (diff) | |
download | poezio-2b42c6a3ead7c2bd35bbea1c6d704a4f89a4c8a2.tar.gz poezio-2b42c6a3ead7c2bd35bbea1c6d704a4f89a4c8a2.tar.bz2 poezio-2b42c6a3ead7c2bd35bbea1c6d704a4f89a4c8a2.tar.xz poezio-2b42c6a3ead7c2bd35bbea1c6d704a4f89a4c8a2.zip |
Update setup.py to use distutils
(use new default directory, install the plugins as a separate
python moduleā¦)
-rw-r--r-- | MANIFEST.in | 3 | ||||
-rw-r--r-- | Makefile | 20 | ||||
-rw-r--r-- | plugins/__init__.py | 0 | ||||
-rwxr-xr-x | scripts/poezio | 4 | ||||
-rw-r--r-- | setup.py | 44 | ||||
-rw-r--r-- | src/__init__.py | 1 | ||||
-rw-r--r-- | src/config.py | 7 | ||||
-rw-r--r-- | src/plugin_manager.py | 37 | ||||
-rw-r--r-- | src/poezio.py | 6 |
9 files changed, 82 insertions, 40 deletions
diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..302727b2 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include data/default_config.cfg +include data/poezio.1 +recursive-include data/ * @@ -7,7 +7,7 @@ LOCALEDIR=$(DATADIR)/locale MANDIR=$(DATADIR)/man all: Makefile - cd src/ && python3 ../setup.py build_ext --inplace + python3 setup.py build_ext --inplace clean: find ./ -name \*.pyc -delete @@ -17,25 +17,11 @@ clean: rm -r doc/build/ install: all - mkdir -p $(DESTDIR)$(prefix) - install -d $(DESTDIR)$(LOCALEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(DATADIR)/poezio $(DESTDIR)$(DATADIR)/poezio/data $(DESTDIR)$(DATADIR)/poezio/src/ $(DESTDIR)$(DATADIR)/poezio/src $(DESTDIR)$(DATADIR)/poezio/data/themes $(DESTDIR)$(MANDIR)/man1 $(DESTDIR)$(DOCDIR)/poezio $(DESTDIR)$(DATADIR)/poezio/plugins - - cp -R data/* $(DESTDIR)$(DATADIR)/poezio/data/ - rm $(DESTDIR)$(DATADIR)/poezio/data/poezio.1 - - cp -R plugins/* $(DESTDIR)$(DATADIR)/poezio/plugins + mkdir -p $(DESTDIR)$(prefix) $(DESTDIR)$(DOCDIR)/poezio/ $(DESTDIR)$(LOCALEDIR) $(DESTDIR)$(BINDIR) cp -R doc/* $(DESTDIR)$(DOCDIR)/poezio/ - cp README CHANGELOG COPYING $(DESTDIR)$(DOCDIR)/poezio/ - install -m644 data/poezio.1 $(DESTDIR)$(MANDIR)/man1/ - for sourcefile in `ls -1 src/*.py src/*.so` ; do \ - install -m644 $$sourcefile $(DESTDIR)$(DATADIR)/poezio/src; \ - done - - echo "#!/usr/bin/env sh" > $(DESTDIR)$(BINDIR)/poezio - echo "python3 $(DATADIR)/poezio/src/poezio.py \$$@" >> $(DESTDIR)$(BINDIR)/poezio - chmod 755 $(DESTDIR)$(BINDIR)/poezio + cp README CHANGELOG COPYING $(DESTDIR)$(DOCDIR)/poezio/ uninstall: rm -f $(DESTDIR)$(BINDIR)/poezio diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/plugins/__init__.py diff --git a/scripts/poezio b/scripts/poezio new file mode 100755 index 00000000..665edcaa --- /dev/null +++ b/scripts/poezio @@ -0,0 +1,4 @@ +#!/usr/bin/python3 + +from poezio import main +main() @@ -1,16 +1,40 @@ from distutils.core import setup, Extension -module_poopt = Extension('poopt', - sources = ['pooptmodule.c']) +module_poopt = Extension('poezio.poopt', + sources = ['src/pooptmodule.c']) -setup (name = 'BuildLines', - version = '0.0.1', - description = 'Poezio Optimizations', +setup(name="poezio", + version="0.8-dev", + description="A console XMPP client", + long_description= + """ + Poezio is a free chat client aiming to reproduce the ease of use of most + IRC clients (e.g. weechat, irssi) while using the XMPP network. + """, ext_modules = [module_poopt], + url = 'http://poezio.eu/', + license = 'zlib', + author = 'Florent Le Coz', author_email = 'louiz@louiz.org', - long_description = """ - a python3 module for poezio, used to replace some time-critical - python functions that are too slow. If compiled, poezio will use this module, - otherwise it will just use the equivalent python functions. - """) + + maintainer = 'Mathieu Pasquet', + maintainer_email = 'mathieui@mathieui.net', + + classifiers = ['Development Status :: 4 - Beta', + 'Environment :: Console :: Curses', + 'Intended Audience :: End Users/Desktop', + 'License :: OSI Approved :: zlib/libpng License', + 'Natural Language :: English', + 'Operating System :: Unix', + 'Topic :: Communications :: Chat', + 'Programming Language :: Python :: 3', + ], + keywords = ['xmpp', 'chat', 'im', 'console'], + packages = ['poezio', 'poezio_plugins'], + package_dir = {'poezio': 'src', 'poezio_plugins': 'plugins'}, + scripts = ['scripts/poezio'], + data_files = [('/etc/poezio/', ['data/default_config.cfg']), + ('share/poezio/themes/', ['data/themes/dark.py']), + ('share/man/man1/', ['data/poezio.1'])], +) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 00000000..9fdbcc02 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1 @@ +from poezio.poezio import main diff --git a/src/config.py b/src/config.py index 2134513f..47262e28 100644 --- a/src/config.py +++ b/src/config.py @@ -251,7 +251,12 @@ options = parse_args(CONFIG_PATH) # Copy a default file if none exists if not path.isfile(options.filename): - copy2(path.join(path.dirname(__file__), '../data/default_config.cfg'), options.filename) + default = path.join(path.dirname(__file__), '../data/default_config.cfg') + other = '/etc/poezio/default_config.cfg' + if path.isfile(default): + copy2(default, options.filename) + elif path.isfile(other): + copy2(other, options.filename) firstrun = True config = Config(options.filename) diff --git a/src/plugin_manager.py b/src/plugin_manager.py index f494fefc..9e253f97 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -20,6 +20,8 @@ from config import config log = logging.getLogger(__name__) +load_path = [] + plugins_dir = config.get('plugins_dir', '') plugins_dir = plugins_dir or\ os.path.join(os.environ.get('XDG_DATA_HOME') or\ @@ -39,6 +41,8 @@ try: os.makedirs(plugins_dir) except OSError: pass +else: + load_path.append(plugins_dir) try: os.makedirs(plugins_conf_dir) @@ -47,14 +51,23 @@ except OSError: default_plugin_path = path.join(path.dirname(path.dirname(__file__)), 'plugins') -sys.path.append(plugins_dir) -sys.path.append(default_plugin_path) +if os.path.exists(default_plugin_path): + load_path.append(default_plugin_path) + +try: + import poezio_plugins +except: + pass +else: + if poezio_plugins.__path__: + load_path.append(poezio_plugins.__path__[0]) + +sys.path.extend(load_path) if version_info[1] >= 3: # 3.3 & > from importlib import machinery finder = machinery.PathFinder() - class PluginManager(object): """ Plugin Manager @@ -94,7 +107,7 @@ class PluginManager(object): imp.acquire_lock() module = imp.reload(self.modules[name]) else: - file, filename, info = imp.find_module(name, [plugins_dir, default_plugin_path]) + file, filename, info = imp.find_module(name, load_path) imp.acquire_lock() module = imp.load_module(name, file, filename, info) else: # 3.3 & > @@ -288,15 +301,19 @@ class PluginManager(object): all .py files in plugins_dir """ try: - try: - names = set(os.listdir(default_plugin_path)) - except: - names = set() - names |= set(os.listdir(plugins_dir)) + names = set() + for path in load_path: + try: + add = set(os.listdir(path)) + names |= add + except: + pass except OSError as e: self.core.information(_('Completion failed: %s' % e), 'Error') return - plugins_files = [name[:-3] for name in names if name.endswith('.py')] + plugins_files = [name[:-3] for name in names if name.endswith('.py') + and name != '__init__.py' and not name.startswith('.')] + plugins_files.sort() return the_input.auto_completion(plugins_files, '', quotify=False) def completion_unload(self, the_input): diff --git a/src/poezio.py b/src/poezio.py index 161446da..c0863416 100644 --- a/src/poezio.py +++ b/src/poezio.py @@ -12,11 +12,13 @@ Starting point of poezio. Launches both the Connection and Gui import sys import os -sys.path.append(os.path.dirname(os.path.abspath(__file__))) + import signal import logging -from logger import logger +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + +from logger import logger from config import options import singleton import core |