Debian Codegraph @

setup.py

raw symbols SCIP
1 # pyOCD debugger
2 # Copyright (c) 2012-2020 Arm Limited
3 # Copyright (c) 2021 Chris Reed
4 # SPDX-License-Identifier: Apache-2.0
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 import os
19 from setuptools import setup
20 import zipfile
21 from pathlib import Path
22
23 # Get the directory containing this setup.py. Even though full paths are used below, we must
24 # chdir in order for setuptools-scm to successfully pick up the version.
25 SCRIPT_DIR = Path(__file__).parent.resolve()
26 os.chdir(SCRIPT_DIR)
27
28 # Build zip of SVD files.
29 #
30 # The SVD files are stored individually in the data/ directory only in the repo. For both sdist and
31 # wheel, the svd_data.zip file is used rather than including the data directory. Thus, this setup
32 # script needs to skip building svd_data.zip if the data/ directory is not present.
33 svd_dir_path = SCRIPT_DIR / "pyocd" / "debug" / "svd"
34 svd_data_dir_path = svd_dir_path / "data"
35 svd_zip_path = svd_dir_path / "svd_data.zip"
36 if svd_data_dir_path.exists():
37 with zipfile.ZipFile(svd_zip_path, 'w', zipfile.ZIP_DEFLATED) as svd_zip:
38 for svd_file in sorted(svd_data_dir_path.iterdir()):
39 svd_zip.write(svd_file, svd_file.name)
40 elif not svd_zip_path.exists():
41 raise RuntimeError("neither the source SVD data directory nor built svd_data.zip exist")
42
43 setup()