esheldon / esutil

A variety of python utilities focusing on numerical, scientific, and astrophysical computing
GNU General Public License v2.0
35 stars 19 forks source link

imp is deprecated #49

Closed rmjarvis closed 4 years ago

rmjarvis commented 4 years ago

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.

esheldon commented 4 years ago

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

esheldon commented 4 years ago

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

rmjarvis commented 4 years ago

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.

rmjarvis commented 4 years ago

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

esheldon commented 4 years ago

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

rmjarvis commented 4 years ago

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

esheldon commented 4 years ago

sounds great, thanks

jobovy commented 4 years ago

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.

rmjarvis commented 4 years ago

Yes. It is compiler specific.

rmjarvis commented 4 years ago

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