File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.20)
2+
3+ project (pyinstaller)
4+
5+ # ensure a Python 3 interpreter and development libraries are available
6+ find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
7+
8+ # create a custom command to build the executables
9+ add_custom_command (
10+ OUTPUT dist/prod_columns dist/sum_columns
11+ COMMAND python -m venv ${CMAKE_CURRENT_BINARY_DIR} /build_venv
12+ COMMAND ${CMAKE_CURRENT_BINARY_DIR} /build_venv/bin/pip install
13+ -r ${CMAKE_CURRENT_SOURCE_DIR} /requirements.txt
14+ COMMAND ${CMAKE_CURRENT_BINARY_DIR} /build_venv/bin/pyinstaller --onefile
15+ --hidden-import funcs --collect-submodules funcs
16+ ${CMAKE_CURRENT_SOURCE_DIR} /src/sum_columns.py
17+ COMMAND ${CMAKE_CURRENT_BINARY_DIR} /build_venv/bin/pyinstaller --onefile
18+ --add-data ${CMAKE_CURRENT_SOURCE_DIR} /data.csv:.
19+ --hidden-import funcs --collect-submodules funcs
20+ ${CMAKE_CURRENT_SOURCE_DIR} /src/prod_columns.py
21+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /src/prod_columns.py
22+ ${CMAKE_CURRENT_SOURCE_DIR} /src/sum_columns.py
23+ ${CMAKE_CURRENT_SOURCE_DIR} /src/lib/funcs.py
24+ ${CMAKE_CURRENT_SOURCE_DIR} /data.csv
25+ VERBATIM )
26+
27+ # create a custom target to build the executables
28+ add_custom_target (create_executables ALL
29+ DEPENDS dist/prod_columns dist/sum_columns)
30+
31+ # install the executables
32+ install (
33+ FILES ${CMAKE_BINARY_DIR} /dist/prod_columns ${CMAKE_BINARY_DIR} /dist/sum_columns
34+ DESTINATION bin
35+ )
Original file line number Diff line number Diff line change @@ -16,10 +16,13 @@ interpreter or any modules. It is very useful to minimize dependencies.
16161 . ` build_apps.sh ` : Bash script that creates a virtual environment, installs
1717 the required packages, and creates a standalone application using
1818 PyInstaller.
19+ 1 . ` CMakeLists.txt ` : CMake file to build and install the applications.
1920
2021
2122## How to create the applications?
2223
24+ ## By hand
25+
23261 . Create a virtual environment and install the required packages:
2427 ``` bash
2528 $ python -m venv build_venv
@@ -40,3 +43,11 @@ interpreter or any modules. It is very useful to minimize dependencies.
4043 --collect-submodules funcs \
4144 src/prod_columns.py
4245 ```
46+
47+
48+ ## Using CMake
49+
50+ ``` bash
51+ $ cmake -B build -S .
52+ $ cmake --build build
53+ ```
You can’t perform that action at this time.
0 commit comments