I started thinking a couple days ago about the example below, and it led me to ask the following question:
How (or when?) can we build a space (let's say a CW complex) with given homology groups and fundamental group? I know we can do either of these separately, but I couldn't do both simultaneously even for the simple example below. Also, can we have two such spaces $X, Y$ such that $X$ is not homotopy equivalent to $Y$?
EDIT: It's a necessary condition that the group we want as an $H_1$ is the abelianization of the one we want as $\pi_1$.
This is the example:
We want to know if it's possible to find a space $X$ (not homotopy equivalent to $\mathbb{T}^2$) such that $H_n(X) \cong H_n(\mathbb{T}^2)$ and $\pi_1(X) \cong \pi_1(\mathbb{T}^2) \cong \mathbb{Z}^2$.
For example, the space $X= S^2 \vee S^1 \vee S^1$ has the same homology as the torus, but has fundamental group $\mathbb{Z}\ast\mathbb{Z}$. I thought of attaching a $2$-cell to $X$ to add the relation $aba^{-1}b^{-1}$, but this ends up giving me $Y = S^2 \vee \mathbb{T}^2$, which has $H_2(Y) \cong \mathbb{Z}^2$, so it's not what I want.
Any hints would be appreciated, thanks in advance.
EDIT: It turns out a more general question was asked a few years ago. Qiaochu Yuan's answer goes a bit over my head right now, but it might be useful for someone else who comes across this.