Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toast.__init__ fails an exception #314

Closed
keskitalo opened this issue Nov 27, 2019 · 4 comments
Closed

toast.__init__ fails an exception #314

keskitalo opened this issue Nov 27, 2019 · 4 comments

Comments

@keskitalo
Copy link
Member

Should import toast fail, the exception handling seems to have some stale code that looks for file called RELEASE two levels higher than the root directory: https://github.com/hpc4cmb/toast/blob/master/src/toast/__init__.py#L24-L35

@tskisner
Copy link
Member

That is not stale code- it is used installing the code with setup.py during generating the documentation on readthedocs.

@keskitalo
Copy link
Member Author

Excellent. However, it still fails if there is any issue importing toast:

In [1]: import toast                                                                                                                                                               
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~/Software/macports/lib/python3.7/site-packages/toast/__init__.py in <module>
     19 try:
---> 20     from ._libtoast import Environment
     21 

ImportError: dlopen(/Users/reijo/Software/macports/lib/python3.7/site-packages/toast/_libtoast.cpython-37m-darwin.so, 2): Symbol not found: __ZN3atm10AtmProfileC1ERKNS_6LengthERKNS_8PressureERKNS_11TemperatureEdRKNS_7PercentES3_S6_dS3_m
  Referenced from: /Users/reijo/Software/macports/lib/python3.7/site-packages/toast/_libtoast.cpython-37m-darwin.so
  Expected in: flat namespace
 in /Users/reijo/Software/macports/lib/python3.7/site-packages/toast/_libtoast.cpython-37m-darwin.so

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-1-548f5c417892> in <module>
----> 1 import toast

~/Software/macports/lib/python3.7/site-packages/toast/__init__.py in <module>
     31     thisdir = os.path.abspath(os.path.dirname(__file__))
     32     relfile = os.path.join(thisdir, "..", "..", "RELEASE")
---> 33     with open(relfile, "r") as rel:
     34         if __version__ is None:
     35             __version__ = rel.readline().rstrip()

FileNotFoundError: [Errno 2] No such file or directory: '/Users/reijo/Software/macports/lib/python3.7/site-packages/toast/../../RELEASE'

@tskisner
Copy link
Member

Ok, we should have an additional try / except around parsing the RELEASE file and raise ImportError so that it propagates back to the calling code.

@tskisner
Copy link
Member

This old issue was fixed some time ago in #350. If the compiled extension is not importable to get the version and also the RELEASE file is not readable, then it raises ImportError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants