Repository: numba/numba

Issue:
Python without --enable-shared raises libpython3.6.m.so ImportError on numba use
It seems like `numba` (when installed via `pip install`) requires a Python built with `--enable-shared`, but a (admittedly cursory) glance at the numba readme and the docs and issue tracker do not reveal that this is documented anywhere.

Specifically, when installing `resampy` (which now depends on `numba`) and using it, we get the following error upon importing:

```
...
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/__init__.py", line 12, in <module>
    from .special import typeof, prange
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/special.py", line 3, in <module>
    from .typing.typeof import typeof
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typing/__init__.py", line 2, in <m
odule>
    from .context import BaseContext, Context
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typing/context.py", line 10, in <m
odule>
    from numba.typeconv import Conversion, rules
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typeconv/rules.py", line 3, in <mo
dule>
    from .typeconv import TypeManager, TypeCastingRules
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typeconv/typeconv.py", line 3, in
<module>
    from . import _typeconv, castgraph, Conversion
ImportError: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
```

The key piece is `ImportError: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory`. Python built without `--enable-shared` doesn't have this file, so if this dependency is real (not spurious) then this should be documented somewhere.

If this is actually documented somewhere (and I just missed it), or this is a duplicate, please close this issue. Otherwise, adding a line in `README.md` about `--enable-shared`, or fixing the underlying reason for this bug, would be appreciated!
Python without --enable-shared raises libpython3.6.m.so ImportError on numba use
It seems like `numba` (when installed via `pip install`) requires a Python built with `--enable-shared`, but a (admittedly cursory) glance at the numba readme and the docs and issue tracker do not reveal that this is documented anywhere.

Specifically, when installing `resampy` (which now depends on `numba`) and using it, we get the following error upon importing:

```
...
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/__init__.py", line 12, in <module>
    from .special import typeof, prange
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/special.py", line 3, in <module>
    from .typing.typeof import typeof
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typing/__init__.py", line 2, in <m
odule>
    from .context import BaseContext, Context
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typing/context.py", line 10, in <m
odule>
    from numba.typeconv import Conversion, rules
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typeconv/rules.py", line 3, in <mo
dule>
    from .typeconv import TypeManager, TypeCastingRules
  File "/mnt/home/xyz/test_env/lib/python3.6/site-packages/numba/typeconv/typeconv.py", line 3, in
<module>
    from . import _typeconv, castgraph, Conversion
ImportError: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
```

The key piece is `ImportError: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory`. Python built without `--enable-shared` doesn't have this file, so if this dependency is real (not spurious) then this should be documented somewhere.

If this is actually documented somewhere (and I just missed it), or this is a duplicate, please close this issue. Otherwise, adding a line in `README.md` about `--enable-shared`, or fixing the underlying reason for this bug, would be appreciated!


Discussion:
I suspect this might be a problem with our wheels on PyPI.  When pip installed numba, could you tell whether it compile Numba from scratch, or used a binary wheel?
Relevant section from manylinux1 PEP:

https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
It is using a wheel:
```Collecting numba
  Using cached numba-0.35.0-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: numpy in /mnt/home/xyz/test_env/lib/python3.6/site-packages (from nu
mba)
Requirement already satisfied: llvmlite in /mnt/home/xyz/test_env/lib/python3.6/site-packages (from
 numba)
Installing collected packages: numba
Successfully installed numba-0.35.0
```
OK, thanks.  It looks like we need to build this wheel differently.
Alright. I don't think I have more helpful info to contribute here but I guess this isn't a doc request after all then :) 
I suspect this might be a problem with our wheels on PyPI.  When pip installed numba, could you tell whether it compile Numba from scratch, or used a binary wheel?
Relevant section from manylinux1 PEP:

https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
It is using a wheel:
```Collecting numba
  Using cached numba-0.35.0-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: numpy in /mnt/home/xyz/test_env/lib/python3.6/site-packages (from nu
mba)
Requirement already satisfied: llvmlite in /mnt/home/xyz/test_env/lib/python3.6/site-packages (from
 numba)
Installing collected packages: numba
Successfully installed numba-0.35.0
```
OK, thanks.  It looks like we need to build this wheel differently.
Alright. I don't think I have more helpful info to contribute here but I guess this isn't a doc request after all then :) 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -9,11 +9,16 @@
 
 from distutils.command import build
 from distutils.spawn import spawn
+from distutils import sysconfig
 import sys
 import os
 
 import versioneer
 
+if sys.platform.startswith('linux'):
+    # Patch for #2555 to make wheels without libpython
+    sysconfig.get_config_vars()['Py_ENABLE_SHARED'] = 0
+
 
 class build_doc(build.build):
     description = "build documentation"


Test patch: