The definition I'm aware of a spin structure is the following one:
Definition: Let $(M,g)$ be a semi-Riemannian manifold with signature $(p,q)$. Let ${\cal F}M$ be the principal ${\rm SO}(p,q)$-bundle of orthonormal frames and let $\rho : {\rm Spin}(p,q)\to {\rm SO}(p,q)$ be the covering map. A spin structure is a principal ${\rm Spin}(p,q)$-bundle ${\cal S}M$ over $M$ together with a principal bundle map $\Phi:{\cal S}M\to {\cal F}M$ such that $$\Phi(E\cdot g)=\Phi(E)\cdot \rho(g),\quad \forall E\in{\cal S}M,g\in {\rm Spin}(p,q).$$
On the other hand, studying string theory in the book by Blumenhagen, Lüst and Theisen, the authors say that a Riemann surface $\Sigma_g$ of genus $g$ has $2^{2g}$ inequivalent spin structures. They ellaborate by talking about boundary conditions (page 224):
We know from Chap. 6 that there are two non-contractible loops associated with each of the $g$ holes. All other non-contractible loops can be generated by deforming and joining elements of this basis. When we have spinors defined over $\Sigma_g$ we can assign them either periodic or anti-periodic boundary conditions around each of the $2g$ loops. Each of these $2^{2g}$ possible assignments is called a spin structure on $\Sigma_g$.
I can't see the relation between these two ideas. I mean, why the assignment of boundary conditions around each of the $2g$ loops will give rise to a spin structure in the sense of the definition above? Why these two things are the same?