Просмотр исходного кода

add coriolis-dbsync command

* add __init__.py in cmd folder
* add coriolis-dbsync command
* move resources under coriolis folder
* modify setup.py to build the write_data binary on Linux
* add MANIFEST.in to include the binary
Gabriel Adrian Samfira 8 лет назад
Родитель
Сommit
77c44071ed
7 измененных файлов с 18 добавлено и 5 удалено
  1. 1 0
      MANIFEST.in
  2. 0 0
      coriolis/cmd/__init__.py
  3. 0 0
      coriolis/resources/makefile
  4. 0 0
      coriolis/resources/write_data.c
  5. 2 5
      coriolis/utils.py
  6. 1 0
      setup.cfg
  7. 14 0
      setup.py

+ 1 - 0
MANIFEST.in

@@ -0,0 +1 @@
+include coriolis/resources/write_data

+ 0 - 0
coriolis/cmd/__init__.py


+ 0 - 0
resources/makefile → coriolis/resources/makefile


+ 0 - 0
resources/write_data.c → coriolis/resources/write_data.c


+ 2 - 5
coriolis/utils.py

@@ -288,12 +288,9 @@ def get_ssl_cert_thumbprint(context, host, port=443, digest_algorithm="sha1"):
     return x509.digest('sha1').decode()
 
 
-def _get_base_dir():
-    return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
-
 def get_resources_dir():
-    return os.path.join(_get_base_dir(), "resources")
+    return os.path.join(
+        os.path.dirname(os.path.abspath(__file__)), "resources")
 
 
 def serialize_key(key, password=None):

+ 1 - 0
setup.cfg

@@ -28,6 +28,7 @@ console_scripts =
     coriolis-api = coriolis.cmd.api:main
     coriolis-conductor = coriolis.cmd.conductor:main
     coriolis-worker = coriolis.cmd.worker:main
+    coriolis-dbsync = coriolis.cmd.db_sync:main
 
 [wheel]
 universal = 1

+ 14 - 0
setup.py

@@ -1,6 +1,20 @@
 import setuptools
+import subprocess
+import platform
+import os
 
 
+def _compile_and_install():
+    if platform.system() != "Linux":
+        return
+    dirname = os.path.dirname(__file__)
+    resources = os.path.join(dirname, "coriolis", "resources")
+    if os.path.isdir(resources):
+        subprocess.check_call(
+            ["make"], cwd=resources, shell=True)
+
+
+_compile_and_install()
 setuptools.setup(
     setup_requires=['pbr>=1.8'],
     pbr=True)