Skip to content

Commit 0612f79

Browse files
committed
[cmake] Small tweaks
1 parent 7d3547e commit 0612f79

File tree

4 files changed

+55
-46
lines changed

4 files changed

+55
-46
lines changed

documentation/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (INEXOR_BUILD_DOCUMENTATION_USE_VENV)
2828
endif()
2929

3030
execute_process(
31-
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../helper/requirements_check/req_check.py requirements.txt
31+
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../helper/req_check.py requirements.txt
3232
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
3333
COMMAND_ERROR_IS_FATAL ANY
3434
)

example/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set_target_properties(
99
)
1010

1111
if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
12+
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "inexor-vulkan-renderer-example")
1213
target_compile_options(inexor-vulkan-renderer-example PRIVATE "/MP")
1314
set_target_properties(
1415
inexor-vulkan-renderer-example
@@ -27,5 +28,3 @@ target_link_libraries(
2728
PRIVATE
2829
inexor-vulkan-renderer
2930
)
30-
31-
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "inexor-vulkan-renderer-example")

helper/req_check.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Copyright 2021-present Iceflower - [email protected]
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
"""
10+
11+
from argparse import ArgumentParser
12+
from pathlib import Path
13+
14+
import pkg_resources
15+
import sys
16+
17+
18+
def cmd_parser() -> ArgumentParser:
19+
parser = ArgumentParser(prog="req_check",
20+
description="Check if a python installation matches a requirements.txt file")
21+
22+
parser.add_argument(dest='req_file', type=str, help='path to requirements.txt')
23+
parser.add_argument('--quiet', dest='quiet', action='store_true', default=False, help='output nothing')
24+
25+
return parser
26+
27+
28+
def main():
29+
args = cmd_parser().parse_args(sys.argv[1:])
30+
31+
with Path(args.req_file).open(mode='r', encoding='UTF-8') as reader:
32+
dependencies = reader.read()
33+
34+
success = True
35+
for pkg in dependencies.split('\n'):
36+
try:
37+
pkg_resources.require(pkg)
38+
except pkg_resources.DistributionNotFound:
39+
success = False
40+
if not args.quiet:
41+
print(f"Did not found '{pkg}', but is required.")
42+
except pkg_resources.VersionConflict as ex:
43+
success = False
44+
if not args.quiet:
45+
print(f"Found: '{ex.dist}', but '{ex.req}' is required.")
46+
else:
47+
if not args.quiet:
48+
print(f"Found: '{pkg}'.")
49+
exit(0) if success else exit(1)
50+
51+
52+
if __name__ == '__main__':
53+
main()

helper/requirements_check/req_check.py

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

0 commit comments

Comments
 (0)