Skip to content

Commit b04c481

Browse files
Finish migrating to pyproject.toml
1 parent e5de1b9 commit b04c481

File tree

13 files changed

+62
-96
lines changed

13 files changed

+62
-96
lines changed

.github/workflows/basic_checks.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,16 @@ jobs:
169169
sudo apt-get update
170170
sudo apt-get install -y python3-venv
171171
172-
-
173-
name: install dependencies
172+
- name: Install Python packages
174173
run: |
175174
python3 -m venv venv
176175
source venv/bin/activate
177-
pip install -r tools/requirements.txt
178-
pip install -r tools/python/python_tests/requirements.txt
176+
pip install -e ./tools[unit-tests]
179177
180-
-
181-
name: Python Tests
178+
- name: Python Tests
182179
run: |
183180
source venv/bin/activate
184-
cd tools/python
181+
cd tools
185182
./run_python_tests.sh
186183
187184
check-cmsis-mcu-descriptions-matches-target-list:
@@ -195,18 +192,18 @@ jobs:
195192
sudo apt-get update
196193
sudo apt-get install -y python3-venv
197194
198-
- name: install dependencies
195+
- name: Install Python packages
199196
run: |
200197
python3 -m venv venv
201198
source venv/bin/activate
202-
pip install -r tools/requirements.txt
199+
pip install -e ./tools
203200
204201
- name: Verify that cmsis_mcu_descriptions.json5 is in sync with targets.json5
205202
run: |
206203
source venv/bin/activate
207204
cd tools/python
208-
python -m mbed_tools.cli.main cmsis-mcu-descr find-unused
209-
python -m mbed_tools.cli.main cmsis-mcu-descr check-missing
205+
mbed-tools cmsis-mcu-descr find-unused
206+
mbed-tools cmsis-mcu-descr check-missing
210207
211208
212209
pin-validation:

.github/workflows/test_building_multiple_executables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
# Note: pip>=20.3 is needed to install dependencies of cysecuretools
1515
run: |
1616
python3 -m pip install --upgrade pip
17-
python3 -m pip install -r tools/requirements.txt
17+
python3 -m pip install -e ./tools
1818
1919
# Note: For this CI job we use MBED_CREATE_PYTHON_VENV=FALSE so that we can make sure
2020
# this mode works.

tools/cmake/mbed-run-greentea-test.in.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ set(MBEDHTRUN_ARGS --skip-flashing @MBED_HTRUN_ARGUMENTS@) # filled in by config
1414

1515
# Print out command
1616
string(REPLACE ";" " " MBEDHTRUN_ARGS_FOR_DISPLAY "${MBEDHTRUN_ARGS}")
17-
message("Executing: @Python3_EXECUTABLE@ -m mbed_host_tests.mbedhtrun ${MBEDHTRUN_ARGS_FOR_DISPLAY}")
17+
message("Executing: mbedhtrun ${MBEDHTRUN_ARGS_FOR_DISPLAY}")
1818

1919
execute_process(
20-
COMMAND @Python3_EXECUTABLE@ -m mbed_host_tests.mbedhtrun ${MBEDHTRUN_ARGS}
21-
WORKING_DIRECTORY "@mbed-os_SOURCE_DIR@/tools/python"
20+
COMMAND mbedhtrun ${MBEDHTRUN_ARGS}
2221
COMMAND_ERROR_IS_FATAL ANY)

tools/cmake/mbed_generate_configuration.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ if(MBED_NEED_TO_RECONFIGURE)
8282
# Make sure an old config file doesn't stick around
8383
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/mbed_config.cmake)
8484

85-
set(MBEDTOOLS_CONFIGURE_COMMAND ${Python3_EXECUTABLE}
86-
-m mbed_tools.cli.main
85+
set(MBEDTOOLS_CONFIGURE_COMMAND mbed-tools
8786
-v -v # without at least -v, warnings (e.g. "you have tried to override a nonexistent parameter") do not get printed
8887
configure
8988
-t GCC_ARM # GCC_ARM is currently the only supported toolchain
@@ -96,7 +95,6 @@ if(MBED_NEED_TO_RECONFIGURE)
9695

9796
execute_process(
9897
COMMAND ${MBEDTOOLS_CONFIGURE_COMMAND}
99-
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../python
10098
RESULT_VARIABLE MBEDTOOLS_CONFIGURE_RESULT
10199
OUTPUT_VARIABLE MBEDTOOLS_CONFIGURE_OUTPUT
102100
ERROR_VARIABLE MBEDTOOLS_CONFIGURE_ERROR_OUTPUT
@@ -106,7 +104,7 @@ if(MBED_NEED_TO_RECONFIGURE)
106104

107105
if((NOT MBEDTOOLS_CONFIGURE_RESULT EQUAL 0) OR (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mbed_config.cmake))
108106
string(JOIN " " MBEDTOOLS_COMMAND_SPC_SEP ${MBEDTOOLS_CONFIGURE_COMMAND})
109-
message(FATAL_ERROR "mbedtools configure failed! Cannot build this project. Command was cd ${CMAKE_CURRENT_LIST_DIR}/../python && ${MBEDTOOLS_COMMAND_SPC_SEP}")
107+
message(FATAL_ERROR "mbedtools configure failed! Cannot build this project. Command was ${MBEDTOOLS_COMMAND_SPC_SEP} [note that you need to activate the Mbed OS virtualenv to run this command]")
110108
endif()
111109

112110
endif()

tools/cmake/mbed_python_interpreter.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if(MBED_CREATE_PYTHON_VENV)
8484
COMMAND_ERROR_IS_FATAL ANY
8585
)
8686
execute_process(
87-
COMMAND ${Python3_EXECUTABLE} -m pip install ${MBED_CE_TOOLS_BASE_DIR}
87+
COMMAND ${Python3_EXECUTABLE} -m pip install -e ${MBED_CE_TOOLS_BASE_DIR}
8888
COMMAND_ERROR_IS_FATAL ANY
8989
)
9090

@@ -106,6 +106,6 @@ else()
106106
check_python_package(mbed_tools.cli.cmsis_mcu_descr HAVE_MBED_CE_TOOLS)
107107

108108
if(NOT HAVE_MBED_CE_TOOLS)
109-
message(FATAL_ERROR "Did not detect the Mbed CE Python tools installed into the python interpreter ${Python3_EXECUTABLE}. Install them with a command like: ${Python3_EXECUTABLE} -m pip install ${MBED_CE_TOOLS_BASE_DIR}")
109+
message(FATAL_ERROR "Did not detect the Mbed CE Python tools installed into the python interpreter ${Python3_EXECUTABLE}. Install them with a command like: ${Python3_EXECUTABLE} -m pip install -e ${MBED_CE_TOOLS_BASE_DIR}")
110110
endif()
111111
endif()

tools/pyproject.toml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,32 @@ dependencies = [
5555
"cysecuretools~=6.0",
5656
]
5757

58+
[project.optional-dependencies]
59+
unit-tests = [
60+
"pytest",
61+
"factory_boy",
62+
"requests-mock",
63+
"mock",
64+
"coverage",
65+
66+
# Even though beautifulsoup4 and lxml are only used by the mac version
67+
# of mbed ls tools, they're needed on all platforms for its unit test.
68+
"beautifulsoup4",
69+
"lxml"
70+
]
71+
5872
[tool.hatch.build.targets.wheel]
59-
packages = ["python"]
73+
packages = [
74+
"python/mbed_host_tests",
75+
"python/mbed_lstools",
76+
"python/mbed_os_tools",
77+
"python/mbed_tools",
78+
"python/memap",
79+
"python/scancode_evaluate",
80+
]
6081

6182
[project.scripts]
83+
mbedhtrun = "mbed_host_tests.mbedhtrun:main"
84+
mbedls = "mbed_lstools.main:mbedls_main"
85+
mbed-tools = "mbed_tools.cli.main:cli"
6286
memap = "memap.memap:main"

tools/python/scancode_evaluate/scancode_evaluate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def parse_args():
212212
return parser.parse_args()
213213

214214

215-
if __name__ == "__main__":
215+
def main():
216216
init_logger()
217217
args = parse_args()
218218
if pathlib.Path(args.scancode_output_path).is_file():
@@ -224,3 +224,6 @@ def parse_args():
224224
else:
225225
userlog.warning("Could not find the scancode json file")
226226
sys.exit(ReturnCode.ERROR.value)
227+
228+
if __name__ == "__main__":
229+
main()

tools/python_tests/requirements.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

tools/python_tests/scancode_evaluate/scancode_test/scancode_test_2.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
],
3232
"files":[
3333
{
34-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test.h",
34+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test.h",
3535
"type":"file",
3636
"licenses":[
3737
{
@@ -141,7 +141,7 @@
141141
]
142142
},
143143
{
144-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test2.h",
144+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test2.h",
145145
"type":"file",
146146
"licenses":[
147147
{
@@ -251,7 +251,7 @@
251251
]
252252
},
253253
{
254-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test3.h",
254+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test3.h",
255255
"type":"file",
256256
"licenses":[
257257
{
@@ -361,7 +361,7 @@
361361
]
362362
},
363363
{
364-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test4.h",
364+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test4.h",
365365
"type":"file",
366366
"licenses":[
367367
{
@@ -471,7 +471,7 @@
471471
]
472472
},
473473
{
474-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test5.c",
474+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test5.c",
475475
"type":"file",
476476
"licenses":[
477477
{
@@ -548,7 +548,7 @@
548548
]
549549
},
550550
{
551-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test6.c",
551+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test6.c",
552552
"type":"file",
553553
"licenses":[
554554
{
@@ -625,7 +625,7 @@
625625
]
626626
},
627627
{
628-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test7.c",
628+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test7.c",
629629
"type":"file",
630630
"licenses":[
631631
{
@@ -702,7 +702,7 @@
702702
]
703703
},
704704
{
705-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test8.c",
705+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test8.c",
706706
"type":"file",
707707
"licenses":[
708708
{

tools/python_tests/scancode_evaluate/scancode_test/scancode_test_3.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
],
2929
"files":[
3030
{
31-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test.h",
31+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test.h",
3232
"type":"file",
3333
"licenses":[
3434

@@ -41,7 +41,7 @@
4141
]
4242
},
4343
{
44-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test3.h",
44+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test3.h",
4545
"type":"file",
4646
"licenses":[
4747
{
@@ -85,7 +85,7 @@
8585
]
8686
},
8787
{
88-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test4.h",
88+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test4.h",
8989
"type":"file",
9090
"licenses":[
9191
{
@@ -129,7 +129,7 @@
129129
]
130130
},
131131
{
132-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test5.h",
132+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test5.h",
133133
"type":"file",
134134
"licenses":[
135135
{
@@ -173,7 +173,7 @@
173173
]
174174
},
175175
{
176-
"path":"tools/python/python_tests/scancode_evaluate/scancode_test/test6.h",
176+
"path":"tools/python_tests/scancode_evaluate/scancode_test/test6.h",
177177
"type":"file",
178178
"licenses":[
179179
{

0 commit comments

Comments
 (0)