Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

barracuda156

macrumors 68020
Original poster
Sep 3, 2021
2,398
1,591
Anyone interested in R, I have brought a number of packages into Macports, everything should work on PPC.
Available ports: https://ports.macports.org/search/?selected_facets=categories_exact:R
Of course, R itself builds in its current version, 4.3.1. (Forget outdated CRAN.)

Alternative GUI should work too, some glitches may be there (it is a hack): https://ports.macports.org/port/R-app/details
If you use 10.6 PPC, you may need this version: https://github.com/barracuda156/macports-ports/tree/snow-ppc/math/R-app

This will allow using libgcc12 instead of libgcc7: Move Leopard to libgcc12, fix GCC targets for PPC
gcc12 fixed for 10.6 PPC: https://github.com/barracuda156/macports-ports/tree/snow-ppc/lang/gcc12

If anyone is interested in specific R packages that are missing presently in Macports, please let me know in comments. I will try adding them.
 
Last edited:
Wow, nicely done! I haven’t used R on PowerPC in a while (used a 12” PowerBook G4 through undergrad stats), but I use it heavily for work so it’s cool to see it’s still being maintained on vintage hardware :)

Is all the core tidyverse stuff working? Would be fun to run some data wrangling benchmarks on my G5 (or heck, my 466 MHz G4 tower) against my M1 Pro MBP!

EDIT: If the R GUI is glitchy (and Python 3 works fine with macports), a solid alternative might be the fantastic Python-based ‘radian’ alternative R CLI (features multi-line paste, syntax highlighting, autocomplete, and more) along with iTerm. You might want to disable some of the more computationally-intensive features to save cycles on old hardware (e.g. drop-down function suggestions) but otherwise it’s light and powerful and a huge step up from base terminal R.
 
Last edited:
Wow, nicely done! I haven’t used R on PowerPC in a while (used a 12” PowerBook G4 through undergrad stats), but I use it heavily for work so it’s cool to see it’s still being maintained on vintage hardware :)

Is all the core tidyverse stuff working? Would be fun to run some data wrangling benchmarks on my G5 (or heck, my 466 MHz G4 tower) against my M1 Pro MBP!

tidyverse is there, you can try :)
(If anything fails, please let us know – and/or open an issue with upstream.)

Not all packages have tests enabled, but I am adding support for tests slowly. (Often requirements for dependencies to run tests are ridiculous, so it is not easy.)

P. S. On a second thought, it might be worth for a while to use gcc11 instead. I hoped non_lazy_prt bug was fixed with recent patch, but no, it just changed a bit, still there.
 
  • Like
Reactions: Amethyst1
@barracuda156 Are the only R packages on macports the ones that include C/FORTRAN code and thus need compilation? Or are pure-R packages provided through macports too?

Just curious because I actually maintain a package on CRAN and it isn’t there (eyelinker, for importing/parsing data files from EyeLink eye trackers), but it’s pure R so would presumably run fine if all its dependencies are there.
 
@barracuda156 Are the only R packages on macports the ones that include C/FORTRAN code and thus need compilation? Or are pure-R packages provided through macports too?

Just curious because I actually maintain a package on CRAN and it isn’t there (eyelinker, for importing/parsing data files from EyeLink eye trackers), but it’s pure R so would presumably run fine if all its dependencies are there.

No, there is no such restriction: many Python, Perl, Ruby packages do not require compilation, so thankfully no one came up with an idea to prohibit pure-R packages. As of now, I am the only one who submit R packages to Macports, so hope you excuse me, it takes time :)

By the way, why don’t you submit your package and be a maintainer? It will be awesome, contributors are always welcome.
 
No one asked, but anyway, let me answer perhaps a due question: why bother installing via Macports when there is CRAN?

One immediate reason is that a number of packages are broken for older systems (and by older I mean not just PPC). When I tried 1.5 years ago to install Rstan “normally” via R itself, well, nothing worked: already a number of basic dependencies were broken.
So far I am pretty sure that whatever we have for R should be working on PPC, at least on ppc32 (I sorta gave up on ppc64, at least for the time-being, too many things have to be fixed for it to start working).
That includes advanced statistical packages actually used for research.
 
No one asked, but anyway, let me answer perhaps a due question: why bother installing via Macports when there is CRAN?

One immediate reason is that a number of packages are broken for older systems (and by older I mean not just PPC). When I tried 1.5 years ago to install Rstan “normally” via R itself, well, nothing worked: already a number of basic dependencies were broken.
So far I am pretty sure that whatever we have for R should be working on PPC, at least on ppc32 (I sorta gave up on ppc64, at least for the time-being, too many things have to be fixed for it to start working).
That includes advanced statistical packages actually used for research.
Wait, you managed to get RStan running on 32-bit PowerPC??? I can only imagine how slow it must be, an average model for me takes anywhere between 5 and 55 minutes on my M1 Pro (some taking 12+ hours) so I'd be very curious how a G5 or G4 stacks up against that. 😄 Very impressed you got something so hefty and modern to build and run on 15+ year-old hardware/OSes!

Is it still possible to install things from CRAN with macports R though, or does it need to be available on macports to install at all?

By the way, why don’t you submit your package and be a maintainer? It will be awesome, contributors are always welcome.
Heh, I'd take you up on that, but a) I'm pretty sure the Venn diagram of "vintage mac enthusiasts" and "people who work with research-grade eye trackers" isn't terribly big, and b) as a technically-inclined person in the sciences I'm already responsible for maintaining more software than I'd like to be...

eyelinker got abandoned by its original author so I took it over, PySDL2 (which we use for writing experiment scripts) got abandoned by its original author so I took that over too, the in-house Python experiment programming framework my old lab used got abandoned years ago so I've been cleaning it up and improving it ever since, the library we were using to control some specialized brain stimulation hardware (TMS) was a buggy mess so I've just ended up writing a new one from scratch...

On top of all that, I'm also the main person programming and troubleshooting people's experiments/equipment and helping people with data wrangling/stats (which our grad courses really drop the ball on so there are lots of gaps to fill), and I still have to find time for my own research in there somewhere. Ahhh, the joys of being a tech guy in academia... 🙂
 
Wait, you managed to get RStan running on 32-bit PowerPC??? I can only imagine how slow it must be, an average model for me takes anywhere between 5 and 55 minutes on my M1 Pro (some taking 12+ hours) so I'd be very curious how a G5 or G4 stacks up against that. 😄 Very impressed you got something so hefty and modern to build and run on 15+ year-old hardware/OSes!

Is it still possible to install things from CRAN with macports R though, or does it need to be available on macports to install at all?

I haven’t tried out yet its performance – these are very recent developments, and I am busy fixing software. But everything builds at least. I have also built stanc3 which is written in OCaml (and I have fixed OCaml for PPC, though at the moment only bytecode).
CmdStan is in plans. (Should not be a big deal to build, just their build ecosystem is a mess, TBH. Once my PR for oneTBB is merged, CmdStan is the next goal.)
If I remember, I will dig out models I wrote in brms for a paper and try running on G5. Maybe will motivate me to do some writing.

Yes, you can install packages from outside of Macports, but I think some env variables should be set for R to acknowledge a second library. I did that once, as I recall it was trivial. (At the same time why not just write a new port? It is a matter of few minutes.)
 
  • Like
Reactions: ahurst
Anyone interested in R, I have brought a number of packages into Macports, everything should work on PPC.
Available ports: https://ports.macports.org/search/?selected_facets=categories_exact:R
Of course, R itself builds in its current version, 4.2.2. (Forget outdated CRAN.)

Alternative GUI should work too, some glitches may be there (it is a hack): https://ports.macports.org/port/R-app/details
If you use 10.6 PPC, you may need this version: https://github.com/barracuda156/macports-ports/tree/snow-ppc/math/R-app

This will allow using libgcc12 instead of libgcc7: Move Leopard to libgcc12, fix GCC targets for PPC
gcc12 fixed for 10.6 PPC: https://github.com/barracuda156/macports-ports/tree/snow-ppc/lang/gcc12

If anyone is interested in specific R packages that are missing presently in Macports, please let me know in comments. I will try adding them.
Wow, cool! That sounds awesome, and I'm curious about your motivation for putting in the effort for PPC. Are there a lot of people doing data science on PPC still?
 
Wow, cool! That sounds awesome, and I'm curious about your motivation for putting in the effort for PPC. Are there a lot of people doing data science on PPC still?

The optimal usage of PowerPC Macs now is in development and science, since command line interface works great as always, while web and media – not so much LOL

I kinda got a Quad with an idea of using it for Bayesian models in R (plus experimenting with 10.6 PPC). Found out that everything is broken – from compilers to R packages and math software, decided to fix that. Because we can.
 
The optimal usage of PowerPC Macs now is in development and science, since command line interface works great as always, while web and media – not so much LOL

I kinda got a Quad with an idea of using it for Bayesian models in R (plus experimenting with 10.6 PPC). Found out that everything is broken – from compilers to R packages and math software, decided to fix that. Because we can.
That’s the spirit!

Very curious to see some benchmarks on this though
 
The optimal usage of PowerPC Macs now is in development and science, since command line interface works great as always, while web and media – not so much LOL

I kinda got a Quad with an idea of using it for Bayesian models in R (plus experimenting with 10.6 PPC). Found out that everything is broken – from compilers to R packages and math software, decided to fix that. Because we can.
Neat. What are you modeling if you don't mind my asking?
 
UPD. New R-igraph builds fine with GCC, so just use that one. Deleted the link to old version here.
 
Last edited:
A quick tutorial on How to write ports for R packages

Borrow any existing port from R folder as a template: https://github.com/macports/macports-ports/tree/master/R

Set the following into R.setup field: Source (github, cran, gitlab, bioconductor), repo (necessary for github/gitlab; optional for cran: if no repo known, use cran, it does nothing for cran packages anyway), package name (without appending R-, i.e. as it is on Github or CRAN), version, version prefix (for github/gitlab).

Put all dependencies (depends, links to and imports fields on CRAN) into depends_lib-append. This is required.

Put all suggested packages into depends_test-append. This is optional and may be omitted. If you do, add test.run yes, since it is currently disabled by default, and run tests. I.e. sudo port -v test PACKAGE.

If the package does not compile anything, add supported_archs noarch. Example: https://github.com/macports/macports-ports/blob/master/R/R-lavaan/Portfile
CRAN makes it clear whether compilation is needed.

If the package uses gfortran, add compilers.setup require_fortran. Example: https://github.com/macports/macports-ports/blob/master/R/R-Rfast/Portfile
This is necessary for silly Clang. Heh.
Unfortunately, CRAN does not mention Fortran requirement anywhere. So you need to look into output from package installation. If you use verbose, sudo port -v install PACKAGE, it will show compilation commands. At linking stage see if there is -lgfortran (it may or may not be used during compilation, so check linking command).

Rest should be self-explanatory. License and description are borrowed from CRAN (or other source), if you do not want to copy a long description, use {*}${description} in long_description field. How to get checksums: use wrong ones, try extracting with sudo port -v extract, if will spit out correct ones :)

If everything works locally, submit PR to Macports.

P. S. If the build is broken, but you want the package to be in Macports, ask here, we can try to fix. No dependents of V8 and Pandoc, LOL.
 
Last edited:
EDIT: If the R GUI is glitchy (and Python 3 works fine with macports), a solid alternative might be the fantastic Python-based ‘radian’ alternative R CLI (features multi-line paste, syntax highlighting, autocomplete, and more) along with iTerm. You might want to disable some of the more computationally-intensive features to save cycles on old hardware (e.g. drop-down function suggestions) but otherwise it’s light and powerful and a huge step up from base terminal R.

Okay, sounds good, but it does not work: https://github.com/randy3k/radian/issues/403
What am I doing wrong?

P. S. Portfiles are here: https://github.com/barracuda156/macports-ports/tree/radian
 
Okay, sounds good, but it does not work: https://github.com/randy3k/radian/issues/403
What am I doing wrong?

P. S. Portfiles are here: https://github.com/barracuda156/macports-ports/tree/radian
Oh, very weird. Do you know if `ptpython`works? It's an alternative Python console built around the same 'prompt_toolkit' framework as radian, so if that fails with a similar error you'd know if it's a Radian problem or a problem with its prompt_toolkit dependency (which the traceback in your issue seems to suggest).
 
Oh, very weird. Do you know if `ptpython`works? It's an alternative Python console built around the same 'prompt_toolkit' framework as radian, so if that fails with a similar error you'd know if it's a Radian problem or a problem with its prompt_toolkit dependency (which the traceback in your issue seems to suggest).

Okay, it was helpful. ptpython is broken on 10.6 PPC, but works on 10.6.8 Rosetta. Should be fixable then, some SDK issue.

UPD. Oops, it is also broken on Leopard. However, it is a good news, of a sort, since now I can open a ticket on Trac.
 
Last edited:
Oh, very weird. Do you know if `ptpython`works? It's an alternative Python console built around the same 'prompt_toolkit' framework as radian, so if that fails with a similar error you'd know if it's a Radian problem or a problem with its prompt_toolkit dependency (which the traceback in your issue seems to suggest).

Launches fine on Rosetta, but again malloc hell, and I am too uncomfortable with Python to deal with fixing this:
Code:
10:~ svacchanda$ radian
R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Platform: powerpc-apple-darwin10.8.0 (32-bit)

r$> library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
Learn more about the underlying theory at https://ggplot2-book.org/
Python(85755,0xa0dfb620) malloc: *** error for object 0xa0d51754: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0xa0d517c4: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a0a2c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a09928: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a09890: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a098dc: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a097c8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a096a0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a095c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a09630: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a094f8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a0a200: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a0a380: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a0a38c: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Python(85755,0xa0dfb620) malloc: *** error for object 0x8a0a3a8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
rstan (Version 2.21.8, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)

Test are pretty bad too:
Code:
--->  Testing radian
Executing:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_math_radian/radian/work/radian-0.6.4" && py.test-3.10 -o addopts='' 
============================= test session starts ==============================
platform darwin -- Python 3.10.9, pytest-7.2.0, pluggy-1.0.0
rootdir: /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_radian/radian/work/radian-0.6.4, configfile: setup.cfg, testpaths: tests
collected 15 items

tests/test_aaa.py .                                                      [  6%]
tests/test_readline.py .....                                             [ 40%]
tests/test_reticulate.py .FEFFE                                          [ 66%]
tests/test_shell.py ...                                                  [ 86%]
tests/test_startup.py .                                                  [ 93%]
tests/test_version.py .                                                  [100%]

==================================== ERRORS ====================================
_____________________ ERROR at teardown of test_multiline ______________________

radian_command = ['/opt/local/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10', '-m', 'radian']

    @pytest.fixture(scope='function')
    def terminal(radian_command):
        with Terminal.open(radian_command) as t:
            yield t
            t.sendintr()
            t.write("q()\n")
            start_time = time.time()
            while t.isalive():
                if time.time() - start_time > 15:
>                   raise Exception("radian didn't quit cleanly")
E                   Exception: radian didn't quit cleanly

tests/conftest.py:32: Exception
_____________________ ERROR at teardown of test_completion _____________________

radian_command = ['/opt/local/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10', '-m', 'radian']

    @pytest.fixture(scope='function')
    def terminal(radian_command):
        with Terminal.open(radian_command) as t:
            yield t
            t.sendintr()
            t.write("q()\n")
            start_time = time.time()
            while t.isalive():
                if time.time() - start_time > 15:
>                   raise Exception("radian didn't quit cleanly")
E                   Exception: radian didn't quit cleanly

tests/conftest.py:32: Exception
=================================== FAILURES ===================================
________________________________ test_multiline ________________________________

terminal = <tests.terminal.Terminal object at 0x2434040>

    def test_multiline(terminal):
        terminal.current_line().assert_startswith("r$>")
        terminal.write("~")
>       terminal.current_line().strip().assert_equal(">>>")

tests/test_reticulate.py:30: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/terminal.py:97: in assert_equal
    self._assert(operator.eq, operand, timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.terminal.Var object at 0x2434d48>, op = <built-in function eq>
operand = '>>>', timeout = 5

    def _assert(self, op, operand, timeout=5):
        t = time.time()
        while time.time() - t < timeout:
            value = self.getter()
            if op(value, operand):
                break
            time.sleep(0.05)
        else:
>           raise Exception("value is {}".format(value))
E           Exception: value is

tests/terminal.py:88: Exception
_________________________________ test_ctrl_d __________________________________

terminal = <tests.terminal.Terminal object at 0x377b568>

    def test_ctrl_d(terminal):
        terminal.current_line().assert_startswith("r$>")
        terminal.write("~")
>       terminal.current_line().strip().assert_equal(">>>")

tests/test_reticulate.py:49: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/terminal.py:97: in assert_equal
    self._assert(operator.eq, operand, timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.terminal.Var object at 0x377b5e0>, op = <built-in function eq>
operand = '>>>', timeout = 5

    def _assert(self, op, operand, timeout=5):
        t = time.time()
        while time.time() - t < timeout:
            value = self.getter()
            if op(value, operand):
                break
            time.sleep(0.05)
        else:
>           raise Exception("value is {}".format(value))
E           Exception: value is

tests/terminal.py:88: Exception
_______________________________ test_completion ________________________________

terminal = <tests.terminal.Terminal object at 0x378ac58>

    def test_completion(terminal):
        terminal.current_line().assert_startswith("r$>")
        terminal.write("~")
>       terminal.current_line().strip().assert_equal(">>>")

tests/test_reticulate.py:63: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/terminal.py:97: in assert_equal
    self._assert(operator.eq, operand, timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.terminal.Var object at 0x378acd0>, op = <built-in function eq>
operand = '>>>', timeout = 5

    def _assert(self, op, operand, timeout=5):
        t = time.time()
        while time.time() - t < timeout:
            value = self.getter()
            if op(value, operand):
                break
            time.sleep(0.05)
        else:
>           raise Exception("value is {}".format(value))
E           Exception: value is

tests/terminal.py:88: Exception
=========================== short test summary info ============================
FAILED tests/test_reticulate.py::test_multiline - Exception: value is
FAILED tests/test_reticulate.py::test_ctrl_d - Exception: value is
FAILED tests/test_reticulate.py::test_completion - Exception: value is
ERROR tests/test_reticulate.py::test_multiline - Exception: radian didn't qui...
ERROR tests/test_reticulate.py::test_completion - Exception: radian didn't qu...
============== 3 failed, 12 passed, 2 errors in 126.32s (0:02:06) ==============
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_math_radian/radian/work/radian-0.6.4" && py.test-3.10 -o addopts='' 
Exit code: 1
 
Last edited:
Oh, very weird. Do you know if `ptpython`works? It's an alternative Python console built around the same 'prompt_toolkit' framework as radian, so if that fails with a similar error you'd know if it's a Radian problem or a problem with its prompt_toolkit dependency (which the traceback in your issue seems to suggest).

It is in fact Python itself: https://trac.macports.org/ticket/67046
 
Huh, well at least you've got it narrowed down a bit! Do you get the same issue with Python 3.9 or 3.8? I think radian supports back to 3.7, so if older versions have fewer PowerPC-related quirks that might be worth a shot.

Running testsuite takes quite a while, but I will try when have some time for that.
 
Rstan_powerpc.png


Well, at least it works :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.