You'd hope the answer was straight-forward, but because we live in such a special place, there are all kinds of special cases that will change the answer, which is it depends on a building's age (pre-1979?) and legal definition (condo, house, TIC?) and the tenant's characteristics (older, younger, school-aged children, disabled?)
In many cases, if a tenant has been in a location for more than a year, they most likely must be offered certain statutory-defined minimum relocation fees/assistance (about $5400 per tenant, plus certain add-ons for older tenants or extended family members); if there are school children involved, owner-move-in evictions can only take place in the summer. While you can do an owner move-in eviction unless the tenants there qualify for "protected status" in which case you can't.
There are a lot more variations that come into play too. For more contact me or check out Bornstein and Bornstein website or that of the SF Tenant's Union.