|
2 | 2 |
|
3 | 3 | import os |
4 | 4 | from distutils.sysconfig import get_python_inc |
| 5 | +from subprocess import check_output, CalledProcessError, DEVNULL |
5 | 6 |
|
6 | 7 |
|
7 | 8 | try: |
@@ -136,16 +137,23 @@ def main(auto_config=False): |
136 | 137 | ]) |
137 | 138 |
|
138 | 139 | print('Hunting dependencies...') |
139 | | - incdirs = ['/usr/local/include', '/opt/homebrew/include'] |
140 | | - incdirs.extend(['/usr/local/include/SDL2', '/opt/homebrew/include/SDL2', '/opt/local/include/SDL2']) |
| 140 | + |
| 141 | + homebrew_prefix = '/opt/homebrew' |
| 142 | + try: |
| 143 | + homebrew_prefix = check_output(['brew', '--prefix'], text=True, stderr=DEVNULL).strip() |
| 144 | + except (FileNotFoundError, CalledProcessError): |
| 145 | + pass |
| 146 | + |
| 147 | + incdirs = ['/usr/local/include', f'{homebrew_prefix}/include'] |
| 148 | + incdirs.extend(['/usr/local/include/SDL2', f'{homebrew_prefix}/include/SDL2', '/opt/local/include/SDL2']) |
141 | 149 |
|
142 | 150 | incdirs.extend([ |
143 | 151 | #'/usr/X11/include', |
144 | 152 | '/opt/local/include', |
145 | 153 | '/opt/local/include/freetype2/freetype'] |
146 | 154 | ) |
147 | 155 | #libdirs = ['/usr/local/lib', '/usr/X11/lib', '/opt/local/lib'] |
148 | | - libdirs = ['/usr/local/lib', '/opt/local/lib', '/opt/homebrew/lib'] |
| 156 | + libdirs = ['/usr/local/lib', '/opt/local/lib', f'{homebrew_prefix}/lib'] |
149 | 157 |
|
150 | 158 | for d in DEPS: |
151 | 159 | if isinstance(d, (list, tuple)): |
|
0 commit comments