Even minor point releases of Visual Studio can cause significant behavior changes and ABI breakages.
The full range of defaults that changes inside Visual Studio for a major release may be more than can be accommodated with user options.
Switching the Visual Studio “platform toolset” version may be of help: in Visual Studio, click Project → Properties → Platform Toolset.
If the desired toolset is not present, use Visual Studio Installer to obtain it.
The standards-enforcing /permissive- flag can be turned off.
That may not be enough to compile projects from older MSVC versions.
The /permissive- flag is under Project → Properties → C/C++ →; Language → conformance mode.
Offline (non-Internet-connected) systems may experience failures on installing Python packages.
The package authors may not have CI setup for an offline test case, so they don’t realize it’s an issue.
In general, Python packages can use pyproject.toml more effectively in a Python-standard way to overcome these issues.
Instead of telling users to manually install a package such as Numpy, use pyproject.toml instead of setuptools setup_requires.
Setuptools assumes the computer will be internet-connected and even if the package is already installed the install will fail on an offline system.
To ensure a package like Numpy is installed first, for example where f2py is used,
have a pyproject.toml file including:
This will auto-install the prereqs before the install begins.
When including this pyproject.toml parameter, do not omit “setuptools”, “wheel” or the package may fail to install.
Pip is a widely-used, complex Python package installer program with a lot of legacy baggage.
The Python Software Foundation recognizes the critical need to update Pip, putting $116K to
sponsor a senior dev
to modernize Pip.
Sometimes, pip install fails to realize a .whl binary wheel is available.
Thus pip tries to download and install a package from source code.
In the case of a large package like SciPy, OpenCV or Pillow on an embedded system like the Raspberry Pi Zero,
it could take hours or even days to compile, probably failing numerous times due to missing prerequisite binary libraries.
A workaround to Pip not automatically finding the desired .whl binary wheel is to download and install the .whl directly.
The binary wheels are often available at PyPI from the package download page, for example
SciPy.
For embedded systems such as Raspberry Pi, there may be non-PyPI sites such as
PiWheels.
Download the file, then pip install from the file like:
If the wheel binary is not compatible with the system, it will fail to import or run.
In that case, simply pip uninstall my_package_name and try something else.
uses 256 colors-low the quality, but really makes a speed improvement. Might not display videos (e.g. VLC)–try /bpp:16 if trouble.
/bpp:16
uses 65536 colors, saving bandwidth over 24-bit color with negligible visible difference for most basic uses.
/network:modem /compression
reduce bandwidth via compression (trade CPU usages for network bandwidth)
-themes -wallpaper
great speedup by not needlessly sending background graphics repeatedly
/async-update /async-input
disable RDP waiting for screen updates to reach you before it accepts input.
These allow clicking ahead before the screen updates. Be careful of clicking unwanted options while using the PC.
-glyph-cache
disable glyph caching. Note: this can cause garbled characters and radio boxes.
/audio-mode:1
disable FreeRDP audio redirection (do not play sound from remote PC)
/auto-reconnect
automatically reconnect on failure (also works over SSH tunnel)
Usually it’s desired to check Python type annotations for an entire project.
However, when introducing type checking to a large Python project, it can be beneficial to introduce type checking gradually, to avoid massive refactoring all at once.
You will almost certainly find old code bugs due to type checking that will require refactoring, which introduces risk.
Mitigate this risk by introducing type checking gradually.
MyPy is a strongly recommended type checker, though others exist.
Use
pyproject.toml
to configure MyPy default behavior.
To tell MyPy to only check certain files, use the MyPy
–follow-imports=
option like:
32-bit Python binaries can run on 64-bit OS.
To precisely detect if the operating system is 64-bit or 32-bit,
check if Python
itself is 32-bit to avoid falsely detecting a 64-bit OS as 32 bit.
This check is just for the Python interpreter.
To detect OS parameters in a cross-platform-robust way further checks are necessary.
If the history of a Git repository has been rewritten, but someone has forked the repository before the history was rewritten, they will be unable to merge due to the unrelated history.
This method corrects the history in their forked branches to match the original repository.
In this synthetic example:
Original Git repository: github.com/username/coolprog main branch develop
Forked Git repository: github.com/jane/coolprog
A colleague, Jane, with GitHub username jane, has created a branch from develop named feature1. However, scivision changed the history of develop after the fork.
The “easy” way can reduce the risk of compromising months or years of work compared to the “Pure Git” way.
This method requires Jane to force push and execute these commands (or grant write access to the forked repository).
It is risky, so the “Easy” way is recommended.
Clone the forked repository into a temporary directory:
cd${TMPDIR}git clone https://github.invalid/jane/coolprog
cd coolprog
git switch develop
Add the original repository as upstream of the fork:
git remote add upstream https://github.invalid/scivision/coolprog
git fetch upstream
git rebase upstream/develop
git switch feature1
git rebase develop
If these changes are successful and the Git history is confirmed to be correct, a git push -f can be performed.
Ensure secure, independent copies of the GitHub repository are available, as force-pushing overwrites Git history and may erase work.
Sometimes for Git repos with a long, complicated history this doesn’t work, and would be time consuming to fix.
In that case, let’s try the “easy” way.
Matlab sparse matrices are among the classes that Matlab
cannot pass to Python.
The workaround requires enough RAM to hold the full matrix to pass to and from Python.
convert Matlab sparse to full
process sparse data in Python
convert Python sparse to full
All commands are issued in Matlab.
A = sparse(eye(5)); % test dataAs = py.scipy.sparse.csc_matrix(full(A))