From: Ole Streicher <olebole@debian.org>
Date: Tue, 19 Dec 2017 17:23:10 +0100
Subject: Use system provided iraf by default

---
 pyraf/clcache.py       |  4 ++--
 pyraf/fill_clcache.py  |  3 ++-
 pyraf/iraffunctions.py | 13 +------------
 3 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/pyraf/clcache.py b/pyraf/clcache.py
index 77bf7b7..c336e1e 100644
--- a/pyraf/clcache.py
+++ b/pyraf/clcache.py
@@ -19,10 +19,10 @@ if 'PYRAF_CLCACHE_PATH' in os.environ:
         clcache_path = []
 else:
     # create code cache
-    userCacheDir = os.path.join(userIrafHome, 'pyraf')
+    userCacheDir = os.path.expanduser('~/.iraf/pyraf')
     if not os.path.exists(userCacheDir):
         try:
-            os.mkdir(userCacheDir)
+            os.makedirs(userCacheDir, exist_ok=True)
             if '-s' not in sys.argv and '--silent' not in sys.argv:
                 print(f'Created directory {userCacheDir} for cache')
         except OSError:
diff --git a/pyraf/fill_clcache.py b/pyraf/fill_clcache.py
index 122c918..0b3d3f6 100644
--- a/pyraf/fill_clcache.py
+++ b/pyraf/fill_clcache.py
@@ -9,7 +9,8 @@ def fill_clcache():
         clcache.clcache_path[-1], 'clcache')])
     n_compiled = 0
     n_fail = 0
-    for cl_script in glob.glob(os.path.join(os.environ['iraf'], '**/*.cl'),
+    for cl_script in glob.glob(os.path.join(os.environ.get('iraf', '/usr/lib/iraf'),
+                                            '**/*.cl'),
                                recursive=True):
         try:
             cl2py.cl2py(cl_script)
diff --git a/pyraf/iraffunctions.py b/pyraf/iraffunctions.py
index c03ab10..f3f7560 100644
--- a/pyraf/iraffunctions.py
+++ b/pyraf/iraffunctions.py
@@ -158,18 +158,7 @@ def Init(doprint=1, hush=0, savefile=None):
                         _os.environ[key] = value
                 iraf = _os.environ['iraf']
             except OSError:
-                raise OSError("""
-Your "iraf" environment variable is not defined and could not be
-determined from /usr/local/bin/cl.  This is are needed to find IRAF
-tasks.  Before starting pyraf, define ot by doing (for example):
-
-    export iraf=/iraf/iraf/
-
-at the Unix command line. Actual values will depend on your IRAF installation,
-and they are set during the IRAF user installation (see https://iraf-community.github.io).
-Also be sure to run the "mkiraf" command to create a logion.cl
-(http://www.google.com/search?q=mkiraf).
-""")
+                iraf = '/usr/lib/iraf/'
 
         arch = _os.environ.get('IRAFARCH', '')
 
