Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

venv for Python setup #653

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
libraries/**/Cargo.lock
target/
/build/
/py_virtual_env/

# Local installation of elf2tab.
/elf2tab/
Expand Down
4 changes: 2 additions & 2 deletions deploy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2019 Google LLC
#!py_virtual_env/bin/python3
# Copyright 2019-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.
Expand Down
2 changes: 1 addition & 1 deletion docs/boards/nrf52840_mdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ After general setup, you still need these steps:
1. Run the script:
```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
Expand Down
6 changes: 3 additions & 3 deletions docs/boards/nrf52840dk.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ Afterwards, you can upgrade the other partition with
```shell
# Board A -> B
./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
./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,
Expand All @@ -81,5 +81,5 @@ for example:
```shell
./deploy.py --board=nrf52840dk_opensk_a --opensk --version=0 --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
```
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ colorama
tqdm
cryptography
fido2 >= 1.0.0

# Tests
pylint
hid
7 changes: 5 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# Ensure the script doesn't fail on Github workflows
export TERM=${TERM:-vt100}
done_text="$(tput bold)DONE.$(tput sgr0)"
PY_VENV_NAME=py_virtual_env
PIP="$PY_VENV_NAME"/bin/pip

set -e

Expand All @@ -31,7 +33,8 @@ check_command () {
fi
}
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
source tools/gen_key_materials.sh
Expand All @@ -40,7 +43,7 @@ generate_crypto_materials N
rustup show
# Nightly is used for testing and fuzzing libraries
rustup install nightly
pip3 install --upgrade -r requirements.txt
"$PIP" install --upgrade -r requirements.txt

# Install dependency to create applications.
mkdir -p elf2tab
Expand Down
1 change: 0 additions & 1 deletion tools/authenticator_config.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion tools/configure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!py_virtual_env/bin/python3
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion tools/deploy_partition.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
# Copyright 2020-2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions tools/run_pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
# Ensure we are at the project root directory
cd $(readlink -f $(dirname $0))/..

export PATH="py_virtual_env/bin:$PATH"

pylint --score=n `git ls-files --deduplicate --exclude-standard --full-name '*.py'`
13 changes: 13 additions & 0 deletions tools/vendor_hid_test.py
Original file line number Diff line number Diff line change
@@ -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."""
import fido2
from fido2 import ctap
Expand Down
Loading