Debian Codegraph @

get_site-packages.py

raw symbols SCIP
1 # pyOCD debugger
2 # Copyright (c) 2025 Arm Limited
3 # SPDX-License-Identifier: Apache-2.0
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 import os
18 import sysconfig
19
20 def get_site_packages() -> str:
21 """Get the path to the site-packages directory."""
22 path = sysconfig.get_path('purelib')
23 if not path:
24 raise RuntimeError("Could not determine site-packages directory")
25 return path
26
27 def main() -> None:
28 site_packages = get_site_packages()
29 # Check if running in GitHub Actions
30 github_env = os.getenv('GITHUB_ENV')
31
32 if github_env:
33 # If running in GitHub Actions, write to GITHUB_ENV
34 with open(github_env, "a") as env_file:
35 env_file.write(f"SITE_PACKAGES={site_packages}\n")
36 else:
37 # If not running in GitHub Actions, print the path
38 print(f"SITE_PACKAGES={site_packages}")
39
40 if __name__ == "__main__":
41 main()