Friday, June 21, 2019

IORegistryExplorer on macOS Dark Mode issue fix

IO Registry Explorer is a utility developed by Apple which allows you to watch the I/O Registry on your macOS.
A sample I/O Registry Explorer window
(Original: https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/art/registryexplorer.jpg)


If you are using the IORegistryExplorer on macOS while working with Dark Mode enabled, then you probably noticed the fact that the explorer doesn't fit the new DarkMode, hence the UI might look like that:




Which makes it hard to read the content.

I found this article which shows you how to disable DarkMode for a specific application.

Running the following commands:

osascript -e 'id of app "IORegistryExplorer"'
defaults write com.apple.IORegistryExplorer NSRequiresAquaSystemAppearance -bool yes

Solves the issue and make it usable again.



Have fun,
Tal Kain

Saturday, May 18, 2019

Standalone IPython using PyInstaller and VirtualEnv


I decided that I want to create a standalone IPython executable that I can distribute.
This executable should be:

  • Run as a standalone, even if there is no Python installed on the machine
  • Have all required packages even if they aren't installed on the machine
  • Doesn't have extra packages in it (just what needed)
  • Single executable (no shared objects)


In order to achieve this task I used PyInstaller, which according to this StackOverflow post seems like one of the good options to do so.

I also wanted to make my environment as clean as possible, so I installed virtualenv:

virtualenv ipython_env/
source ipython_env/bin/activate

Inside this environment, I ran the following pip command to install PyInstaller and IPython:

pip install pyinstaller
pip install ipython 

Following rgtk's comment: https://stackoverflow.com/a/31412509/132847, I created the following script:

from IPython import embed
embed()

and called it ipython.py


From PyInstaller help manual:
  -F, --onefile         Create a one-file bundled executable.
then, I ran:
pyinstaller -F ipython.py


The output of the script generated a (default named) directory called dist which the output binary was in.

$ file dist/ipython
dist/ipython: Mach-O 64-bit executable x86_64

$ otool -L ./dist/ipython
./dist/ipython:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)

Running this binary:
$ ./dist/ipython
Python 2.7.16 (default, Apr 12 2019, 15:32:40)
Type "copyright", "credits" or "license" for more information.
IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
In [1]:


That's all for today.

Good luck!
Tal Kain