-
Notifications
You must be signed in to change notification settings - Fork 27
2. Dev Setup
Originally, the README.md contained instructions for how to set up a development environment for the edge-addition-planarity-suite on Windows using the Eclipse IDE (see README.md from commit b4063b). Support was extended to using Visual Studio Code on Windows 10 (both MinGW gcc and MSVC cl) and MacOS Sequoia 15.0 (clang) with the testing of PR #16, and subsequently to include Debian Linux 12.7 with the testing of PR #58. The most recent Visual Studio Code configuration files were updated in PR #92 to reflect the new project structure described by Epic #91.
For simplicity and maintainability of the documentation, support for the Eclipse IDE has been deprecated; the following instructions now only refer to setting up Visual Studio Code for development purposes.
- Install your chosen compiler toolchain:
- To install MinGW 32, download and run
mingw-get-setup.exefrom here and then use the MinGW Installation Manager to install C and C++, GDB, MSYS, and any other packages you may want; with the Basic Setup tab selected, mark themingw-developer-toolkit-bin(also marksmsys-base-binmeta package for installation) andmingw32-base-binmeta packages for installation, then under the Installation menu item, select "Apply Changes". Finally, ensure yourgccis accessible from the command line by addingC:\MinGW\binto the systemPATH.- N.B. These instructions will be revised to cover installing MinGW 64 as a part of Issue #102 - Add support for MinGW 64 and deprecate MinGW 32
- To install the MSVC compiler toolchain, follow the third step of Configure VS Code for Microsoft C++ to use the Visual Studio Installer to install the "Desktop development with C++" Visual Studio Build Tools workload. One must use the Developer Command Prompt to use the MSVC compiler toolchain, as other shells won't have the appropriate environment variables set; if you choose to use VSCode with MSVC
cl, you must open the Developer Command Prompt, navigate to theedge-addition-planarity-suiterepository root, and run VSCode by executing:code .
- To install MinGW 32, download and run
- To install Python 3.12 on Windows 10:
- Follow 4.1.1. Installation steps using the Python 3.12.7 Windows 64-bit installer from the Python Releases for Windows page.
-
N.B. Unless you choose to customize the installation, you will only install Python for the current user; the
Pathvariable under "User variables for " will be prepended with the user-level Python installation directory (i.e. a subdirectory of%LOCALAPPDATA%)
-
N.B. Unless you choose to customize the installation, you will only install Python for the current user; the
- Open “Manage App Execution Aliases” through the Start menu and toggle both
python3.exeandpython3.exeto off, - Confirm successful installation by opening a command prompt and checking the output from
python --version:C:\Users\wbkbo>python --version Python 3.12.7
-
N.B. If you follow 4.2. The Microsoft Store package to install Python, you may end up installing a higher version than that with which the
TestSupport/planaritytestingpackage has been tested.
- Follow 4.1.1. Installation steps using the Python 3.12.7 Windows 64-bit installer from the Python Releases for Windows page.
- Follow Install git on Windows
- To install Visual Studio Code on Windows, follow Visual Studio Code on Windows - Installation, and then depending on which compiler toolchain you have installed, follow either Using GCC with MinGW or Configure VS Code for Microsoft C++.
Creating a Windows 10 22H2 VM using VirtualBox
If you are on a Windows device and wish to create a Windows 10 Home 22H2 virtual machine to contain your development environment, you can download the Windows 10 Media Creation tool which will help you create an .iso file. Otherwise, you may download the .iso file directly from the Windows 10 Home 22H2 ISO Download page.
- Ensure your username is part of the
sudoersgroup; if not, then follow the advice in the replies to this Unix StackExchange post - Run the following command
To install build dependencies (i.e. the
sudo apt update && sudo apt -y upgrade && sudo apt install -y build-essential gdb autotools-dev git-allbuild-essentialmetapackage, which includesgccbut doesn't includegdb, as well as the GNU Autotools (see the Autotools FAQ and the Debian AutoTools home for more info)). Finally, we must installgit-all(see Install git on Linux - Debian/Ubuntu)-
N.B. It is preferable to use
aptrather thanapt-getto update, upgrade, and install packages due to more sophisticated package search, system memory cleanup, and dependency resolution; please see the AWS docs on What’s the Difference Betweenaptandapt-get? for more in-depth justification.
-
N.B. It is preferable to use
- To build Python 3.12 from source on Debian Linux, please follow the Python documentation page Building Python; in particular, please ensure that you run
make altinstallso that you do not override the systempython3binary.-
N.B. Although the
TestSupport/planaritytestingpackage doesn't depend on extension modules that impose further requirements of development headers for additional libraries, it might be prudent to follow the Python Developer's Guide - Build Dependencies for instructions on how to get all build dependencies on Linux. If you decide to install these dependencies after having initially built and installed Python 3.12 from source, you'll have to re-runconfigureandmake altinstall.
-
N.B. Although the
- To install Visual Studio Code on Linux, follow Visual Studio Code on Linux - Installation, and then Using C++ on Linux in VS Code.
Creating a Debian Linux 12.7 VM using VirtualBox
If you wish to create a Debian Linux VM to contain your development environment, you can get the most recent version of Debian Linux from the Debian Downloads page; however, the edge-addition-planarity-suite has been tested on Debian 12.7.0, the netinst CD image .iso for which may be obtained from Installing Debian 12.7 (Bookworm). If you are using VirtualBox to set up your VM, follow a guide like How To Install Debian 12 on VirtualBox, which includes instructions for how to set up VirtualBox Guest Additions on the Debian Linux VM; there are alternate instructions for how to install VirtualBox Guest Additions on the VM provided by the Debian Wiki: Installing the Guest Additions on a Debian VM - Debian 10 "Buster", Debian 11 "Bullseye", and Debian 12 "Bookworm". If your sources.list doesn't contain the expected package mirrors, you can copy a default version by running:
sudo cp /usr/share/doc/apt/examples/sources.list /etc/apt/sources.list
Recommended in this reply to a Unix StackExchange post.
- Open a terminal window and type:
% xcode-select --install xcode-select: note: install requested for command line developer tools - A new prompt will open outside the terminal window; click 'Install'
- Agree to the Command Line Tools License Agreement
- A new prompt will open indicating the progress as the software is downloaded
- Verify that Xcode command line tools were correctly installed and the requisite utilities are present:
Where
% xcode-select -p /Applications/Xcode.app/Contents/Developer % clang --version Apple clang version 16.0.0 (clang-1600.0.26.4) ... % lldb --version lldb-1600.0.39.3 ... % leaks --help leaks: Search through a process for leaked memory. ... % git --version git version 2.39.5 (Apple Git-154)clangis the compiler,lldbis the debugger,leaksis a command-line tool for finding memory leaks (see the 3. Test Support wiki page section on Automating memory checking on MacOS usingleaks), andgitis the source control utility required to interact with this repository as a contributor - To install Python 3.12 on MacOS, download the Python 3.12.7 macOS 64-bit universal2 installer from the Python Releases for macOS, or from the Python 3.12.7 release page.
- To install Visual Studio Code on MacOS, follow Visual Studio Code on macOS - Installation, and then Using Clang in Visual Studio Code.
Installing Python 3.12 using Homebrew (NOT recommended)
- Follow The Hitchhiker's Guide to Python instructions for Installing Python 3 on Mac OS X. This recommends using
homebrewto install Python 3 using the commandbrew install python; however, you can specifypython@3.12by running the install command:% brew install python@3.12 - In order to ensure the proper environment variables are set for
homebrew, you must add the following to your~/.zprofilefile:Then runeval "$(/opt/homebrew/bin/brew shellenv)"source ~/.zprofile - Check what the aliases for
pythonandpython3correspond to by typing the following:% python --version zsh: command not found: python % which python python not found % python3 --version Python 3.9.X <----- INSTALLED BY xcode-select --install % which python3 /usr/bin/python3 % python3.12 --version Python 3.12.7 % which python3.12 /opt/homebrew/bin/python3.12 - To set the alias
pythonandpython3to correspond to thepython3.12binary, add the following to your~/.zprofilefile:Then runexport PATH=/opt/homebrew/opt/python@3.12/libexec/bin:$PATHsource ~/.zprofile.-
N.B. If you do not follow this step, then scripts in the
TestSupport/planaritytestingpackage (see 3. Test Support) must be run usingpython3.12as the interpreter alias
-
N.B. If you do not follow this step, then scripts in the
Creating a MacOS Sequoia 15.0 VM using UTM
If you wish to create a MacOS VM to contain your development environment, visit the Apple Developer Download page and sign in using your Apple ID; then, search for MacOS (i.e. Sequoia 15.0) and click the link labelled Mac computers with Apple silicon to download the .ipsw restore image. Then, download UTM and install this system emulator. Finally, follow their instructions for How to set up a MacOS Guest using the .ipsw previously downloaded.
-
Fork the
edge-addition-planarity-suiterepository -
Clone your fork for local use via the command-line
- N.B. If you don't wish to use the command-line, follow Clone a repository locally to clone your fork within Visual Studio Code. After you have chosen your fork to clone locally, if prompted "Do you trust the authors of the files in this folder?", select "Yes, I trust the authors."
- If you plan on contributing to the project, create a feature branch on the local copy of your fork (regularly committing and pushing to your fork on GitHub), and ensure that any upstream changes to the base repository are merged into your feature branch. To do this, you must either:
-
Set the upstream URL on the command-line to that of the
edge-addition-planarity-suitebase repository, and then regularly sync your fork, merging any upstream changes synced to yourmasterinto your feature branch. - Follow Syncing a fork branch from the web UI, switch to your
masterbranch within VSCode, fetch and pull the changes that were synced from the base repository into your fork, and then switch to your feature branch and merge your localmasterinto that branch.
-
Set the upstream URL on the command-line to that of the
- When you are ready to propose your changes, please create a Pull Request from the branch of your fork to the
graph-algorithms:edge-addition-planarity-suite'smasterbranch.
Once you have installed VSCode on your chosen platform(s), you must Browse for extensions and choose to install:
- C/C++ Extension Pack -
ms-vscode.cpptools-extension-pack - Python -
ms-python.python - Pylint -
ms-python.pylint - Black Formatter -
ms-python.black-formatter - GitLens -
eamodio.gitlens
One must run the edge-addition-planarity-suite/devEnvSetupAndDefaults/devEnvSetupScript.sh (to be added in forthcoming PR to satisfy Issue #89) to copy the bespoke tasks.json and launch.json into the .vscode directory at the root of the project. These configuration files allow users to build and run/debug the planarity executable on Windows (MinGW gcc and MSVC cl), Debian Linux (gcc), and MacOS (clang), and also enable one to debug the Python TestSupport scripts. Additionally, this script copies a bespoke settings.json to configure the pylint as well as the black Python formatter extension.
Debug and Release configurations within tasks.json and launch.json for C/C++ applications
To debug the planarity executable within VSCode:
- Update the
argsarray of your platform's Debug configuration to contain a quotes-enclosed comma-separated list of the command-line parameters; for example, from the "C/C++: (Windows) [Debug] gcc.exe build and debug planarity project" inlaunch.json:... "args": [ ... // Command: `planarity -test <samplesDir>` // "-test", // "${workspaceFolder}\\c\\samples" ], ... - Add desired breakpoints
- Ensure a
.cfile's tab has focus before clicking the dropdown next to the play button icon ("[Run|Debug] C/C++ File") in the top right of the VSCode editor and select "Debug C/C++ File" - Select the launch configuration corresponding to your current platform and compiler toolchain; please read the following for the correspondence between
tasks.jsonbuild tasks andlaunch.jsonrun/debug configurations.
- For MinGW
gcc, refer to Using GCC with MinGW sections Run helloworld.cpp and Customize debugging withlaunch.json-
C/C++: (Windows) [Debug] gcc.exe build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (Windows) [Debug] gcc.exe build and debug planarity projectinlaunch.json -
C/C++: (Windows) [Release] gcc.exe build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (Windows) [Release] gcc.exe build and run planarity projectinlaunch.json
-
- For MSVC
cl, refer to Configure VS Code for Microsoft C++ sections Run helloworld.cpp and Customize debugging with launch.json. N.B. You must run VSCode from the Developer Command Prompt, otherwise you won't have the appropriate environment variables set to build using MSVCclnor to debug; see section Check your Microsoft Visual C++ installation-
C/C++: (Windows) [Debug] cl.exe build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (Windows) [Debug] cl.exe build and debug planarity projectinlaunch.json -
C/C++: (Windows) [Release] cl.exe build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (Windows) [Release] cl.exe build and run planarity projectinlaunch.json
-
- For
gccon Linux, refer to Using C++ on Linux in VS Code sections Run helloworld.cpp and Customize debugging with launch.json-
C/C++: (Linux) [Debug] gcc build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (Linux) [Debug] gcc build and debug planarity projectinlaunch.json -
C/C++: (Linux) [Release] gcc build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (Linux) [Release] gcc build and run planarity projectinlaunch.json
-
- For
clangon MacOS refer to Using Clang in Visual Studio Code sections Run helloworld.cpp, specifically Understanding tasks.json and Customize debugging with launch.json-
C/C++: (MacOS) [Debug] clang build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (MacOS) [Debug] clang build and debug planarity projectinlaunch.json -
C/C++: (MacOS) [Release] clang build planarity projectintasks.jsonis thepreLaunchTaskforC/C++: (MacOS) [Release] clang build and run planarity projectinlaunch.json
-
Debug configuration for Python TestSupport scripts
Please see the 3. Test Support wiki page for more context on the scripts within the TestSupport/planaritytesting package, in particular their command-line parameterization; to debug one of these scripts using the "Python Debugger: Current File with Arguments" configuration:
- Update the
argsarray to contain a quotes-enclosed comma-separated list of the command-line parameters:... "args": [ // Args to test test_table_generation_with_numInvalidOK.py // "-n", // "5,8", // "-c", // "3", // "p", // "o" ] ... - Open the target Python script
- Set any desired breakpoints
- Ensure the tab corresponding to the target Python script has focus
- Click the dropdown next to the play button icon ("Run Python File") in the top right of the VSCode editor and select "Python Debugger: Debug using launch.json"
- Select "Python Debugger: Current File with Arguments"
For greater context on how to debug Python applications in VSCode using the "Python Debugger: Current File with Arguments" configuration in launch.json, please see Python debugging in VS Code. In particular, the section Set configuration options details the keys and possible values to augment the Python debugging experience.
Python linting and formatting for the TestSupport scripts
The settings.json customizes the behaviour of the pylint and black VSCode extensions.
N.B. Issue #100 will entail filling out further detail of this configuration.
For greater context on the configuration for linting and formatting specified in settings.json, please refer to Linting Python in Visual Studio Code and Formatting Python in VS Code.