HorlogeSkynet / archey4

:computer: Maintained fork of the original Archey (Linux) system tool
https://git.io/archey4
GNU General Public License v3.0
291 stars 37 forks source link

[FEATURE] MacOS support #95

Closed mdubinko closed 3 years ago

mdubinko commented 3 years ago

There is an old version of archey still on Mac Homebrew, but it's listed as deprecated and brew doctor suggests finding an alternative. Posting here in case someone has already considered adding MacOS (Darwin, actually) support to this nice project.

In this particular instance, I'm still on Catalina 10.15.7 :

python3 -m distro -j
{
    "codename": "",
    "id": "darwin",
    "like": "",
    "version": "19.6.0",
    "version_parts": {
        "build_number": "0",
        "major": "19",
        "minor": "6"
    }
}
HorlogeSkynet commented 3 years ago

Hi @mdubinko, thanks for properly opening this up.

From this formula, I understood Homebrew's proposed Archey version corresponds to this project. I'd love seeing Archey 4 supporting macOS (maybe related to #69 too ?), I unfortunately don't have a proper setup to experiment those developments, and didn't want to abuse of Microsoft GitHub's CI in such conditions.

That being said, have you tried directly running a recent release of Archey 4 on your system ? Despite a wrong logo being displayed, I'd want to know whether it crashed, and if so, why !

Bye :wave:


EDIT : Also see related #38.

mdubinko commented 3 years ago

Straight out of the box, I get ... File "/usr/local/lib/python3.9/site-packages/archey/entries/cpu.py", line 48, in init self.value = self._parse_lscpu_output() File "/usr/local/lib/python3.9/site-packages/archey/entries/cpu.py", line 83, in _parse_lscpu_output cpu_info = check_output('lscpu', env={'LANG': 'C'}, universal_newlines=True) ... File "/usr/local/Cellar/python@3.9/3.9.2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1823, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'lscpu'

Alas, MacOS has neither /proc nor an lscpu binary. According to https://www.quora.com/Is-there-a-Mac-OS-equivalent-to-the-Linux-lscpu it looks like the near equivalent is

sysctl -n machdep.cpu.brand_string

Which locally returns

Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz

So it seems like it would be more complicated to figure out cores/threads/etc. Would it be worth looking at how archey-osx does it, or would you prefer more of a cleanroom approach?

HorlogeSkynet commented 3 years ago

Thanks for you feedback, I'm actually already on it with the help of a friend. Expect a proper proposition within some days. Bye :bow:

HorlogeSkynet commented 3 years ago

Hey back @mdubinko. Would you be able to test latest develop state (recently force-pushed, care with your fork) ?

git checkout develop
git pull
python3 -m archey

I had to adapt tests a bit, but now CI is all green.

I'm waiting for your feedback before anything else.


EDIT : Most of Archey-OSX has been ported, and (regular) BSDs should be supported too.


Bye :wave:

mdubinko commented 3 years ago

My fork is basically abandoned at this point. :) I ran this straight from the develop branch on this repo.

 % python3 -m archey                                                                                                          (develop)archey4
