From e8bd6b297280dfc6dc02a18903786958f41af10e Mon Sep 17 00:00:00 2001 From: David Pierron Date: Fri, 19 May 2023 07:16:38 +0200 Subject: [PATCH] Quality of life (#50) * updated requirements.txt according to GRIMM's instructions * added launch configuration and build tasks for VS Code * updated build scripts and documentation --- .vscode/launch.json | 16 +++++++++++++ .vscode/tasks.json | 22 +++++++++++++++++ Generator/README.md | 37 +++++++++++++++++++++++++++++ Generator/build.bat | 17 +++++++++++-- Generator/install-requirements.bat | 20 ++++++++++++++++ Generator/requirements.txt | Bin 1588 -> 494 bytes 6 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 Generator/install-requirements.bat diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a489ecd --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Run MissionGenerator.py", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/Generator/MissionGenerator.py", + "console": "integratedTerminal", + "justMyCode": true + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..301622b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,22 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build the Mission Generator (run build.bat)", + "type": "shell", + "command": "cd .\\Generator ; .\\build.bat -nopause", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Install the Python requirements (run install-requirements.bat)", + "type": "shell", + "command": "cd .\\Generator ; .\\install-requirements.bat -nopause", + } + ] +} \ No newline at end of file diff --git a/Generator/README.md b/Generator/README.md index b03a060..cb700ee 100644 --- a/Generator/README.md +++ b/Generator/README.md @@ -1,3 +1,40 @@ +# Install a development environment + +## Install VSCode + +Download and install VSCode: https://code.visualstudio.com/ + +VS Code is a free, open source, cross-platform code editor. It is a great tool for editing and debugging python code. It also has a built-in terminal that can be used to run commands. +## Install python + +If using VSCode, you can install the Python extension to get started: [VS Marketplace Link](https://marketplace.visualstudio.com/items?itemName=ms-python.python) + +If not, you may need to install python 3.8.5. If you are using Windows, you can download it here: https://www.python.org/downloads/release/python-385/ + +## Create a python virtual environment + +If using VSCode, you can use the ">Python: create environment" command. + +If not, run the following command in the root of the project: `python -m venv .\Generator\venv` + +## Install python dependencies + +If using VSCode, you can use the ">Run task: " command and choose the "Install the Python requirements" task. + +If not, type `install-requirements.bat` in a terminal. + +## Build the mission generator + +If using VSCode, you can use the ">Run task: " command and choose the "Build the Mission Generator" task. + +If not, type `build.bat` in a terminal. + +## Run the mission generator + +Using VS Code, you can use the provided launch configuration to run the mission generator. + +Otherwise, you can run the following command in a terminal: `python .\Generator\MissionGenerator.py` + # Building the exe with build.bat **Use build.bat to compile the UI files and build the exe.** diff --git a/Generator/build.bat b/Generator/build.bat index 3e07e56..59ddaa1 100644 --- a/Generator/build.bat +++ b/Generator/build.bat @@ -1,4 +1,15 @@ -call .\venv\Scripts\activate.bat +IF EXIST ".\venv" ( + call .\venv\Scripts\activate.bat +) ELSE ( + IF EXIST "..\.venv" ( + rem try to activate venv from root directory (VS Code default) + call ..\.venv\Scripts\activate.bat + ) ELSE ( + echo "venv not found. Please create a virtual environment and activate it." + pause >nul + exit + ) +) echo activated python venv. pyuic5 -x MissionGeneratorUI.ui -o MissionGeneratorUI.py @@ -10,4 +21,6 @@ echo compiled ui resource files. echo building exe with pyinstaller... pyinstaller MissionGenerator.spec --distpath ..\ --clean -pause >nul \ No newline at end of file +if not %1=="-nopause" ( + pause >nul +) \ No newline at end of file diff --git a/Generator/install-requirements.bat b/Generator/install-requirements.bat new file mode 100644 index 0000000..45f6b88 --- /dev/null +++ b/Generator/install-requirements.bat @@ -0,0 +1,20 @@ +IF EXIST ".\venv" ( + call .\venv\Scripts\activate.bat +) ELSE ( + IF EXIST "..\.venv" ( + rem try to activate venv from root directory (VS Code default) + call ..\.venv\Scripts\activate.bat + ) ELSE ( + echo "venv not found. Please create a virtual environment and activate it." + pause >nul + exit + ) +) +echo activated python venv. + +pip install -r requirements.txt +echo installed python requirements. + +if not %1=="-nopause" ( + pause >nul +) \ No newline at end of file diff --git a/Generator/requirements.txt b/Generator/requirements.txt index 973a365c61a924e7e9227b4922d8ece12225a0a5..3c7812dd49d05f2ce68d210edd4fca7cd8002171 100644 GIT binary patch delta 45 zcmV+|0Mh@o4DJI0|NfIm0>qQx0U(pS0~i50ldS|JlR5<+lX3+llb!<}lQIJqlOO|D Dl>rY+ literal 1588 zcmaKsPjAye5XI+=#CJgAh@8f86H+83kl+Rq962V=pN6K1>o|?*hX;Od#v5BoRjoF1 zcHYjsc{4lz{?2S`jjgS=nN@acA6Y{iSZ?q69ocJpWpmquX+SP}_K~A*E)bcWz|HNz ztqpUZM`ZAN<53!WM@7^v6*c)_S1d(uI6cx813c}i&lT3n zbBazlU|+T|7FZYH4)%$db9OZwi-^Z()Xfsb>nX6V9eA z;ie$pve&MJvWh4vM`?6`sd`6>M4nPY{n2T0iOXQWXWel>Blg}qpeFBmt5xdlyzL}K zPl|T6QSH=o@kRnuf->v8IRK#G`vxe$j)Sq9;7=sL{yPYg`+}Nz+I#FwkQ1 z%Rbw8`{q{7im*Jm78%v6SbF^>-J zRTnW$lc(dam;As>P590fVFFuK)l5