From dcd06a2d17ca2cf9689d72cfc22657abeef591f6 Mon Sep 17 00:00:00 2001 From: octogene Date: Fri, 5 Jun 2015 20:36:52 +0200 Subject: [PATCH] Initial setup.py - Refactored project structure. - Fixed import. - Add launch script. - Fixed *.mo loading dir. - Updated documentation --- Makefile | 8 ++-- docs/installation.rst | 6 +-- docs/usage.rst | 9 ++++- hadaly.py | 7 ---- hadaly/__main__.py | 14 +++---- hadaly/app.py | 12 +++--- .../data}/fonts/fontawesome-webfont.ttf | Bin {data => hadaly/data}/icon.png | Bin {data => hadaly/data}/icon/128x128/icon.png | Bin {data => hadaly/data}/icon/32x32/icon.png | Bin {data => hadaly/data}/icon/48x48/icon.png | Bin {data => hadaly/data}/icon/64x64/icon.png | Bin {data => hadaly/data}/icon/icon.ico | Bin {data => hadaly/data}/icon/icon.svg | 0 {data => hadaly/data}/locales/po/fr.po | 0 {data => hadaly/data}/presplash.jpg | Bin {data => hadaly/data}/settings_panel.json | 0 hadaly/editor.py | 2 +- hadaly/hadaly.kv | 6 +-- hadaly/meta.py | 7 ++++ hadaly/search.py | 2 +- hadaly/viewer.py | 2 +- scripts/hadaly | 5 +++ setup.py | 37 ++++++++++++++++++ 24 files changed, 81 insertions(+), 36 deletions(-) delete mode 100755 hadaly.py rename {data => hadaly/data}/fonts/fontawesome-webfont.ttf (100%) rename {data => hadaly/data}/icon.png (100%) rename {data => hadaly/data}/icon/128x128/icon.png (100%) rename {data => hadaly/data}/icon/32x32/icon.png (100%) rename {data => hadaly/data}/icon/48x48/icon.png (100%) rename {data => hadaly/data}/icon/64x64/icon.png (100%) rename {data => hadaly/data}/icon/icon.ico (100%) rename {data => hadaly/data}/icon/icon.svg (100%) rename {data => hadaly/data}/locales/po/fr.po (100%) rename {data => hadaly/data}/presplash.jpg (100%) rename {data => hadaly/data}/settings_panel.json (100%) create mode 100644 hadaly/meta.py create mode 100755 scripts/hadaly create mode 100644 setup.py diff --git a/Makefile b/Makefile index 08a3cbf..9dab5da 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ .PHONY: po mo po: - xgettext -LPython -o data/locales/po/hadaly.pot --from-code=UTF-8 hadaly/*.kv hadaly/*.py - msgmerge --update --no-fuzzy-matching --backup=off data/locales/po/fr.po data/locales/po/hadaly.pot + xgettext -LPython -o hadaly/data/locales/po/hadaly.pot --from-code=UTF-8 hadaly/*.kv hadaly/*.py + msgmerge --update --no-fuzzy-matching --backup=off hadaly/data/locales/po/fr.po hadaly/data/locales/po/hadaly.pot mo: - mkdir -p data/locales/fr/LC_MESSAGES - msgfmt data/locales/po/fr.po -o data/locales/fr/LC_MESSAGES/hadaly.mo + mkdir -p hadaly/data/locales/fr/LC_MESSAGES + msgfmt hadaly/data/locales/po/fr.po -o hadaly/data/locales/fr/LC_MESSAGES/hadaly.mo diff --git a/docs/installation.rst b/docs/installation.rst index b2cb4c3..1327fee 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -25,16 +25,14 @@ Requirements :: pip install kivy-garden - garden install magnet - garden install filechooserthumbview -For now, no setup or binary are available, you have to clone the repository: :: git clone https://github.com/octogene/hadaly.git - + cd hadaly + python setup.py install Windows ~~~~~~~ diff --git a/docs/usage.rst b/docs/usage.rst index 4668a9c..f8603df 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -6,11 +6,16 @@ GNU/Linux :: - python hadaly.py [file.opah] + hadaly [file.opah] Windows ~~~~~~~ -For now, to directly open a presentation file (\*.opah) you'll have to drag'n drop the file on the hadaly.exe executable or the shortcut. +:: + + hadaly.exe [file.opah] + + +Or open *.opah files like any other by double clicking on it. diff --git a/hadaly.py b/hadaly.py deleted file mode 100755 index 7b56ccb..0000000 --- a/hadaly.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python -#-*- coding: utf-8 -*- - -from hadaly.__main__ import main - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/hadaly/__main__.py b/hadaly/__main__.py index 53178ee..409b325 100755 --- a/hadaly/__main__.py +++ b/hadaly/__main__.py @@ -1,19 +1,19 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - -__version__ = '0.1a' - +from __future__ import absolute_import +import os, sys def main(args=None): - from app import HadalyApp + from .app import HadalyApp import locale import gettext current_locale, encoding = locale.getdefaultlocale() - language = gettext.translation('hadaly', 'data/locales/', - [current_locale], fallback=True) + abspath = os.path.abspath(os.path.dirname(sys.argv[0])) + langpath = abspath + '/data/locales/' + language = gettext.translation('hadaly', langpath, + [current_locale]) language.install() - HadalyApp().run() diff --git a/hadaly/app.py b/hadaly/app.py index bd016a6..00e26cc 100644 --- a/hadaly/app.py +++ b/hadaly/app.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import division, unicode_literals +from __future__ import division, unicode_literals, absolute_import import shutil from kivy import require @@ -9,7 +9,7 @@ require('1.9.0') import os, json from sys import argv -import __main__ +from .meta import version as app_version import urllib import re @@ -32,16 +32,16 @@ from kivy.uix.popup import Popup from kivy.uix.label import Label from kivy.factory import Factory from kivy.uix.progressbar import ProgressBar -from editor import Slide, SlideInfoDialog, DraggableSlide -from viewer import SlideBox +from .editor import Slide, SlideInfoDialog, DraggableSlide +from .viewer import SlideBox from kivy.logger import Logger from kivy.network.urlrequest import UrlRequest -from hadaly.search import ItemButton +from .search import ItemButton from kivy.uix.filechooser import FileChooserIconView, FileChooserListView class HadalyApp(App): - presentation = DictProperty({'app': ('hadaly', __main__.__version__), 'title': 'New Title', 'slides': []}) + presentation = DictProperty({'app': ('hadaly', app_version), 'title': 'New Title', 'slides': []}) slides_list = ListProperty() diff --git a/data/fonts/fontawesome-webfont.ttf b/hadaly/data/fonts/fontawesome-webfont.ttf similarity index 100% rename from data/fonts/fontawesome-webfont.ttf rename to hadaly/data/fonts/fontawesome-webfont.ttf diff --git a/data/icon.png b/hadaly/data/icon.png similarity index 100% rename from data/icon.png rename to hadaly/data/icon.png diff --git a/data/icon/128x128/icon.png b/hadaly/data/icon/128x128/icon.png similarity index 100% rename from data/icon/128x128/icon.png rename to hadaly/data/icon/128x128/icon.png diff --git a/data/icon/32x32/icon.png b/hadaly/data/icon/32x32/icon.png similarity index 100% rename from data/icon/32x32/icon.png rename to hadaly/data/icon/32x32/icon.png diff --git a/data/icon/48x48/icon.png b/hadaly/data/icon/48x48/icon.png similarity index 100% rename from data/icon/48x48/icon.png rename to hadaly/data/icon/48x48/icon.png diff --git a/data/icon/64x64/icon.png b/hadaly/data/icon/64x64/icon.png similarity index 100% rename from data/icon/64x64/icon.png rename to hadaly/data/icon/64x64/icon.png diff --git a/data/icon/icon.ico b/hadaly/data/icon/icon.ico similarity index 100% rename from data/icon/icon.ico rename to hadaly/data/icon/icon.ico diff --git a/data/icon/icon.svg b/hadaly/data/icon/icon.svg similarity index 100% rename from data/icon/icon.svg rename to hadaly/data/icon/icon.svg diff --git a/data/locales/po/fr.po b/hadaly/data/locales/po/fr.po similarity index 100% rename from data/locales/po/fr.po rename to hadaly/data/locales/po/fr.po diff --git a/data/presplash.jpg b/hadaly/data/presplash.jpg similarity index 100% rename from data/presplash.jpg rename to hadaly/data/presplash.jpg diff --git a/data/settings_panel.json b/hadaly/data/settings_panel.json similarity index 100% rename from data/settings_panel.json rename to hadaly/data/settings_panel.json diff --git a/hadaly/editor.py b/hadaly/editor.py index 9b672f2..3a93b81 100644 --- a/hadaly/editor.py +++ b/hadaly/editor.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import division, unicode_literals +from __future__ import division, unicode_literals, absolute_import import os from functools import partial diff --git a/hadaly/hadaly.kv b/hadaly/hadaly.kv index 2d571fb..98f7cc0 100644 --- a/hadaly/hadaly.kv +++ b/hadaly/hadaly.kv @@ -1,4 +1,4 @@ #:kivy 1.9.0 -#:include hadaly/editor.kv -#:include hadaly/viewer.kv -#:include hadaly/search.kv +#:include editor.kv +#:include viewer.kv +#:include search.kv diff --git a/hadaly/meta.py b/hadaly/meta.py new file mode 100644 index 0000000..ad232f6 --- /dev/null +++ b/hadaly/meta.py @@ -0,0 +1,7 @@ +"""This module contains metadata about the project.""" +title = 'hadaly' +version = '0.1a' +description = 'Presentation software for art historians' +author = 'Bogdan Cordie' +author_email = 'ooctogene@gmail.com' +license = 'GPLv3' \ No newline at end of file diff --git a/hadaly/search.py b/hadaly/search.py index 9e69c57..26a2674 100644 --- a/hadaly/search.py +++ b/hadaly/search.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import division, unicode_literals +from __future__ import division, unicode_literals, absolute_import try: from urlparse import urlparse, parse_qs diff --git a/hadaly/viewer.py b/hadaly/viewer.py index 2e7e7a2..0a085d5 100644 --- a/hadaly/viewer.py +++ b/hadaly/viewer.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import division, unicode_literals +from __future__ import division, unicode_literals, absolute_import from kivy.uix.screenmanager import Screen from kivy.uix.scatter import Matrix diff --git a/scripts/hadaly b/scripts/hadaly new file mode 100755 index 0000000..c6bec6a --- /dev/null +++ b/scripts/hadaly @@ -0,0 +1,5 @@ +#!/usr/bin/env python +import runpy + +if __name__ == '__main__': + runpy.run_module('hadaly', run_name=__name__, alter_sys=True) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..326360e --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +import os +from setuptools import setup, find_packages +from hadaly import meta + +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + +setup( + name='hadaly', + version=meta.version, + description=meta.description, + packages=find_packages(), + url='https://octogene.github.io/hadaly/', + license=meta.license, + author=meta.author, + author_email=meta.author_email, + requires=['lxml', 'Pillow', 'kivy'], + long_description=read('README.md'), + package_data={'hadaly': ['data/*.png', + 'data/fonts/*.ttf', + 'data/locales/fr/LC_MESSAGES/*.mo']}, + include_package_data=True, + classifiers=[ + "Development Status :: 3 - Alpha", + "Environment :: X11 Applications", + "Programming Language :: Python :: 2.7", + "Operating System :: OS Independent", + "Natural Language :: English", + "Natural Language :: French", + "Topic :: Education", + "Intended Audience :: Education", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + ], + scripts = ['scripts/hadaly'], + zip_safe = False, +)