Canada barely has any laws requiring the existence of a prime minister.
We elect a parliament. Then one of them goes to the Governor general and says "I have support of the majority of the members", and voila: they are the Prime Minister.
Could be any member, from any party, for any reason, just so long as the majority of MPs support the person.
And once that person is PM, that just means they sit in and control the Prime Minister's office, and choose the Cabinet.
After that, they're just a figurehead who happens to be the MP with the most power.
My Hail-Mary hope for this next election is that Jody Wilson-Rayboul reruns as an independent, wins, then Trudeau gets a minority and gets kicked out as head of the Liberals. This leaves a strange minority government situation that is perfect for Jody to take charge as the first independent PM. (It could happen!)