[mousetrap/gnome3-wip: 174/240] Getting closer to working...



commit b991a1ca16cae8ad6abc64b6e13ff485d218d929
Author: Kevin Brown <kevin kevinbrown in>
Date:   Thu Jun 26 12:39:30 2014 -0400

    Getting closer to working...
    
    This updates Makefile.am to use the correct pathes for VPATH builds,
    which are required for distcheck to pass.  The files that are
    includes for distribution have also been updated and will probably
    be changed again before this is all set.
    
    The compilation step for locales has also been moved from install
    to build as it makes more sense and new files cannot be created
    during installation.  When compiling files, the directories will
    also be created automatically if they do not already exist.

 .gitignore  |    2 +-
 Makefile.am |   20 +++++++++++---------
 setup.py    |   31 +++++++++++++++++++++----------
 3 files changed, 33 insertions(+), 20 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 645597f..e266467 100644
--- a/.gitignore
+++ b/.gitignore
@@ -99,4 +99,4 @@ Makefile.in
 /Makefile
 /config.status
 
-no changes added to commit (use "git add" and/or "git commit -a")
+/py-compile
diff --git a/Makefile.am b/Makefile.am
index ea3bf9e..62eca3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,7 +13,9 @@
 
 mousetrapdir=$(pkgpythondir)
 
-nobase_mousetrap_SOURCES= \
+mousetrap_pythondir=$(pyexecdir)/mousetrap/
+
+mousetrap_python_PYTHON= \
        setup.py \
        src/mousetrap/__init__.py \
        src/mousetrap/plugins/__init__.py \
@@ -31,25 +33,25 @@ nobase_mousetrap_SOURCES= \
        src/mousetrap/tests/test_vision.py \
        src/mousetrap/tests/run_python_tests.py \
        src/mousetrap/gui.py \
-       src/mousetrap/config.py \
-       src/mousetrap/locale/en/LC_MESSAGES/mousetrap.po
+       src/mousetrap/config.py
 
-nobase_mousetrap_DATA= \
+EXTRA_DIST= \
        src/mousetrap/haars/haarcascade_mcs_righteye.xml \
        src/mousetrap/haars/haarcascade_mcs_lefteye.xml \
        src/mousetrap/haars/haarcascade_frontalface_default.xml \
        src/mousetrap/haars/haarcascade_mcs_nose.xml \
        src/mousetrap/haars/haarcascade_eye.xml \
-       src/mousetrap/mousetrap.yaml
+       src/mousetrap/mousetrap.yaml \
+       src/mousetrap/locale/en/LC_MESSAGES/mousetrap.po
 
 all-local:
-       $(PYTHON) setup.py build
+       $(PYTHON) $(srcdir)/setup.py build --build-base $(builddir)/build --verbose
 
 install-exec-local:
-       $(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix)
+       $(PYTHON) $(srcdir)/setup.py install --prefix=$(DESTDIR)$(prefix)
 
 uninstall-local:
-       rm -rf $(DESTDIR)$(libdir)/python*/site-packages/*mousetrap*
+       rm -rf $(DESTDIR)$(libdir)/python*/site-packages/mousetrap*
 
 clean-local:
-       $(PYTHON) setup.py clean --all
+       $(PYTHON) $(srcdir)/setup.py clean --all
diff --git a/setup.py b/setup.py
index 9a91d0f..74521a3 100644
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,13 @@
 from setuptools import setup, find_packages
+from distutils.command.build import build
 from setuptools.command.egg_info import egg_info
-from setuptools.command.install import install
 import glob
 import os
 import sys
 
 
-SRC_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "src"))
+SRC_PATH = os.path.join(os.path.dirname(__file__), "src")
+ABS_SRC_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "src"))
 
 sys.path.append(SRC_PATH)
 
@@ -110,7 +111,7 @@ The installation not work as expected without this dependency.
         egg_info.run(self)
 
 
-class InstallCommand(install):
+class BuildCommand(build):
 
     def run(self):
         from subprocess import Popen
@@ -119,7 +120,8 @@ class InstallCommand(install):
 
         program = "msgfmt"
 
-        LOCALE_PATH = "src/mousetrap/locale"
+        LOCALE_PATH = "%s/mousetrap/locale" % SRC_PATH
+        DEST_PATH = "%s/mousetrap/locale" % self.build_base
 
         root, directories, files = os.walk(LOCALE_PATH).next()
 
@@ -127,7 +129,11 @@ class InstallCommand(install):
 
         for language_code in language_codes:
             message_file = os.path.join(LOCALE_PATH, language_code, "LC_MESSAGES", "mousetrap.po")
-            compiled_file = os.path.join(LOCALE_PATH, language_code, "LC_MESSAGES", "mousetrap.mo")
+            compiled_file = os.path.join(DEST_PATH, language_code, "LC_MESSAGES", "mousetrap.mo")
+
+            if not os.path.exists(os.path.dirname(compiled_file)):
+                sys.stdout.write("Creating %s\n" % os.path.dirname(compiled_file))
+                os.makedirs(os.path.dirname(compiled_file))
 
             arguments = [message_file, "--output-file", compiled_file]
 
@@ -145,7 +151,7 @@ class InstallCommand(install):
             else:
                 sys.stdout.write(" [FAIL]\n")
 
-        install.run(self)
+        build.run(self)
 
 
 setup(
@@ -155,13 +161,13 @@ setup(
     license="GPL",
     include_package_data=True,
     install_requires=requirements,
-    packages=find_packages("src"),
+    packages=find_packages(SRC_PATH),
     cmdclass={
+        "build": BuildCommand,
         "egg_info": EggInfoCommand,
-        "install": InstallCommand,
     },
     package_dir={
-        "": "src",
+        "": SRC_PATH,
     },
     entry_points={
         "console_scripts": [
@@ -173,5 +179,10 @@ setup(
         "License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
         "Programming Language :: Python :: 2",
         "Programming Language :: Python :: 2.7",
-    ]
+    ],
+    options={
+        "egg_info": {
+            "egg_base": ".",
+        }
+    },
 )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]