ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=a053bb97575e83ea8d609fad6f06c7c3fa0818c0

commit a053bb97575e83ea8d609fad6f06c7c3fa0818c0
Author: Andy Williams <a...@andywilliams.me>
Date:   Tue Feb 7 00:05:06 2017 +0000

    build: add trivial python project support
---
 src/lib/Makefile.am                 |  1 +
 src/lib/edi_build_provider.c        |  4 +++
 src/lib/edi_build_provider_python.c | 55 +++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)

diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index eb2c06f..e9b7011 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -21,6 +21,7 @@ includesdir = $(includedir)/edi-@VMAJ@
 libedi_la_SOURCES = \
 edi_private.h \
 edi_build_provider_make.c \
+edi_build_provider_python.c \
 edi_build_provider.c \
 edi_builder.c \
 edi_create.c \
diff --git a/src/lib/edi_build_provider.c b/src/lib/edi_build_provider.c
index 6051d2d..5e92977 100644
--- a/src/lib/edi_build_provider.c
+++ b/src/lib/edi_build_provider.c
@@ -8,6 +8,7 @@
 #include "edi_private.h"
 
 extern Edi_Build_Provider _edi_build_provider_make;
+extern Edi_Build_Provider _edi_build_provider_python;
 
 EAPI Edi_Build_Provider *edi_build_provider_for_project_get()
 {
@@ -22,6 +23,9 @@ EAPI Edi_Build_Provider 
*edi_build_provider_for_project_path_get(const char *pat
    if (_edi_build_provider_make.path_supported_is(path))
      return &_edi_build_provider_make;
 
+   if (_edi_build_provider_python.path_supported_is(path))
+     return &_edi_build_provider_python;
+
    return NULL;
 }
 
diff --git a/src/lib/edi_build_provider_python.c 
b/src/lib/edi_build_provider_python.c
new file mode 100644
index 0000000..cb1e2ab
--- /dev/null
+++ b/src/lib/edi_build_provider_python.c
@@ -0,0 +1,55 @@
+#ifdef HAVE_CONFIG
+# include "config.h"
+#endif
+
+#include <unistd.h>
+#include <Ecore.h>
+#include <Ecore_File.h>
+
+#include "Edi.h"
+
+#include "edi_private.h"
+
+static Eina_Bool
+_relative_path_exists(const char *base, const char *relative)
+{
+   char *path;
+   Eina_Bool ret;
+
+   path = edi_path_append(base, relative);
+   ret = ecore_file_exists(path);
+
+   free(path);
+   return ret;
+}
+
+static Eina_Bool
+_python_project_supported(const char *path)
+{
+   return _relative_path_exists(path, "requirements.txt");
+}
+
+static Eina_Bool
+_python_file_hidden_is(const char *file)
+{
+   if (!file || strlen(file) == 0)
+     return EINA_FALSE;
+
+   if (eina_str_has_extension(file, ".pyc") || eina_str_has_extension(file, 
".pyo"))
+     return EINA_TRUE;
+
+   return EINA_FALSE;
+}
+
+static void
+_python_test(void)
+{
+   chdir(edi_project_get());
+   ecore_exe_pipe_run("python -m unittest", ECORE_EXE_PIPE_READ_LINE_BUFFERED 
| ECORE_EXE_PIPE_READ |
+                              ECORE_EXE_PIPE_ERROR_LINE_BUFFERED | 
ECORE_EXE_PIPE_ERROR |
+                              ECORE_EXE_PIPE_WRITE | ECORE_EXE_USE_SH, NULL);
+}
+
+Edi_Build_Provider _edi_build_provider_python =
+   {"python", _python_project_supported, _python_file_hidden_is,
+     NULL, _python_test, NULL};

-- 


Reply via email to