Controlling power via code?
Controlling the power going to the load can be done using various ways the design usually depends on the concept of the driver,it also depend upon the current your pump drives
There is always a need to isolate reactive loads in your circuit as the have reflective power hence there always a chance that the power may flow back to PS damaging any controlling unit in the way

Using the Raspberry pi you could use relay(ON/OFF) as Wouter van Ooijen suggests
or you could use a DAC to get a range of analog output to derive the pump,by varying the voltage across the pump.
you will need to bias the pump and vary this biasing voltage using the DAC output to give variable speed to the pump.

Or you could just you a simple analog solution ,where you can use a H bridge which can be unbalanced using a POT resistance,you can relate this value POT in a form of feedback hence relating it with some of the control variable like speed(rpm),or temperature in cooling application.

Also you can use a PWM circuit as Scott says with a 555 timer,to drive the pump,change the duty cycle to adjust the rpm.