in tensorflow_examples/lite/model_maker/pip_package/setup_util.py [0:0]
def _prepare_nightly(self):
"""Prepares nightly and gets extra setup config.
For nightly, tflite-model-maker will pack `tensorflowjs` python source code.
TODO(tianlin): tensorflowjs pip requires stable tensorflow instead of
nightly,
which conflicts with tflite-model-maker-nightly. Thus, we include its python
code directly.
Returns:
dict: extra package_data.
"""
tfjs_git = 'https://github.com/tensorflow/tfjs'
tfjs_path = pathlib.Path(__file__).with_name('tfjs')
# Remove existing tfjs and git clone.
if tfjs_path.exists():
shutil.rmtree(str(tfjs_path), ignore_errors=True)
cmd = ['git', 'clone', tfjs_git, str(tfjs_path)]
print('Running git clone: {}'.format(cmd))
subprocess.check_call(cmd)
# Copy `tensorflowjs` python code, and release with tflite-model-maker
src_folder = str(
tfjs_path.joinpath('tfjs-converter', 'python', 'tensorflowjs'))
dst_folder = str(self.build_dir.joinpath('tensorflowjs'))
shutil.copytree(
src_folder,
dst_folder,
ignore=lambda _, names: set(s for s in names if s.endswith('_test.py')))
return {'tensorflowjs/op_list': ['*.json']}