Repository: yt-project/yt

Issue:
Fresh yt installation not importing
<!--To help us understand and resolve your issue, please fill out the form to
the best of your ability.-->
<!--You can feel free to delete the sections that do not apply.-->

### Bug report

**Bug summary**

yt fails to import on a fresh development installation. The error is that `ModuleNotFoundError: No module named 'yt.utilities.lib.misc_utilities'` Similar to [Issue 2685](https://github.com/yt-project/yt/issues/2685)
<!--A short 1-2 sentences that succinctly describes the bug-->

**Code for reproduction**
Installed using `pip install git+git://github.com/yt-project/yt.git`
<!--A minimum code snippet required to reproduce the bug, also minimizing the
number of dependencies required.-->

<!-- If you need to use a data file to trigger the issue you're having, consider
using one of the datasets from the yt data hub (http://yt-project.org/data). If
your issue cannot be triggered using a public dataset, you can use the yt
curldrop (https://docs.hub.yt/services.html#curldrop) to share data
files. Please include a link to the dataset in the issue if you use the
curldrop.-->

```python
import yt
```

**Actual outcome**

<!--The output produced by the above code, which may be a screenshot, console
output, etc.-->

```
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-2d2292a375dc> in <module>
----> 1 import yt

~/.conda/envs/ytgit/lib/python3.8/site-packages/yt/__init__.py in <module>
     63 )
     64 
---> 65 from yt.fields.api import (
     66     field_plugins,
     67     DerivedField,

~/.conda/envs/ytgit/lib/python3.8/site-packages/yt/fields/api.py in <module>
      1 # from . import species_fields
----> 2 from . import (
      3     angular_momentum,
      4     astro_fields,
      5     cosmology_fields,

~/.conda/envs/ytgit/lib/python3.8/site-packages/yt/fields/angular_momentum.py in <module>
      1 import numpy as np
      2 
----> 3 from yt.utilities.lib.misc_utilities import (
      4     obtain_position_vector,
      5     obtain_relative_velocity_vector,

ModuleNotFoundError: No module named 'yt.utilities.lib.misc_utilities'
```

**Expected outcome**

<!--A description of the expected outcome from the code snippet-->
<!--If this used to work in an earlier version of yt, please note the
version it used to work on-->

**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: CentOS Linux 7 (Core)x86_64
  * Python Version: 3.8.5
  * yt version: 4.0.dev0
  * Other Libraries (if applicable): N/A

<!--Please tell us how you installed yt and python e.g., from source,
pip, conda. If you installed from conda, please specify which channel you used
if not the default-->

Installed using `pip install git+git://github.com/yt-project/yt.git`


Thanks!


Discussion:
Hi!  One reason this often happens is if it isn't built.  But, pip
installing it like this should build.  Can you provide the full log output
from the pip install?

On Fri, Sep 4, 2020 at 10:32 AM Raziq Noorali <notifications@github.com>
wrote:

> Bug report
>
> *Bug summary*
>
> yt fails to import on a fresh development installation. The error is that ModuleNotFoundError:
> No module named 'yt.utilities.lib.misc_utilities'
>
> *Code for reproduction*
> Installed using pip install git+git://github.com/yt-project/yt.git
>
> # Paste your code here##import yt
>
> *Actual outcome*
>
> # If applicable, paste the console output here
> #
> #
>
> *Expected outcome*
>
> *Version Information*
>
>    - Operating System: CentOS Linux 7 (Core)x86_64
>    - Python Version: 3.8.5
>    - yt version: 4.0.dev0
>    - Other Libraries (if applicable): N/A
>
> Installed using pip install git+git://github.com/yt-project/yt.git
>
> Thanks!
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/yt-project/yt/issues/2892>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAAVXO7JCM3FCUAY7FJ3CGTSEECCRANCNFSM4QYVEXEQ>
> .
>

Hi @matthewturk. I apologize for the delay. In solidarity with the [graduate student strike at the University of Michigan](https://www.geo3550.org/2020/09/08/geo-is-on-strike/), I have not crossed imposed picket lines and am getting to this now. Please let me know if you need anything else!

log from pip install: 
```
$ pip install git+git://github.com/yt-project/yt.git
Collecting git+git://github.com/yt-project/yt.git
  Cloning git://github.com/yt-project/yt.git to /tmp/pip-req-build-m9_kw_3f
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting IPython>=1.0
  Downloading ipython-7.18.1-py3-none-any.whl (786 kB)
     |████████████████████████████████| 786 kB 5.6 MB/s 
Collecting unyt>=2.7.2
  Using cached unyt-2.7.2-py2.py3-none-any.whl (97 kB)
Collecting numpy>=1.10.4
  Downloading numpy-1.19.2-cp38-cp38-manylinux2010_x86_64.whl (14.5 MB)
     |████████████████████████████████| 14.5 MB 53.4 MB/s 
Requirement already satisfied: setuptools>=19.6 in ./.conda/envs/ytgit_test/lib/python3.8/site-packages (from yt==4.0.dev0) (49.6.0.post20200814)
Collecting matplotlib>=1.5.3
  Downloading matplotlib-3.3.2-cp38-cp38-manylinux1_x86_64.whl (11.6 MB)
     |████████████████████████████████| 11.6 MB 85.2 MB/s 
Collecting sympy>=1.2
  Using cached sympy-1.6.2-py3-none-any.whl (5.8 MB)
Collecting decorator
  Using cached decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting pexpect>4.3; sys_platform != "win32"
  Using cached pexpect-4.8.0-py2.py3-none-any.whl (59 kB)
Collecting pygments
  Downloading Pygments-2.7.1-py3-none-any.whl (944 kB)
     |████████████████████████████████| 944 kB 83.9 MB/s 
Collecting traitlets>=4.2
  Downloading traitlets-5.0.4-py3-none-any.whl (98 kB)
     |████████████████████████████████| 98 kB 5.3 MB/s 
Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0
  Downloading prompt_toolkit-3.0.7-py3-none-any.whl (355 kB)
     |████████████████████████████████| 355 kB 87.6 MB/s 
Collecting pickleshare
  Using cached pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
Collecting jedi>=0.10
  Using cached jedi-0.17.2-py2.py3-none-any.whl (1.4 MB)
Collecting backcall
  Using cached backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Collecting python-dateutil>=2.1
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting cycler>=0.10
  Using cached cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting pillow>=6.2.0
  Using cached Pillow-7.2.0-cp38-cp38-manylinux1_x86_64.whl (2.2 MB)
Collecting kiwisolver>=1.0.1
  Using cached kiwisolver-1.2.0-cp38-cp38-manylinux1_x86_64.whl (92 kB)
Requirement already satisfied: certifi>=2020.06.20 in ./.conda/envs/ytgit_test/lib/python3.8/site-packages (from matplotlib>=1.5.3->yt==4.0.dev0) (2020.6.20)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Processing ./.cache/pip/wheels/29/2c/1c/d2e4580cde2743b0aef389e936ac21a2db92921ddbca53faa1/mpmath-1.1.0-py3-none-any.whl
Collecting ptyprocess>=0.5
  Using cached ptyprocess-0.6.0-py2.py3-none-any.whl (39 kB)
Collecting ipython-genutils
  Using cached ipython_genutils-0.2.0-py2.py3-none-any.whl (26 kB)
Collecting wcwidth
  Using cached wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
Collecting parso<0.8.0,>=0.7.0
  Using cached parso-0.7.1-py2.py3-none-any.whl (109 kB)
Collecting six>=1.5
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Building wheels for collected packages: yt
  Building wheel for yt (PEP 517) ... done
  Created wheel for yt: filename=yt-4.0.dev0-py3-none-any.whl size=1857377 sha256=648b2cef24207a5d158b0c61c76a0f8723c97e6a235036c578870ae2e4197267
  Stored in directory: /tmp/pip-ephem-wheel-cache-p6pus6eo/wheels/de/5c/c8/8c939833284c1c193ca0f3dda036b9ea66c6e4089174dace55
Successfully built yt
Installing collected packages: decorator, ptyprocess, pexpect, pygments, ipython-genutils, traitlets, wcwidth, prompt-toolkit, pickleshare, parso, jedi, backcall, IPython, numpy, mpmath, sympy, unyt, six, python-dateutil, cycler, pillow, kiwisolver, pyparsing, matplotlib, yt
Successfully installed IPython-7.18.1 backcall-0.2.0 cycler-0.10.0 decorator-4.4.2 ipython-genutils-0.2.0 jedi-0.17.2 kiwisolver-1.2.0 matplotlib-3.3.2 mpmath-1.1.0 numpy-1.19.2 parso-0.7.1 pexpect-4.8.0 pickleshare-0.7.5 pillow-7.2.0 prompt-toolkit-3.0.7 ptyprocess-0.6.0 pygments-2.7.1 pyparsing-2.4.7 python-dateutil-2.8.1 six-1.15.0 sympy-1.6.2 traitlets-5.0.4 unyt-2.7.2 wcwidth-0.2.5 yt-4.0.dev0
``` 


What is the output of the following two commands?
```
which pip
which python
```
Also, it may prove useful to provide the log using `pip install --verbose git+git://github.com/yt-project/yt.git`.
Sure!
```
(ytgit_test) [rnoorali@gl-login2 ~]$ which pip
~/.conda/envs/ytgit_test/bin/pip
(ytgit_test) [rnoorali@gl-login2 ~]$ which python
~/.conda/envs/ytgit_test/bin/python
```

The verbose log is quite long, soft the sake of readability I attached it here
[pip_log.txt](https://github.com/yt-project/yt/files/5263879/pip_log.txt)

> Sure!
> 
> ```
> (ytgit_test) [rnoorali@gl-login2 ~]$ which pip
> ~/.conda/envs/ytgit_test/bin/pip
> (ytgit_test) [rnoorali@gl-login2 ~]$ which python
> ~/.conda/envs/ytgit_test/bin/python
> ```
> 
> The verbose log is quite long, soft the sake of readability I attached it here
> [pip_log.txt](https://github.com/yt-project/yt/files/5263879/pip_log.txt)

Alright, this looks definitely like a bug on yt's side: yt relies on some files that need to be compiled (for higher efficiency). However, for some reason they do not get compiled when one installs using the command you tried (I can reproduce this on my side).

In the meantime, you should be able to install with the following commands:
```bash
$ cd /path/to/where/yt/will/be
$ git clone https://github.com/yt-project/yt.git
$ cd yt
$ pip install -e .
```
So after some debugging, it turns out that yt cannot be installed unless `-e` is specified in the pip command, _i.e._
```bash
pip install -e git+https://github.com/yt-project/yt.git#egg=yt   # works
pip install git+https://github.com/yt-project/yt.git#egg=yt      # does not compile the cython files
```
This stems from the fact that `pip install whatever` without `-e` does not call our custom version of `build_ext.build_extensions`.
Hi @Provider10 , would it be possible to try out the bugfix I submitted and tell me if this works for you?
In order to do so, use the following script
```
pip install git+git://github.com/cphyc/yt.git@bugfix/2892     #note the different URL!
```
Hi @cphyc. The above command gave the following output:

```
Collecting git+git://github.com/cphyc/yt.git@bugfix/2892
  Cloning git://github.com/cphyc/yt.git (to revision bugfix/2892) to /tmp/pip-req-build-8pqa2yj1
  WARNING: Did not find branch or tag 'bugfix/2892', assuming revision or ref.
ERROR: Command errored out with exit status 1: git checkout -q bugfix/2892 Check the logs for full command output.
``` 

Since I see the above was merged I also checked the current master branch (4d9ab24) and got a _new_ error when I try to import yt:

```
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-2d2292a375dc> in <module>
----> 1 import yt

~/.conda/envs/ytgit_test3/lib/python3.8/site-packages/yt/__init__.py in <module>
     63 )
     64 
---> 65 from yt.fields.api import (
     66     field_plugins,
     67     DerivedField,

~/.conda/envs/ytgit_test3/lib/python3.8/site-packages/yt/fields/api.py in <module>
      1 # from . import species_fields
----> 2 from . import (
      3     angular_momentum,
      4     astro_fields,
      5     cosmology_fields,

~/.conda/envs/ytgit_test3/lib/python3.8/site-packages/yt/fields/angular_momentum.py in <module>
      1 import numpy as np
      2 
----> 3 from yt.utilities.lib.misc_utilities import (
      4     obtain_position_vector,
      5     obtain_relative_velocity_vector,

~/.conda/envs/ytgit_test3/lib/python3.8/site-packages/yt/utilities/lib/misc_utilities.pyx in init yt.utilities.lib.misc_utilities()

~/.conda/envs/ytgit_test3/lib/python3.8/site-packages/yt/geometry/oct_container.pyx in init yt.geometry.oct_container()

~/.conda/envs/ytgit_test3/lib/python3.8/site-packages/yt/geometry/oct_visitors.pyx in init yt.geometry.oct_visitors()

~/.conda/envs/ytgit_test3/lib/python3.8/site-packages/yt/geometry/selection_routines.pyx in init yt.geometry.selection_routines()

ModuleNotFoundError: No module named 'yt.utilities.lib.image_samplers'
```

I'd like to recommend that this issue be reopened
That is embarrassing. Can you confirm that if you clone the yt repository and install _via_ `pip install -e .` it works?
Lol sorry about that! When installing as in your [above suggestion](https://github.com/yt-project/yt/issues/2892#issuecomment-697262490), I get the following error message (send via text log to save space).
[pip_log.txt](https://github.com/yt-project/yt/files/5284337/pip_log.txt)

Thanks for taking the time to go through this with me! I really appreciate it 

The pip command you should try `pip install -e .` after having cloned the repository. The log you sent me used `pip install --verbose git+git://github.com/yt-project/yt.git` instead. Note that the latter should _also_ work, so you definitely found a bug!
Ah, my apologies for sending you a novel-length log then. I'm afraid I'm not versed enough in yt to be able to attempt a bigfix, but please let me know how I can help! 
Hello! I get this error too after a fresh installation of the most recent **_master_** branch of yt, and when I try to import yt.

**pip version : pip 20.2.3** 
**python version : Python 3.7.9**
**setuptools version : setuptools 50.3.0**

When i git cloned yt, and checkout out `master`, 
`pip3 install -e . --user `

I get the following error
```
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/rjambunathan/Documents/SOFTWARES/yt/setup.py'"'"'; __file__='"'"'/home/rjambunathan/Documents/SOFTWARES/yt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
         cwd: /home/rjambunathan/Documents/SOFTWARES/yt/
    Complete output (29 lines):
    Using OpenMP to compile parallel extensions
    running develop
    WARNING: The user site-packages directory is disabled.
    error: can't create or remove files in install directory
    
    The following error occurred while trying to add or remove files in the
    installation directory:
    
        [Errno 13] Permission denied: '/usr/local/lib/python3.7/dist-packages/test-easy-install-25156.write-test'
    
    The installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:
    
        /usr/local/lib/python3.7/dist-packages/
    
    Perhaps your account does not have write access to this directory?  If the
    installation directory is a system-owned directory, you may need to sign in
    as the administrator or "root" account.  If you do not have administrative
    access to this machine, you may wish to choose a different installation
    directory, preferably one that is listed in your PYTHONPATH environment
    variable.
    
    For information on other options, you may wish to consult the
    documentation at:
    
      https://setuptools.readthedocs.io/en/latest/easy_install.html
    
    Please make the appropriate changes for your system and try again.
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/rjambunathan/Documents/SOFTWARES/yt/setup.py'"'"'; __file__='"'"'/home/rjambunathan/Documents/SOFTWARES/yt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
```

Please let me know if there is any other detail that may help to fix this or if there is something that I can fix in my python environment setup.

> In the meantime, you should be able to install with the following commands:
> ...
> `pip install -e .`

Just a note as @RevathiJambunathan is encountering the same issue as the OP and we debugged it together offline a bit.

I would focus on the issue with `pip install git+git://github.com/yt-project/yt.git` because:
- editable installs via `pip install -e .` do NOT work anymore for PEP517 enabled projects like yt: [[1]](https://www.python.org/dev/peps/pep-0517/#get-requires-for-build-sdist) [[2]](https://github.com/pypa/pip/issues/7953#issuecomment-646588548)
  - I guess some of the reports here are still working for editable installs if people have old, non-PEP517 enabled pip versions installed
  - in fact, `pip install .` is not the right way with PEP517 either anymore -.- (forgot the citation)
  - before continuing to debug further, let's all update to the latest pip: `python3 -m pip install -U pip`
- for a local install, pip works like this in the age of PEP517:
```bash
# cleaning up
python3 -m pip uninstall yt
# upgrading important basics
python3 -m pip install -U pip setuptools wheel
python3 -m pip install -U cython

# this is our life now
python3 -m pip wheel .
python3 -m pip install *whl
```
(apply `--user` as needed if you are outside of virtual envs)
- alternatively, someone suggested `python3 -m pip install --no-use-pep517 -e .` to  get back editable installs [[3]](https://github.com/pypa/pip/issues/7953#issuecomment-676600130) (pep517 is the future, consider this is a hack)
  - note that uninstalling already present editable installs can be tricky: [[4]](https://stackoverflow.com/questions/17346619/how-to-uninstall-editable-packages-with-pip-installed-with-e)
- for debugging the issue, the output of
  - `python3 -m pip wheel -v .` might be useful to post here
`pip wheel -v . 2>&1 | tee build.log`
gives 
[build.log](https://github.com/yt-project/yt/files/5344740/build.log)

upon "grepping" for error I get :+1: 
[grepping_error.txt](https://github.com/yt-project/yt/files/5344747/grepping_error.txt)

**the gcc version is - gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609**


It looks like the GCC 5.4.0 compiler does not recognize the compiled files as C++11 in those setups:
https://github.com/yt-project/yt/blob/88597474c2f49d527941ac8d13296044a2dc3f59/yt/utilities/lib/ewahboolarray/ewah.h#L626-L628
```
  yt/utilities/lib/ewahboolarray/ewah.h:626:31: error: expected ‘,’ or ‘...’ before ‘&&’ token
  yt/utilities/lib/ewahboolarray/ewah.h:626:38: error: invalid constructor; you probably meant ‘EWAHBoolArray<uword> (const EWAHBoolArray<uword>&)’
```

This might not occur in CI or on newer systems, because GCC 6+ default to C++14: https://gist.github.com/ax3l/53db9fa8a4f4c21ecc5c4100c0d93c94

Checking the history of that file, it looks like #2575 introduced this with an update of [EWAHBoolArray](https://github.com/lemire/EWAHBoolArray), which defaults to C++11 in newer versions.

The solution would probably be to add `-std=c++<N>` flags explicitly in yt's build system. It's confusing though, because #2575 adds `extra_compile_args=["-std=c++11"])` in `setup.py`. Does it need to be added to further `Extension`s that include the same header? Or the problem came in with recent changes to the `setup.py` compiler flags, e.g. #2610

I can reproduce this on newer Ubuntu's by running:
```bash
export CC=$(which gcc-5)
export CXX=$(which g++-5)
python3 -m pip wheel -v .
```

A related challenge/bug in this issue: this is clearly an error in the build process. A build error of a component/extension should abort the whole installation, instead of silently installing an incomplete version of `yt`.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,7 @@
 import glob
 import os
 import sys
+from collections import defaultdict
 from distutils.ccompiler import get_default_compiler
 from distutils.version import LooseVersion
 
@@ -36,20 +37,24 @@
 with open("README.md") as file:
     long_description = file.read()
 
-if check_for_openmp():
-    omp_args = ["-fopenmp"]
-else:
-    omp_args = []
+CPP14_CONFIG = defaultdict(
+    lambda: ["-std=c++14"], {"unix": ["-std=c++14"], "msvc": ["/std:c++14"]}
+)
+CPP03_CONFIG = defaultdict(
+    lambda: ["-std=c++03"], {"unix": ["-std=c++03"], "msvc": ["/std:c++03"]}
+)
+
+_COMPILER = get_default_compiler()
+
+omp_args, _ = check_for_openmp()
 
 if os.name == "nt":
     std_libs = []
 else:
     std_libs = ["m"]
 
-if get_default_compiler() == "msvc":
-    CPP14_FLAG = ["/std:c++14"]
-else:
-    CPP14_FLAG = ["--std=c++14"]
+CPP14_FLAG = CPP14_CONFIG[_COMPILER]
+CPP03_FLAG = CPP03_CONFIG[_COMPILER]
 
 cythonize_aliases = {
     "LIB_DIR": "yt/utilities/lib/",
@@ -65,6 +70,7 @@
     "FIXED_INTERP": "yt/utilities/lib/fixed_interpolator.cpp",
     "ARTIO_SOURCE": glob.glob("yt/frontends/artio/artio_headers/*.c"),
     "CPP14_FLAG": CPP14_FLAG,
+    "CPP03_FLAG": CPP03_FLAG,
 }
 
 lib_exts = [
diff --git a/setupext.py b/setupext.py
--- a/setupext.py
+++ b/setupext.py
@@ -59,7 +59,8 @@ def stdchannel_redirected(stdchannel, dest_filename):
 
 
 def check_for_openmp():
-    """Returns True if local setup supports OpenMP, False otherwise
+    """Returns OpenMP compiler and linker flags if local setup supports
+    OpenMP or [], [] otherwise
 
     Code adapted from astropy_helpers, originally written by Tom
     Robitaille and Curtis McCully.
@@ -72,15 +73,17 @@ def check_for_openmp():
     tmp_dir = tempfile.mkdtemp()
     start_dir = os.path.abspath(".")
 
+    # TODO: test more known compilers:
+    # MinGW, AppleClang with libomp, MSVC, ICC, XL, PGI, ...
     if os.name == "nt":
         # TODO: make this work with mingw
         # AFAICS there's no easy way to get the compiler distutils
         # will be using until compilation actually happens
-        compile_flag = "-openmp"
-        link_flag = ""
+        compile_flags = ["-openmp"]
+        link_flags = [""]
     else:
-        compile_flag = "-fopenmp"
-        link_flag = "-fopenmp"
+        compile_flags = ["-fopenmp"]
+        link_flags = ["-fopenmp"]
 
     try:
         os.chdir(tmp_dir)
@@ -93,12 +96,12 @@ def check_for_openmp():
         # Compile, link, and run test program
         with stdchannel_redirected(sys.stderr, os.devnull):
             ccompiler.compile(
-                ["test_openmp.c"], output_dir="objects", extra_postargs=[compile_flag]
+                ["test_openmp.c"], output_dir="objects", extra_postargs=compile_flags
             )
             ccompiler.link_executable(
                 glob.glob(os.path.join("objects", "*")),
                 "test_openmp",
-                extra_postargs=[link_flag],
+                extra_postargs=link_flags,
             )
             output = (
                 subprocess.check_output("./test_openmp")
@@ -136,7 +139,10 @@ def check_for_openmp():
             "extensions will be compiled without parallel support"
         )
 
-    return using_openmp
+    if using_openmp:
+        return compile_flags, link_flags
+    else:
+        return [], []
 
 
 def check_for_pyembree(std_libs):


Test patch: