Did you already buy your Eurail passes?
If not, I urge you to reconsider. They are very inconvenient to use in Spain and France because you need reservations anyway, which cost extra and are a hassle to secure... Cheap advance tickets (bought when reservations open, so typically 3-4 months before the trip) will come out cheaper and be easier to manage overall! Plus there are no convenient train connections between Portugal and Spain these days, so that's a mandatory bus or flight.
And even if you did buy the passes, they are refundable for a 15% cancellation fee... Might be worth it.
As for the route, I would spend about 9 nights in Portugal, splitting those between Lisbon, a coastal location (I suggest Ericeira, near Lisbon), and Porto. Then fly from Porto to Bilbao and spend about 5-6 nights in the Spanish Basque country.
And take the train from San Sebastián to Paris where you can spend the remaining 6 nights or so.