bwinkel / pycraf

pycraf is a package that provides functions and procedures for various tasks in spectrum-management compatibility studies.
35 stars 15 forks source link

Python2 compatibility? #4

Closed mpeel closed 3 years ago

mpeel commented 6 years ago

Is it possible to make this package compatible with python2? Trying to compile using pip on a python2 system gives the error message:

Complete output from command python setup.py egg_info:
ERROR: Python (3, 5) or later is required by astropy-helpers

Commenting out lines 48-53 of ah_bootstrap.py means that it compiles OK (with astropy-helpers v2 installed), however running 'import pycraf' then throws the error: File "pycraf/utils/multistate.py", line 38 class MultiState(object, metaclass=_MultiMeta): ^ SyntaxError: invalid syntax so it looks like the main code isn't python2 compatible at the moment.

bwinkel commented 6 years ago

Hi @mpeel,

pycraf is a rather young package and when I started it, I deliberately chose to make it Python-3, only. I'm making heavy use of other libraries such as numpy, astropy and the like. You may know, that all of these will phase out Python-2 support rather soon. This, and the fact that it is quite a bit of work to maintain both Python 2 and 3 support, led me to this decision.

I'm quite sure that you have very good reasons to still use Python 2. I don't know what your constraints are. Is there any chance that you could just install an up-to-date Anaconda distribution with Python 3 support. Or do you need to integrate pycraf into legacy software? Depending on this, perhaps I can think of a solution, e.g., to help you backporting just one or two modules that you need. (However, I won't provide any support to that in the mid-term due to my limited resources.

mpeel commented 6 years ago

Thanks for the quick response - and sorry for only just spotting the notification! I've ended up using pyenv to set up python 3 on my machine (I use v2 for most things, but I'm looking to write new code to use pyfits, if it works).

Two odd issues. I'm installing it using pip. The first is that pytest doesn't seem to be a dependency, so it's not installed automatically - although that's simple to work around. However, I then get the error below, which I'm not sure how to fix.

$ python Python 3.6.5 (default, Jun 6 2018, 13:33:50) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import pycraf WARNING: AstropyDeprecationWarning: astropy.utils.compat.funcsigs is now deprecated - use inspect instead [astropy.utils.compat.funcsigs] Traceback (most recent call last): File "", line 1, in File "/Users/mpeel/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pycraf/init.py", line 25, in from . import pathprof File "/Users/mpeel/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pycraf/pathprof/init.py", line 11, in from .cyprop import * ImportError: dlopen(/Users/mpeel/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pycraf/pathprof/cyprop.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libgomp.1.dylib Referenced from: /Users/mpeel/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pycraf/pathprof/cyprop.cpython-36m-darwin.so Reason: image not found exit() $ pip list Package Version


astropy 3.0.3
atomicwrites 1.1.5
attrs 18.1.0 cycler 0.10.0 Cython 0.28.3 kiwisolver 1.0.1
matplotlib 2.2.2
more-itertools 4.2.0
numpy 1.14.3 pip 10.0.1 pluggy 0.6.0
py 1.5.3
pycraf 0.25.6 pyparsing 2.2.0
pytest 3.6.1
python-dateutil 2.7.3
pytz 2018.4 scipy 1.1.0
setuptools 39.0.1 six 1.11.0

bwinkel commented 6 years ago

I guess, you're working on MacOS... Have you followed the instructions for this? I've had lots of trouble with MacOS myself. An alternative would be to try the Anaconda distribution, where chances are higher that after "conda install -c conda-forge openmp" the pip-installation works.

Please let me know, if that doesn't solve your problem.