Note: it may be necessary to reinstall Anaconda/Miniconda from scratch if packages break during a Python version upgrade.
Consider this before attempting an in-place Python upgrade.
There is often a couple month delay between a major Python release (e.g. Python 3.7 to Python 3.8) and Anaconda defaulting to this version.
We strongly suggest waiting until the new Python version is the
before trying to upgrade, as many packages many be missing or broken until then.
A good example of why to wait for default Anaconda Python is
that did not yet
work with Python 3.8
as of March 11, 2020.
Given the caveats above, if appropriate it is possible to upgrade to Python 3.8 by
conda create -n py38 python=3.8
switch to this environment by
conda activate py38
For interactive data science GUI applications
is often used.
Legacy hard-coded GUIs using external libraries have considerable overhead to maintain, and suffer bit rot far faster than the underlying code.
At the very least, be sure your code is usable from the command line and/or as a plain importable module without requiring a graphics library.
In stripped-down cloud / embedded applications, unused graphical imports cause stability problems and considerable startup lag.
generate dependency graphs
and export to GraphML files.
The GUI dependency analyzer also shows missing variable and function definitions for the whole project in one view.
The implicit static analysis of the dependency analyzer seems to be more thorough than the command
Even if you don’t typically use the Matlab “Project” feature, it’s useful for quality assurance to run this tool on Matlab code to find hidden problems that escape the imperfect nature of unit tests.
Regardless of coding language, we use a layered approach for code quality assurance including static analysis, unit tests and integration tests.
Git over SSH can use
to remember SSH keys for Linux and Windows.
For those not using Git over SSH but tiring of typing the Git password, on Windows the
Git Credential Manager
can fix that situation.
The install is small and quick, and to use Git Credential Manager, be sure via
git remote -v
that the connection is https:// and not ssh:// where appropriate.
Upon trying to git push or git pull, the Git Credential Manager will appear.
It works with Two Factor Authentication as well, storing in
Windows Credential Manager.
The keys can be deleted from Windows Credential Manager if needed, and / or the Personal Access Token automatically generated can be deleted from GitHub.
If using automatic
Git push SSH
that would need to be disabled to allow git push to use https so that Git Credential Manager is invoked.
SSH-agent remembers SSH Public Key authentication, which can be time-limited by the user.
This avoids the user having to type the password for each SSH connection, especially relevant to using Git over SSH.
Native Windows has SSH including SSH-agent, and separately WSL also can use SSH-agent.
SSH-agent works well with
Git over SSH.
Add SSH keys to SSH-agent
To use SSH-agent, add SSH keys like:
ssh-add -t 30m ~/.ssh/mykey
remember authentication for a period of time (here, 30 minutes)
One can optionally remove all SSH-agent keys from RAM by
Note that if the SSH private key was manually deleted, access to the remote SSH server is lost until a new private key is placed on the remote server when an SSH key is removed from SSH-agent.
Each operating system has a distinct method of enabling SSH-agent, as follows.
Normally it is not necessary to specify the path to the CMake generator backend, assuming the generator executable is on the system PATH.
In some cases, perhaps testing CMake with several different versions of a generator, one may wish to specify the generator executable via
When doing so, the absolute path to the generator is necessary or CMake will not find it.
For example, suppose on a CI one extracts Ninja 1.10 to use CMake and Ninja on a Fortran project.
With GitHub Actions on a Linux image, this would be specified like:
It’s trivial to detect if one is running inside WSL.
It’s also straightforward to detect if WSL is available and working on a Windows PC.
These functions are using only Python standard library modules.
Detect if inside WSL
This function detects if Python is running in WSL.
defin_wsl() -> bool:
WSL is thought to be the only common Linux kernel with Microsoft in the name.
Detect WSL from Windows
defwsl_available() -> bool:
heuristic to detect if Windows Subsystem for Linux is available.
Uses presence of /etc/os-release in the WSL image to say Linux is there.
This is a de facto file standard across Linux distros.
"""if os.name =="nt":
wsl = shutil.which("wsl")
# can't read this file or test with# pathlib.Path('//wsl$/Ubuntu/etc/os-release').# A Python limitation?
ret = subprocess.run(["wsl", "test", "-f", "/etc/os-release"])
return ret.returncode ==0return False
where “subprojects/lapack/” is automatically created as a Meson subproject from the metadata in “subprojects/lapack.wrap”.
negate .gitignore syntax
Git will ignore subdirectories but track the subprojects/*.wrap files:
include in the project .gitignore:
This technique can be applied to similar non-Meson scenarios.
We generally recommend using Ninja ≥ 1.10 with CMake ≥ 3.15, especially for large projects (including Fortran) to speed up rebuild times significantly and avoid erratic problems with slower GNU Make on large projects.
CMake 3.17 added
cmake -G "Ninja Multi-Config" -B build
which allows building Debug and Release builds or even cross builds without regenerating build*.ninja files for each build type.
generator options may be used transparently with older CMake and different generators.
The default CMake generator can be set with environment variable:
To make the default multi-config build “Release” while making Debug config also available, add to CMakeLists.txt:
set(CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug" CACHE STRING "Build type selections" FORCE)
Because Release is listed first, the default build type is Release.
With those settings, one can quickly build Debug and Release and test like:
# Release default per above settings
cmake --build .
ctest -C Release