esheldon / esutil

A variety of python utilities focusing on numerical, scientific, and astrophysical computing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

imp is deprecated

rmjarvis opened this issue · comments

I've started getting deprecation warnings from things that import esutil that the imp module is deprecated.

$ python -Wd
Python 3.6.10 | packaged by conda-forge | (default, Mar  5 2020, 09:56:10) 
[GCC Clang 9.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import esutil
/anaconda3/envs/py3/lib/python3.6/site-packages/esutil/htm/htmc.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp

I'm sure there is still lots of time before this stops working, but probably worth fixing. Looks pretty easy.

this file was generated by swig, probably just need to rerun with a new version of swig.

I reran swig, warnings seem to go away. Its in the master branch.

I can make a new release when you confirm it works for you

I hit an error installing from source on my laptop:

$ python setup.py install
running install
running build
running build_py
copying esutil/cosmology/cosmology.py -> build/lib.macosx-10.7-x86_64-3.6/esutil/cosmology
copying esutil/htm/htmc.py -> build/lib.macosx-10.7-x86_64-3.6/esutil/htm
copying esutil/unit_tests/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/esutil/unit_tests
copying esutil/unit_tests/pickle_tests.py -> build/lib.macosx-10.7-x86_64-3.6/esutil/unit_tests
running build_ext
building 'esutil.recfile._records' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/envs/py3/include -arch x86_64 -I/anaconda3/envs/py3/include -arch x86_64 -I/anaconda3/envs/py3/lib/python3.6/site-packages/numpy/core/include -Iesutil/include -Iesutil/recfile -Iesutil/htm -Iesutil/htm/htm_src -I/anaconda3/envs/py3/include/python3.6m -c esutil/recfile/records.cpp -o build/temp.macosx-10.7-x86_64-3.6/esutil/recfile/records.o -stdlib=libc++
gcc: error: unrecognized command line option ‘-stdlib=libc++’
error: command 'gcc' failed with exit status 1

But when I removed that, it worked, and the deprecation warning was gone.

The Mac libc++ thing is kind of a mess. For TreeCorr and GalSim, I've had to have it check the compilation and then maybe remove these flags if they don't work. They are certainly needed on some systems. :(

cf. https://github.com/rmjarvis/TreeCorr/blob/releases/4.1/setup.py#L326

I don't have a mac for testing. Are you interested in making a pull request?

Sure. If you don't mind, I can port over a version of what I did there.

sounds great, thanks

I don't have any issue installing the current master branch on a mac with either Python 3.6 or 3.7. I'm using clang though, maybe it's compiler specific.

Yes. It is compiler specific.

I can easily switch back and forth between clang and real gcc, so I can test both. Will submit a PR.