Coverage for /pythoncovmergedfiles/medio/medio/src/python-crc32c/src/google_crc32c/__config__.py: 39%

18 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-09-25 06:41 +0000

1# Copyright 2018 Google LLC 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# https://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15import os 

16import sys 

17 

18import pkg_resources 

19 

20 

21def modify_path(): 

22 """Modify the module search path.""" 

23 # Only modify path on Windows. 

24 if os.name != "nt": 

25 return 

26 

27 path = os.environ.get("PATH") 

28 if path is None: 

29 return 

30 

31 try: 

32 extra_dll_dir = pkg_resources.resource_filename("google_crc32c", "extra-dll") 

33 if os.path.isdir(extra_dll_dir): 

34 # Python 3.6, 3.7 use path 

35 os.environ["PATH"] = path + os.pathsep + extra_dll_dir 

36 # Python 3.8+ uses add_dll_directory. 

37 if sys.version_info[0] == 3 and sys.version_info[1] >= 8: 

38 os.add_dll_directory(extra_dll_dir) 

39 except ImportError: 

40 pass 

41 

42modify_path()