From 2fb3280d07243c259758bea866706776fa3f69f8 Mon Sep 17 00:00:00 2001 From: Dave Andreoli Date: Mon, 29 May 2017 21:37:37 +0200 Subject: [PATCH] Added a python project skeleton The provided app is identical to the C skeleton (just a window and a label) Is still a bit minimal, but all the basic functions are implemented: ./setup.py check ./setup.py build ./setup.py run ./setup.py install / uninstall ./setup.py clean --all Later I will extend the skeleton to support: * gettext translations * FDO stuff installation (.desktop and icons) * Edje theme building --- data/extra/skeleton/Makefile.am | 7 +- data/extra/skeleton/eflproject_python/COPYING | 29 ++++++++ data/extra/skeleton/eflproject_python/README | 1 + .../eflproject_python/bin/${Edi_Name} | 6 ++ .../extra/skeleton/eflproject_python/setup.py | 70 +++++++++++++++++++ .../eflproject_python/src/__init__.py | 0 .../skeleton/eflproject_python/src/main.py | 33 +++++++++ 7 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 data/extra/skeleton/eflproject_python/COPYING create mode 100644 data/extra/skeleton/eflproject_python/README create mode 100755 data/extra/skeleton/eflproject_python/bin/${Edi_Name} create mode 100755 data/extra/skeleton/eflproject_python/setup.py create mode 100644 data/extra/skeleton/eflproject_python/src/__init__.py create mode 100644 data/extra/skeleton/eflproject_python/src/main.py diff --git a/data/extra/skeleton/Makefile.am b/data/extra/skeleton/Makefile.am index c367077..46df77b 100644 --- a/data/extra/skeleton/Makefile.am +++ b/data/extra/skeleton/Makefile.am @@ -1,9 +1,14 @@ MAINTAINERCLEANFILES = Makefile.in skeletondir = $(datadir)/$(PACKAGE)/skeleton -skeleton_DATA = eflproject.tar.gz +skeleton_DATA = \ +eflproject.tar.gz \ +eflproject_python.tar.gz eflproject.tar.gz: tar zcvf eflproject.tar.gz -C $(srcdir) eflproject +eflproject_python.tar.gz: + tar zcvf eflproject_python.tar.gz -C $(srcdir) eflproject_python + EXTRA_DIST = $(skeleton_DATA) diff --git a/data/extra/skeleton/eflproject_python/COPYING b/data/extra/skeleton/eflproject_python/COPYING new file mode 100644 index 0000000..15a65b8 --- /dev/null +++ b/data/extra/skeleton/eflproject_python/COPYING @@ -0,0 +1,29 @@ + +Copyright (C) ${Edi_Year} ${Edi_User} <${Edi_Email}> + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/data/extra/skeleton/eflproject_python/README b/data/extra/skeleton/eflproject_python/README new file mode 100644 index 0000000..e845566 --- /dev/null +++ b/data/extra/skeleton/eflproject_python/README @@ -0,0 +1 @@ +README diff --git a/data/extra/skeleton/eflproject_python/bin/${Edi_Name} b/data/extra/skeleton/eflproject_python/bin/${Edi_Name} new file mode 100755 index 0000000..abb8b25 --- /dev/null +++ b/data/extra/skeleton/eflproject_python/bin/${Edi_Name} @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +import sys +from ${Edi_Name}.main import main + +sys.exit(main()) diff --git a/data/extra/skeleton/eflproject_python/setup.py b/data/extra/skeleton/eflproject_python/setup.py new file mode 100755 index 0000000..dc509ae --- /dev/null +++ b/data/extra/skeleton/eflproject_python/setup.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# encoding: utf-8 + +# python setup.py check +# python setup.py build +# python setup.py run +# python setup.py install +# python setup.py clean --all + + +from distutils.core import setup, Command +from distutils.version import StrictVersion +from efl.utils.setup import build_extra, build_edc, build_fdo, build_i18n, uninstall +from efl import __version__ as efl_version + + +MIN_EFL = '1.18' +if StrictVersion(efl_version) < MIN_EFL: + print('Your python-efl version is too old! Found: ' + efl_version) + print('You need at least version ' + MIN_EFL) + exit(1) + + +class run_in_tree(Command): + description = 'Run the main() from the build folder (without install)' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + import sys, platform + + sys.path.insert(0, 'build/lib.%s-%s-%d.%d' % ( + platform.system().lower(), platform.machine(), + sys.version_info[0], sys.version_info[1])) + + from ${Edi_Name}.main import main + sys.exit(main()) + + +setup( + name = '${Edi_Name}', + version = '0.0.1', + description = 'Short description', + long_description = 'A longer description of your project', + author = '${Edi_User}', + author_email = '${Edi_Email}', + url = '${Edi_Url}', + license = "GNU GPL", + package_dir = {'${Edi_Name}': 'src'}, + packages = ['${Edi_Name}'], + requires = ['efl'], + scripts = ['bin/${Edi_Name}'], + cmdclass = { + 'build': build_extra, + # 'build_edc': build_edc, + # 'build_fdo': build_fdo, + # 'build_i18n': build_i18n, + 'run': run_in_tree, + 'uninstall': uninstall, + }, + command_options = { + 'install': {'record': ('setup.py', 'installed_files.txt')} + }, +) + diff --git a/data/extra/skeleton/eflproject_python/src/__init__.py b/data/extra/skeleton/eflproject_python/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/data/extra/skeleton/eflproject_python/src/main.py b/data/extra/skeleton/eflproject_python/src/main.py new file mode 100644 index 0000000..799aa08 --- /dev/null +++ b/data/extra/skeleton/eflproject_python/src/main.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# encoding: utf-8 + +from __future__ import absolute_import, print_function, division + +import sys + +from efl import elementary as elm +from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, EXPAND_BOTH, FILL_BOTH + + +def main(): + + # make the application quit when the last window is closed + elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED) + + # Create the main app window + win = elm.StandardWindow("main", "My first window", + autodel=True, size=(300, 200)) + + # Create a simple label + label = elm.Label(win, text="Hello World Python !", + size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) + win.resize_object_add(label) + label.show() + + # Show the window and start the efl main loop + win.show() + elm.run() + + +if __name__ == "main": + sys.exit(main())