Repository: scipy/scipy

Issue:
Build adds the user folder inside the code base
After building the SciPy on Windows 10, the base folder has a copy of the following folder

```
C:\Users\<user>\Documents\GitHub\scipy\Users\<user>\AppData\Local\Temp\tmpuvtg6i4i\main.obj
```
From the look of the structure, it seems like a relative folder is used instead of an absolute one hence it recreates the temp folder within the codebase. 

<strike>I think this might be related to the pocketfft development as I recently started to see it but might also be another C++ source change.</strike> Happens at the `cluster._optimal_leaf_ordering` compilation




Discussion:
Indeed I found a single occasion of this in the Azure Builds; [the relevant line 7504](https://dev.azure.com/scipy-org/SciPy/_build/results?buildId=1962&view=logs&jobId=9f3e9a58-f4d0-59eb-bb9a-f7c4195515fd&taskId=3f2368df-c5ac-559f-8d45-ab15fba3fe6b&lineStart=7504&lineEnd=7505&colStart=1&colEnd=1)

```
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\hostedtoolcache\windows\python\3.7.2\x64\include -Ic:\hostedtoolcache\windows\python\3.7.2\x64\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE -IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt /EHsc /TpC:\Users\VSSADM~1\AppData\Local\Temp\tmp8cd8dhtf\main.cpp /FoUsers\VSSADM~1\AppData\Local\Temp\tmp8cd8dhtf\main.obj /std:c++14
```

At the end `/Fo` should also have the `C:\` prefix I guess.
I think it's likely to be from here:
https://github.com/scipy/scipy/blob/492e7f8e95ef23754b74731ca1af34a4e4288602/scipy/fft/_pocketfft/setup.py#L10-L18

buildutils must have some issue with building a file outside of the project directory.


@ilayn are you building scipy inplace?
Yes but this was not the case before so I'm trying to find the changes around the build scripts. Azure also has this hiccup now anyways.
I've had a look at distutils, it's due to how they construct object file output paths. They are always relative to the build directory:

https://github.com/python/cpython/blob/c8e7146de257930ea8d0d4aa74b3a64fcaa79d4b/Lib/distutils/ccompiler.py#L851-L853

Hmm that suggests that we are now entering into objects branches that we have not been entering before. 

Resolving patch:
diff --git a/scipy/fft/_pocketfft/setup.py b/scipy/fft/_pocketfft/setup.py
--- a/scipy/fft/_pocketfft/setup.py
+++ b/scipy/fft/_pocketfft/setup.py
@@ -13,7 +13,7 @@ def try_compile(compiler, code=None, flags=[], ext='.cpp'):
             f.write(code)
 
         try:
-            compiler.compile([fname], extra_postargs=flags)
+            compiler.compile([fname], output_dir=temp_dir, extra_postargs=flags)
         except CompileError:
             return False
     return True


Test patch: