It's also been a major supplier to Portugal, though recently overtaken by Nigeria, whose gas also runs through both Algeria & Morocco. See https://www.iea.org/articles/spain-natural-gas-security-poli..., https://www.iea.org/articles/portugal-natural-gas-security-p... for background, and https://en.wikipedia.org/wiki/Medgaz and https://en.wikipedia.org/wiki/Maghreb%E2%80%93Europe_Gas_Pip... for details of the pipelines.
There's tensions and all sorts of diplomatic complexity and that have come with that, it's certainly not perfect and there's been recent diplomatic challenges specifically, but it's worked well enough to reliably supply gas from Algeria & Nigeria to Europe for decades, and has largely protected Spain & Portugal from the recent Russian gas challenges in Europe (because of this setup, they have an 'Iberian exception' on gas in EU law).
Not to say it won't be challenging, but given the profits involved, it's totally plausible to me that they could build a setup sufficient to deliver solar energy too.
If Algeria were to stop providing gas to Europe suddenly, gas could always be sourced from somewhere else. It would clearly be a huge headache but it can be done (cf Russian gas crisis just 6 months ago).
However, If Algeria decide to just stop providing electricity to Europe, what can Europe do?
If you think Europe making themselves dependent on Russian gas was a blunder, making themselves dependent on African electricity is a geopolitical suicide.
When solar is the new oil, there might be similar efforts to keep the panels illuminated.
LOL