WARNING: [sysctl]: Couldn't fetch temperature from CPU sensors (sysctl: unknown oid 'dev.cpu.0.temperature'). Please be sure to load the corresponding kernel driver beforehand (`kldload coretemp` for Intel or `kldload amdtemp` for AMD`).
                                  User: micah
                     'c.          Hostname: retina15.lan
                  ,xNMM.          Model: MacBookPro11.3
                .OMMMMo           Distro: Darwin 19.6.0 [x86_64]
                OMMM0,            Kernel: 19.6.0
      .;loddo:' loolloddol;.      Uptime: 7 days, 11 hours and 46 minutes
    cKMMMMMMMMMMNWMMMMMMMMMM0:    Processes: 584
  .KMMMMMMMMMMMMMMMMMMMMMMMWd.    WindowManager: Quartz Compositor
  XMMMMMMMMMMMMMMMMMMMMMMMX.      DesktopEnvironment: Aqua
  MMMMMMMMMMMMMMMMMMMMMMMM:       Shell: /bin/zsh
  MMMMMMMMMMMMMMMMMMMMMMMM:       Terminal: iTerm.app ██ ██ ██ ██ ██ ██ ██
  MMMMMMMMMMMMMMMMMMMMMMMMX.      Packages: 131
  kMMMMMMMMMMMMMMMMMMMMMMMMWd.    Temperature: Not detected
  .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   CPU: 8 x Quad-Core Intel Core i7 @ 2.3 GHz
   .XMMMMMMMMMMMMMMMMMMMMMMMMK.   GPU: Intel Iris Pro
     kMMMMMMMMMMMMMMMMMMMMMMd     GPU: NVIDIA GeForce GT 750M
      ;KMMMMMMMWXXWMMMMMMMk.      RAM: 1664 MiB / 16384 MiB
        .cooc,.    .,coo:.        Disk: 4.5 TiB / 10.6 TiB
                                  LanIP: fe80::1, 192.168.86.27
                                  WanIP: (redacted) 😄 

After iTerm.app the rectangular blocks are in fact color swatches. Not sure if intended, but the "Disk" figure includes my network mounted backup drive.

HorlogeSkynet commented 3 years ago

My fork is basically abandoned at this point. :)

It was just in case :relieved:

Not sure if intended, but the "Disk" figure includes my network mounted backup drive.

Since #67 (IIRC), Disk process them all, indeed.
2 possibilities :


One more thing I also spotted in CI executions : I can't understand your Distro entry output. Could you run python3 -c 'import platform; print(platform.mac_ver())' for me please ?


Thanks for your feedback ! Bye :wave:


EDIT : I don't know whether the sysctl warning is relevant to write on macOS, do you have an idea about this ?

mdubinko commented 3 years ago

On my Catalina box: ('10.15.7', ('', '', ''), 'x86_64') On my Big Sur box: ('10.16', ('', '', ''), 'x86_64')

Not sure how temp sensors work across different Macs, and I haven't closely inspected the new code yet. Though that error message mentions AMD and probably isn't even relevant for Mac...

HorlogeSkynet commented 3 years ago

Thanks again, please find an updated develop (supposed to be) fixing those last two issues. :wave:


EDIT : I opted for (apparently well-known) third-parties to gather temperature on macOS (iStats or OSX CPU Temp), without any error messages in case they are not installed so as to keep the detection fully-optional and a "clean" output out-of-the-box for iUsers. What do you think about that ?

HorlogeSkynet commented 3 years ago

All good on my side, I'm waiting for your feedback about last develop changes before merging this on master and drafting a v4.11.0 :ok_hand: Cheers

mdubinko commented 3 years ago
# python3 -m archey

Gave good output with no error messages. Temperature: Not detected

I ran # brew install osx-cpu-temp then tried again, and got:

...
  File "/Users/micah/Developer/archey4/archey/__main__.py", line 137, in _entry_instantiator
    return Entries[entry.pop('type')].value(
  File "/Users/micah/Developer/archey4/archey/entries/temperature.py", line 37, in __init__
    self._run_istats_or_osxcputemp()
  File "/Users/micah/Developer/archey4/archey/entries/temperature.py", line 140, in _run_istats_or_osxcputemp
    self._temps.append(float(osxcputemp_output.split()[0]))
ValueError: could not convert string to float: '57.0°C'
HorlogeSkynet commented 3 years ago

Thanks again for your feedback @mdubinko ! It appears lavoiesl/osx-cpu-temp#22 has not been released yet, so I got kidded by the upstream documentation. Anyway, I've just published a fix and will try to release a new version this WE. Bye 👋

HorlogeSkynet commented 3 years ago

Released today as v4.11.0, waiting for feedback from the community now. Bye :wave: