platform/dev: add chromite import for internal use in package.
If dev is called as a package, __init__.py can offer a chromite dependency for
it. But __init__.py cannot handle the internal calls.
dev/
__init__.py
A.py
B.py
C.py import package dev, and call functions in A.py, it will succeed.
But if B.py directly calls 'python A.py', or import A to call its funcions, it
will fail.
This CL handles this case.
BUG=chromium:636467
TEST=locally run python cros_update.py, cros_update_progress.py. Run cros
flash.
Change-Id: I69d931b3a20a72a9e33f121f64382004f527cd42
Reviewed-on: https://chromium-review.googlesource.com/375040
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/setup_chromite.py b/setup_chromite.py
new file mode 100644
index 0000000..8bd2d38
--- /dev/null
+++ b/setup_chromite.py
@@ -0,0 +1,18 @@
+# Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Set up syspath to import chromite."""
+
+from __future__ import print_function
+
+import os
+import sys
+
+# Make sure that chromite is available to import.
+_path = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
+ os.pardir)
+if _path not in sys.path:
+ sys.path.insert(0, os.path.abspath(_path))
+
+del _path