blob: 87335759680ee18a62dba24fe9155aabf77ace79 [file] [log] [blame]
Roman Okhrimenko977b3752022-03-31 14:40:48 +03001"""
2Copyright (c) 2019 Cypress Semiconductor Corporation
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
16
17import subprocess
18import sys
19
INFINEON\DovhalA3b578f32024-11-29 01:06:04 +020020package = 'edgeprotecttools'
Roman Okhrimenko977b3752022-03-31 14:40:48 +030021
22def find_cysectools(package_name):
23
24 """
25 Check if package exist in system and return its location if it does
26 """
27
28 pip_show = subprocess.Popen([sys.executable, '-m', 'pip', 'show', package],
29 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
30
31 stdout = pip_show.communicate()[0]
32 rc = pip_show.wait()
33
34 if (rc != 0):
35 print("No package with name " + package + " found")
36 exit(1)
37 else:
38 pip_show_info = stdout.decode("utf-8").splitlines()
39
40 for line in pip_show_info:
41 if 'Location:' in line:
42 location = line.replace('Location: ', '')
43
44 if sys.platform == 'win32':
45 return location.replace('\\','/')
46 else:
47 return location
48
49def main():
50 """
51 Call function and print output
52 """
53 cysecuretools_path = find_cysectools(package)
54
55 print(cysecuretools_path)
56
57if __name__ == "__main__":
58 main()