Update setup files

- remove “make uninstall” target which was broken a long time ago
- move very install action to the setup.py (alias “make install” to
  “python setup.py install”
- add some stuff to “make clean”
- update the config.py to search the default config file using
  pkg_resources (more reliable than dirname(__file__))
- install the html doc only if available
- use README.rst for the setup.py long_description

- also, update the copyright notice to 2015
This commit is contained in:
mathieui 2015-02-10 17:40:53 +01:00
parent c38cddd0ff
commit 14b58c528e
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3
5 changed files with 82 additions and 67 deletions

View file

@ -1,4 +1,4 @@
Copyright (c) 2010-2014 Florent Le Coz and Mathieu Pasquet Copyright (c) 2010-2015 Florent Le Coz and Mathieu Pasquet
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View file

@ -1,4 +0,0 @@
include src/default_config.cfg
include data/default_config.cfg
include data/poezio.1
recursive-include data/ *

View file

@ -14,21 +14,16 @@ clean:
find ./ -name \*.pyc -delete find ./ -name \*.pyc -delete
find ./ -name \*.pyo -delete find ./ -name \*.pyo -delete
find ./ -name \*~ -delete find ./ -name \*~ -delete
find ./ -type d -name __pycache__ -delete
find ./ -name "#*#" -delete find ./ -name "#*#" -delete
rm -rf doc/build/ rm -rf doc/build/
rm -rf poezio.egg-info
rm -rf dist
rm -rf build rm -rf build
rm -f src/*.so rm -f src/*.so
install: all install: all
python3 setup.py install --root=$(DESTDIR) --optimize=1 python3 setup.py install --root=$(DESTDIR) --optimize=1
mkdir -p $(DESTDIR)$(prefix) $(DESTDIR)$(DOCDIR)/poezio/ $(DESTDIR)$(LOCALEDIR) $(DESTDIR)$(BINDIR)
cp -R doc/* $(DESTDIR)$(DOCDIR)/poezio/
cp README.rst CHANGELOG COPYING $(DESTDIR)$(DOCDIR)/poezio/
uninstall:
rm -f $(DESTDIR)$(BINDIR)/poezio
rm -rf $(DESTDIR)$(DOCDIR)/poezio/
rm -rf $(DESTDIR)$(MANDIR)/man1/poezio.1
doc: doc:
make -C doc/ html make -C doc/ html

126
setup.py
View file

@ -7,23 +7,47 @@ except ImportError:
import sys import sys
sys.exit(1) sys.exit(1)
import os from os.path import basename, dirname, exists, join
from os import link, walk, unlink
current_dir = dirname(__file__)
def get_relative_dir(folder, stopper):
"""
Find the path from a directory to a pseudo-root in order to recreate
the filetree.
"""
acc = []
last = basename(folder)
while last != stopper:
acc.append(last)
folder = dirname(folder)
last = basename(folder)
return join(*acc[::-1]) if acc else ''
def find_doc(before, path):
_files = []
stop = basename(path)
for root, dirs, files in walk(join(current_dir, 'doc', path)):
files_path = []
relative_root = get_relative_dir(root, stop)
for name in files:
files_path.append(join(root, name))
_files.append((join(before, relative_root), files_path))
return _files
module_poopt = Extension('poezio.poopt', module_poopt = Extension('poezio.poopt',
extra_compile_args=['-Wno-declaration-after-statement'], extra_compile_args=['-Wno-declaration-after-statement'],
sources = ['src/pooptmodule.c']) sources=['src/pooptmodule.c'])
current_dir = os.path.dirname(__file__)
# Create a link to the config file (for packaging purposes) # Create a link to the config file (for packaging purposes)
if not os.path.exists(os.path.join(current_dir, 'src', 'default_config.cfg')): if not exists(join(current_dir, 'src', 'default_config.cfg')):
os.link(os.path.join(current_dir, 'data', 'default_config.cfg'), link(join(current_dir, 'data', 'default_config.cfg'),
os.path.join(current_dir, 'src', 'default_config.cfg')) join(current_dir, 'src', 'default_config.cfg'))
# identify the git version # identify the git version
git_dir = os.path.join(current_dir, '.git') git_dir = join(current_dir, '.git')
if os.path.exists(git_dir): if exists(git_dir):
try: try:
import subprocess import subprocess
result = subprocess.Popen(['git', '--git-dir', git_dir, 'describe'], result = subprocess.Popen(['git', '--git-dir', git_dir, 'describe'],
@ -37,51 +61,51 @@ if os.path.exists(git_dir):
else: else:
version = '.dev1' version = '.dev1'
with open('README.rst', encoding='utf-8') as readme_fd:
LONG_DESCRIPTION = readme_fd.read()
setup(name="poezio", setup(name="poezio",
version="0.9" + version, version="0.9" + version,
description="A console XMPP client", description="A console XMPP client",
long_description= long_description=LONG_DESCRIPTION,
"Poezio is a Free chat client aiming to reproduce the ease of use of most " ext_modules=[module_poopt],
"IRC clients (e.g. weechat, irssi) while using the XMPP network." url='http://poez.io/',
"\n" license='zlib',
"Documentation is available at http://doc.poez.io/.", download_url='https://dev.louiz.org/projects/poezio/files',
ext_modules = [module_poopt], author='Florent Le Coz',
url = 'http://poez.io/', author_email='louiz@louiz.org',
license = 'zlib',
download_url = 'https://dev.louiz.org/projects/poezio/files',
author = 'Florent Le Coz', maintainer='Mathieu Pasquet',
author_email = 'louiz@louiz.org', maintainer_email='mathieui@mathieui.net',
maintainer = 'Mathieu Pasquet', classifiers=['Development Status :: 2 - Pre-Alpha',
maintainer_email = 'mathieui@mathieui.net', 'Topic :: Communications :: Chat',
'Environment :: Console :: Curses',
classifiers = ['Development Status :: 2 - Pre-Alpha', 'Intended Audience :: End Users/Desktop',
'Topic :: Communications :: Chat', 'License :: OSI Approved :: zlib/libpng License',
'Environment :: Console :: Curses', 'Natural Language :: English',
'Intended Audience :: End Users/Desktop', 'Operating System :: Unix',
'License :: OSI Approved :: zlib/libpng License', 'Programming Language :: Python :: 3.4',
'Natural Language :: English', 'Programming Language :: Python :: 3 :: Only'],
'Operating System :: Unix', keywords=['jabber', 'xmpp', 'client', 'chat', 'im', 'console'],
'Programming Language :: Python :: 3' packages=['poezio', 'poezio.core', 'poezio.tabs', 'poezio.windows',
], 'poezio_plugins', 'poezio_plugins.gpg', 'poezio_themes'],
keywords = ['jabber', 'xmpp', 'client', 'chat', 'im', 'console'], package_dir={'poezio': 'src',
packages = ['poezio', 'poezio.core', 'poezio.tabs', 'poezio.windows', 'poezio_plugins': 'plugins',
'poezio_plugins', 'poezio_plugins.gpg', 'poezio_themes'], 'poezio_themes': 'data/themes'},
package_dir = {'poezio': 'src', 'poezio_plugins': 'plugins', 'poezio_themes': 'data/themes'}, package_data={'poezio': ['default_config.cfg']},
package_data = {'poezio': ['default_config.cfg']}, scripts=['scripts/poezio_gpg_export'],
scripts = ['scripts/poezio_gpg_export'], entry_points={'console_scripts': ['poezio = poezio:main']},
entry_points={ 'console_scripts': [ 'poezio = poezio:main' ] }, data_files=([('share/man/man1/', ['data/poezio.1']),
data_files = [('share/man/man1/', ['data/poezio.1'])], ('share/poezio/', ['README.rst', 'COPYING', 'CHANGELOG'])]
+ find_doc('share/doc/poezio/html', 'source')
install_requires = ['slixmpp', + find_doc('share/doc/poezio/source', 'build/html')),
'aiodns'], install_requires=['slixmpp', 'aiodns'],
extras_require = {'OTR plugin': 'python-potr>=1.0', extras_require={'OTR plugin': 'python-potr>=1.0',
'Screen autoaway plugin': 'pyinotify==0.9.4'} 'Screen autoaway plugin': 'pyinotify==0.9.4'})
)
# Remove the link afterwards # Remove the link afterwards
if os.path.exists(os.path.join(current_dir, 'src', 'default_config.cfg')): if exists(join(current_dir, 'src', 'default_config.cfg')):
os.unlink(os.path.join(current_dir, 'src', 'default_config.cfg')) unlink(join(current_dir, 'src', 'default_config.cfg'))

View file

@ -15,6 +15,7 @@ DEFSECTION = "Poezio"
import logging.config import logging.config
import os import os
import sys import sys
import pkg_resources
from gettext import gettext as _ from gettext import gettext as _
from configparser import RawConfigParser, NoOptionError, NoSectionError from configparser import RawConfigParser, NoOptionError, NoSectionError
@ -527,9 +528,8 @@ def run_cmdline_args(CONFIG_PATH):
# Copy a default file if none exists # Copy a default file if none exists
if not path.isfile(options.filename): if not path.isfile(options.filename):
default = path.join(path.dirname(__file__), default = path.join(path.dirname(__file__), '../data/default_config.cfg')
'../data/default_config.cfg') other = pkg_resources.resource_filename('poezio', 'default_config.cfg')
other = path.join(path.dirname(__file__), 'default_config.cfg')
if path.isfile(default): if path.isfile(default):
copy2(default, options.filename) copy2(default, options.filename)
elif path.isfile(other): elif path.isfile(other):