getting a job with a PhD in (pure) mathematics Probably this concern has been addressed several times here but I will give a try to get other people's perspective from my situation. I am feeling sort of hopeless these times.

I am in my last year of my PhD in mathematics and doing my dissertation soon, my research was mainly devoted to algebraic topology and I made some progress in my advisor's particular area. However, I faced some problems during my studies (personal issues) and I never built a strong relationship with my advisor; so I could not finish all the initial research proposal intended for my PhD thesis.

I recently had a sincere talk with my advisor about my future, and he said that my progress is worth for a PhD thesis but it is not anything very surprising that is worth publishing, so I will be graduating with zero publications. He said that my chances of getting a PostDoc positions are really low and that I can not expect a strong recommendation letter from him. My advisor has a few collaborators (from overseas mainly) and none in the local department. He also never supervised another Master or PhD student while I was under his supervision, then I never got a chance to network or engage properly with other classmates. My advisor kindly suggested to explore other options in the job-market besides academia.

I like to explore new things, and in my free time during my studies I attended several teaching workshops, seminars and courses (I got a small degree in "university teaching"), and I am also familiar with Python, R, Matlab and Sage; however, I learn those things for fun and I have never really worked in 
a big project using any of that.

I do not know what to focus on and what kind of job should I look for after I finish my PhD

I would like to keep doing research in Math, but my area is not very popular lately and I feel that I have no chances of succeed getting a PostDoc; I also feel that I do not have (demonstrable) skills to perform a job with "real-life" applications so probably my chances getting there are also low. And I do not really know the Teaching job-market, I think that those positions are temporary and it would be hard to find a place that is willing to sponsor a work visa (I am not a US-citizen, and the job market in the third-world country that I am from is nonexistent for PhD's in this area)
Your supervisor is honest, blunt, and very helpful because by ruling out the academic path he's saving you a lot of time.

The bad news is it sounds like you screwed up your PhD. Not getting strong research results, not having diversified your PhD experience (e.g. lack of teaching experience makes it harder for you to get a teaching job), and not having a firm idea of what you want to do after the PhD means you sound lost right now. The good news is, chances are you learned more than you think you did, and those things are applicable to the job market.

First: don't think you have to do research. It is what you've been doing for the PhD, but it's not what you have to do in the future. Just consider this: if you like research + are good at it, why didn't you do better in the PhD? Why weren't you able to complete the initial research proposals, why weren't you able to get publishable results, why weren't you able to impress your supervisor such that he can write a strong letter of recommendation? You might have good reasons for these, and it's up to you to convince yourself that yes, you still want to do research, and yes, you are talented + motivated enough to succeed in it. 

If I were you, I'd start examining the possibility that I am not actually good at research and / or it is not what I want to do. Do some serious soul-searching here. You are making a life-altering decision. If it makes you feel bad that by leaving academia you are "failing", don't worry too much about it: there's a good chance that by leaving academia you'll have a more successful life (in terms of material possessions).

Second: go to your local jobs portal (use Google if you don't know what these are) and search for jobs that require a PhD in mathematics. Do you find anything that catches your fancy? For example searching on indeed.com for "phd math", I get this job among many others. Note the requirements:


  Preferred qualifications:
  MBA, Master's or PhD degree in a quantitative field. 
  
  Experience with stakeholder management and ability to influence senior stakeholders. 
  Demonstrated knowledge of statistics and data analysis including R programming or other statistical software packages. 


I highlighted the most relevant parts. You say you are familiar with R. That means you are in business! You can potentially do this job! If you further have experience with statistics and data analysis (do you?) you're in an even better position.

It's up to you to search the jobs portal for jobs you can do, and then it's up to you to apply. It's true that visa issues might sink your candidacy, but it's also true that because PhDs are relatively rare, you might have skills nobody else will have and therefore the employer is willing to sponsor you. You will not know unless you try.

Do remember that even if you can't find a US employer, you can still work elsewhere. It's a big world out there, and it's not true that third-world countries don't need your skills. Example of such a job in India (admittedly they're not looking for PhD-level candidates, but you could still apply).

Third: once you have an idea about what the options in industry are like, then you can start thinking about what you want to do. Are you sure you still want to do math research? If so I'd talk to your supervisor again about what options are available to you. He's already told you your prospects are not good, so you'll need all the help you can get from him. For example, perhaps you could find a position as a teaching assistant somewhere and do research in your spare time. This will not be easy - doing research while holding a full-time job is very difficult - and it's not likely to be well-paid, but if it's what you want to do, you can try.

On the other hand if you think industry will serve you better, then finish up your thesis &amp; defense and start applying for jobs. Be sure to visit your university's career center as well; they'll be able to help you a lot.