diff --git a/mindspore/dataset/engine/cache_admin.py b/mindspore/dataset/engine/cache_admin.py new file mode 100644 index 0000000000..4d528afd1b --- /dev/null +++ b/mindspore/dataset/engine/cache_admin.py @@ -0,0 +1,33 @@ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +""" +This is the entrance to start the cache service +""" + +import os +import stat +import sys +import mindspore + +def main(): + """Entry point for cache service""" + cache_admin_dir = os.path.join(os.path.dirname(mindspore.__file__), "bin") + os.chdir(cache_admin_dir) + cache_admin = os.path.join(cache_admin_dir, "cache_admin") + cache_server = os.path.join(cache_admin_dir, "cache_server") + os.chmod(cache_admin, stat.S_IRWXU) + os.chmod(cache_server, stat.S_IRWXU) + cmd = cache_admin + " " + " ".join(sys.argv[1:]) + os.system(cmd) diff --git a/setup.py b/setup.py index b0d64b728d..744694dac2 100644 --- a/setup.py +++ b/setup.py @@ -129,6 +129,7 @@ package_data = { '*.so*', '*.pyd', '*.dll', + 'bin/*', 'lib/*.so*', 'lib/*.a', 'lib/*.dylib*', @@ -161,24 +162,6 @@ def update_permissions(path): file_fullpath = os.path.join(dirpath, filename) os.chmod(file_fullpath, stat.S_IREAD) -def bin_files(): - """ - Gets the binary files to be installed. - """ - data_files = [] - binary_files = [] - - cache_server_bin = os.path.join('mindspore', 'bin', 'cache_server') - if not os.path.exists(cache_server_bin): - return data_files - binary_files.append(cache_server_bin) - cache_admin_bin = os.path.join('mindspore', 'bin', 'cache_admin') - if not os.path.exists(cache_admin_bin): - return data_files - binary_files.append(cache_admin_bin) - data_files.append(('bin', binary_files)) - return data_files - class EggInfo(egg_info): """Egg info.""" @@ -215,7 +198,6 @@ setup( 'framework that could be used for mobile, edge and cloud scenarios.', long_description="\n\n".join([readme, release]), long_description_content_type="text/markdown", - data_files=bin_files(), packages=find_packages(), package_data=package_data, include_package_data=True, @@ -223,6 +205,11 @@ setup( 'egg_info': EggInfo, 'build_py': BuildPy, }, + entry_points={ + 'console_scripts': [ + 'cache_admin=mindspore.dataset.engine.cache_admin:main', + ], + }, python_requires='>=3.7', install_requires=required_package, classifiers=[