aboutsummaryrefslogtreecommitdiff
path: root/pyfits/pyfits-cfitsio.patch
blob: 64e7057ee195e611eacfe3378d71b8faa9040cf5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
diff -u -p --recursive a/pyfits-3.3/setup.py b/pyfits-3.3/setup.py
--- setup.py	2014-06-09 16:07:11.000000000 -0400
+++ setup.py	2015-07-05 20:46:43.071332734 -0400
@@ -1,15 +1,41 @@
 #!/usr/bin/env python
 
 try:
-    from setuptools import setup
+    from setuptools import setup, Extension
 except ImportError:
     from ez_setup import use_setuptools
     use_setuptools()
-    from setuptools import setup
+    from setuptools import setup, Extension
 
+import sys
+import subprocess
+
+
+PY3 = sys.version_info[0] == 3
+extra_compile_args = ['-Wall']
+extra_link_args = ['-lcfitsio']
+
+try:
+    if PY3:
+        extra_compile_args = subprocess.check_output(['pkg-config', '--cflags', 'cfitsio']).decode().split()
+        extra_link_args = subprocess.check_output(['pkg-config', '--libs', 'cfitsio']).decode().split()
+    else:
+        extra_compile_args = subprocess.check_output(['pkg-config', '--cflags', 'cfitsio']).split()
+        extra_link_args = subprocess.check_output(['pkg-config', '--libs', 'cfitsio']).split()
+except subprocess.CalledProcessError:
+    print('!!! pkg-config failure, skipping flag generation !!!')
+    pass
 
 setup(
     setup_requires=['d2to1>=0.2.12', 'stsci.distutils>=0.3'],
     d2to1=True,
-    zip_safe=False
+    use_2to3=True,
+    zip_safe=False,
+    ext_modules = [
+        Extension('pyfits.compression', ['src/compressionmodule.c'],
+                  include_dirs=['numpy'],
+                  extra_compile_args=extra_compile_args,
+                  extra_link_args=extra_link_args,
+                  optional=True)
+        ],
 )