未验证 提交 5143b0eb 编写于 作者: R risemeup1 提交者: GitHub

optimize setup.py under conda virtual environment (#48211)

* optimize setup.py for conda envir

* check python dependency

* optimize code after reviewed
上级 82cf1fad
......@@ -1379,10 +1379,41 @@ def get_setup_parameters():
)
def check_build_dependency():
missing_modules = '''Missing build dependency: {dependency}
Please run 'pip install -r python/requirements.txt' to make sure you have all the dependencies installed.
'''.strip()
with open(TOP_DIR + '/python/requirements.txt') as f:
build_dependencies = (
f.read().splitlines()
) # Specify the dependencies to install
python_dependcies_module = []
installed_packages = []
for dependency in build_dependencies:
python_dependcies_module.append(
re.sub("_|-", '', re.sub(r"==.*|>=.*|<=.*", '', dependency))
)
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
for r in reqs.split():
installed_packages.append(re.sub("_|-", '', r.decode().split('==')[0]))
for dependency in python_dependcies_module:
if dependency not in installed_packages:
raise RuntimeError(missing_modules.format(dependency=dependency))
def main():
# Parse the command line and check arguments before we proceed with building steps and setup
parse_input_command(filter_args_list)
# check build dependency
check_build_dependency()
# Execute the build process,cmake and make
if cmake_and_build:
build_steps()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册