put the checks for package is installed or not

This commit is contained in:
navjot 2020-11-24 17:05:40 +05:30
parent 54f56cc605
commit 7b6959a03b
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C

View File

@ -71,7 +71,7 @@ def detectPrereqs(missing=True):
def prereqToPackages(): def prereqToPackages():
print('line....................73') # print('line....................73')
if not detectPrereqs(): if not detectPrereqs():
return return
print("%s %s" % ( print("%s %s" % (
@ -80,7 +80,7 @@ def prereqToPackages():
def compilerToPackages(): def compilerToPackages():
print('line....................82') # print('line....................82')
if not detectOS() in COMPILING: if not detectOS() in COMPILING:
return return
print("%s %s" % ( print("%s %s" % (
@ -88,7 +88,7 @@ def compilerToPackages():
def testCompiler(): def testCompiler():
print('line.......................90') # print('line.......................90')
if not HAVE_SETUPTOOLS: if not HAVE_SETUPTOOLS:
# silent, we can't test without setuptools # silent, we can't test without setuptools
return True return True
@ -141,29 +141,41 @@ if prereqs:
# Install the system dependencies of optional extras_require components # Install the system dependencies of optional extras_require components
OPSYS = detectOS() OPSYS = detectOS()
CMD = PACKAGE_MANAGER[OPSYS] if OPSYS in PACKAGE_MANAGER else 'UNKNOWN_INSTALLER' CMD = PACKAGE_MANAGER[OPSYS] if OPSYS in PACKAGE_MANAGER else 'UNKNOWN_INSTALLER'
print('EXTRAS_REQUIRE_DEPS: ', EXTRAS_REQUIRE_DEPS)
for lhs, rhs in EXTRAS_REQUIRE.items(): for lhs, rhs in EXTRAS_REQUIRE.items():
print('lhs, rhs : ', lhs, rhs) # print('lhs, rhs : ', lhs, rhs)
if OPSYS is None: if OPSYS is None:
break break
# print('WWGG: ', any([EXTRAS_REQUIRE_DEPS[x][OPSYS] for x in rhs if x in EXTRAS_REQUIRE_DEPS]))
if rhs and any([ if rhs and any([
EXTRAS_REQUIRE_DEPS[x][OPSYS] EXTRAS_REQUIRE_DEPS[x][OPSYS]
for x in rhs for x in rhs
if x in EXTRAS_REQUIRE_DEPS if x in EXTRAS_REQUIRE_DEPS
]): ]):
rhs_cmd = ''.join([ # print('CMD: ', CMD)
CMD, # print('[xx for xx in EXTRAS_REQUIRE_DEPS[x][OPSYS]]: ', [xx for xx in EXTRAS_REQUIRE_DEPS[x][OPSYS]])
' ', # print('[]: ', [for x in rhs if x in EXTRAS_REQUIRE_DEPS])
' '.join([ try:
''. join([ import lhs
xx for xx in EXTRAS_REQUIRE_DEPS[x][OPSYS] # print('Try pass <<<<<<<<<<<<<Sucess>>>>>>>>>>>>>>>>')
]) except Exception as e:
for x in rhs # print('Except <<<<<<<<<<<<<<Fail>>>>>>>>>>>>>>>>>>>')
if x in EXTRAS_REQUIRE_DEPS rhs_cmd = ''.join([
]), CMD,
]) ' ',
print( ' '.join([
"Optional dependency `pip install .[{}]` would require `{}`" ''. join([
" to be run as root".format(lhs, rhs_cmd)) xx for xx in EXTRAS_REQUIRE_DEPS[x][OPSYS]
])
for x in rhs
if x in EXTRAS_REQUIRE_DEPS
]),
])
print('MMMMMMM: ', lhs, rhs_cmd)
print(
"Optional dependency `pip install .[{}]` would require `{}`"
" to be run as root".format(lhs, rhs_cmd))
if (not compiler or prereqs) and OPSYS in PACKAGE_MANAGER: if (not compiler or prereqs) and OPSYS in PACKAGE_MANAGER:
print("You can install the missing dependencies by running, as root:") print("You can install the missing dependencies by running, as root:")