venv for Python setup (#653)

* Python uses venv

* Small fixes to python calls
This commit is contained in:
kaczmarczyck
2023-11-07 05:13:21 +01:00
committed by GitHub
parent 67e3d46291
commit 778102712f
11 changed files with 33 additions and 11 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,7 @@
libraries/**/Cargo.lock libraries/**/Cargo.lock
target/ target/
/build/
/py_virtual_env/
# Local installation of elf2tab. # Local installation of elf2tab.
/elf2tab/ /elf2tab/

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!py_virtual_env/bin/python3
# Copyright 2019 Google LLC # Copyright 2019-2023 Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.

View File

@@ -19,7 +19,7 @@ After general setup, you still need these steps:
1. Run the script: 1. Run the script:
```shell ```shell
python3 uf2conv.py -c -f 0xada52840 -o target/opensk.uf2 target/nrf52840_mdk_dfu_merged.hex py_virtual_env/bin/python3 uf2conv.py -c -f 0xada52840 -o target/opensk.uf2 target/nrf52840_mdk_dfu_merged.hex
``` ```
1. Boot into DFU mode. Keep the user button pressed on your hardware while 1. Boot into DFU mode. Keep the user button pressed on your hardware while

View File

@@ -64,10 +64,10 @@ Afterwards, you can upgrade the other partition with
```shell ```shell
# Board A -> B # Board A -> B
./deploy.py --board=nrf52840dk_opensk_b --opensk --programmer=none --version=1 ./deploy.py --board=nrf52840dk_opensk_b --opensk --programmer=none --version=1
python3 -m tools.deploy_partition --board=nrf52840dk_opensk_b --version=1 py_virtual_env/bin/python3 -m tools.deploy_partition --board=nrf52840dk_opensk_b --version=1
# Board B -> A # Board B -> A
./deploy.py --board=nrf52840dk_opensk_a --opensk --programmer=none --version=1 ./deploy.py --board=nrf52840dk_opensk_a --opensk --programmer=none --version=1
python3 -m tools.deploy_partition --board=nrf52840dk_opensk_a --version=1 py_virtual_env/bin/python3 -m tools.deploy_partition --board=nrf52840dk_opensk_a --version=1
``` ```
respectively. You can only upgrade the partition that is not currently running, respectively. You can only upgrade the partition that is not currently running,
@@ -81,5 +81,5 @@ for example:
```shell ```shell
./deploy.py --board=nrf52840dk_opensk_a --opensk --version=0 --vendor-hid ./deploy.py --board=nrf52840dk_opensk_a --opensk --version=0 --vendor-hid
./deploy.py --board=nrf52840dk_opensk_b --opensk --programmer=none --version=1 --vendor-hid ./deploy.py --board=nrf52840dk_opensk_b --opensk --programmer=none --version=1 --vendor-hid
python3 -m tools.deploy_partition --board=nrf52840dk_opensk_b --version=1 --vendor-hid py_virtual_env/bin/python3 -m tools.deploy_partition --board=nrf52840dk_opensk_b --version=1 --vendor-hid
``` ```

View File

@@ -8,3 +8,7 @@ colorama
tqdm tqdm
cryptography cryptography
fido2 >= 1.0.0 fido2 >= 1.0.0
# Tests
pylint
hid

View File

@@ -16,6 +16,8 @@
# Ensure the script doesn't fail on Github workflows # Ensure the script doesn't fail on Github workflows
export TERM=${TERM:-vt100} export TERM=${TERM:-vt100}
done_text="$(tput bold)DONE.$(tput sgr0)" done_text="$(tput bold)DONE.$(tput sgr0)"
PY_VENV_NAME=py_virtual_env
PIP="$PY_VENV_NAME"/bin/pip
set -e set -e
@@ -31,7 +33,8 @@ check_command () {
fi fi
} }
check_command rustup " Follow the steps under https://rustup.rs/ to install it." check_command rustup " Follow the steps under https://rustup.rs/ to install it."
check_command pip3 python3 -m venv "$PY_VENV_NAME"
check_command "$PIP"
# Ensure we have certificates, keys, etc. so that the tests can run # Ensure we have certificates, keys, etc. so that the tests can run
source tools/gen_key_materials.sh source tools/gen_key_materials.sh
@@ -40,7 +43,7 @@ generate_crypto_materials N
rustup show rustup show
# Nightly is used for testing and fuzzing libraries # Nightly is used for testing and fuzzing libraries
rustup install nightly rustup install nightly
pip3 install --upgrade -r requirements.txt "$PIP" install --upgrade -r requirements.txt
# Install dependency to create applications. # Install dependency to create applications.
mkdir -p elf2tab mkdir -p elf2tab

1
tools/authenticator_config.py Executable file → Normal file
View File

@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Copyright 2023 Google LLC # Copyright 2023 Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!py_virtual_env/bin/python3
# Copyright 2020 Google LLC # Copyright 2020 Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");

1
tools/deploy_partition.py Executable file → Normal file
View File

@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Copyright 2020-2021 Google LLC # Copyright 2020-2021 Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -16,4 +16,6 @@
# Ensure we are at the project root directory # Ensure we are at the project root directory
cd $(readlink -f $(dirname $0))/.. cd $(readlink -f $(dirname $0))/..
export PATH="py_virtual_env/bin:$PATH"
pylint --score=n `git ls-files --deduplicate --exclude-standard --full-name '*.py'` pylint --score=n `git ls-files --deduplicate --exclude-standard --full-name '*.py'`

View File

@@ -1,3 +1,16 @@
# Copyright 2021-2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""These tests verify the functionality of the VendorHID interface.""" """These tests verify the functionality of the VendorHID interface."""
import fido2 import fido2
from fido2 import ctap from fido2 import ctap