Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/scikit_learn-1.4.dev0-py3.8-linux-x86_64.egg/sklearn/__check_build/__init__.py: 33%

18 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-12 06:31 +0000

1""" Module to give helpful messages to the user that did not 

2compile scikit-learn properly. 

3""" 

4import os 

5 

6INPLACE_MSG = """ 

7It appears that you are importing a local scikit-learn source tree. For 

8this, you need to have an inplace install. Maybe you are in the source 

9directory and you need to try from another location.""" 

10 

11STANDARD_MSG = """ 

12If you have used an installer, please check that it is suited for your 

13Python version, your operating system and your platform.""" 

14 

15 

16def raise_build_error(e): 

17 # Raise a comprehensible error and list the contents of the 

18 # directory to help debugging on the mailing list. 

19 local_dir = os.path.split(__file__)[0] 

20 msg = STANDARD_MSG 

21 if local_dir == "sklearn/__check_build": 

22 # Picking up the local install: this will work only if the 

23 # install is an 'inplace build' 

24 msg = INPLACE_MSG 

25 dir_content = list() 

26 for i, filename in enumerate(os.listdir(local_dir)): 

27 if (i + 1) % 3: 

28 dir_content.append(filename.ljust(26)) 

29 else: 

30 dir_content.append(filename + "\n") 

31 raise ImportError("""%s 

32___________________________________________________________________________ 

33Contents of %s: 

34%s 

35___________________________________________________________________________ 

36It seems that scikit-learn has not been built correctly. 

37 

38If you have installed scikit-learn from source, please do not forget 

39to build the package before using it: run `python setup.py install` or 

40`make` in the source directory. 

41%s""" % (e, local_dir, "".join(dir_content).strip(), msg)) 

42 

43 

44try: 

45 from ._check_build import check_build # noqa 

46except ImportError as e: 

47 raise_build_error(e)