Skip to content

Commit

Permalink
[fix] Try to find data directory beside lib directory first
Browse files Browse the repository at this point in the history
  • Loading branch information
csordasmarton committed Aug 6, 2021
1 parent 9c0ed83 commit 8720e9e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions codechecker_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,25 @@ def get_data_files_dir_path():
# If it's not an internal package (pypi package), try to find the data
# directory.
import sysconfig
data_dir_paths = set(sysconfig.get_path("data", s)
for s in sysconfig.get_scheme_names())
data_dir_paths = [
# Try to find the data directory beside the lib directory.
# E.g.: /usr/local/lib/python3.8/dist-packages/codechecker_common/*.py
os.path.abspath(os.path.join(__file__, *[os.path.pardir] * 5)),

# Automatically try to find data directory if it can be found on other
# places.
*set(sysconfig.get_path("data", s)
for s in sysconfig.get_scheme_names())]

for dir_path in data_dir_paths:
data_dir_path = os.path.join(dir_path, 'share', 'codechecker')
if os.path.exists(data_dir_path):
return data_dir_path

print("Failed to get CodeChecker data files directory path in: ",
data_dir_paths)
sys.exit(1)


def main():
"""
Expand Down

0 comments on commit 8720e9e

Please sign in to comment.