Found the solution to make a product attribute, a variation.
Lets say we have:
wp_set_object_terms( $post_id, 'XL', 'pa_size' );
Above is a custom attribute (a size attribute). In order to make it a variation you need to do this:
$thedata = Array('pa_size'=>Array(
'name'=>'pa_size',
'value'=>'',
'is_visible' => '1',
'is_variation' => '1',
'is_taxonomy' => '1'
));
update_post_meta( $post_id,'_product_attributes',$thedata);