|
18 | 18 | from distutils.command.sdist import sdist |
19 | 19 | from distutils.cmd import Command |
20 | 20 | from distutils.dir_util import remove_tree |
21 | | -from distutils.sysconfig import get_python_inc, get_python_lib |
| 21 | +from distutils.sysconfig import get_python_inc |
22 | 22 | from distutils import log |
23 | 23 | import os, os.path |
24 | 24 | import glob |
@@ -103,6 +103,17 @@ def recursive_package_data(src, package_dir='overviewer_core'): |
103 | 103 |
|
104 | 104 | return ret |
105 | 105 |
|
| 106 | +# Finds the system-wide path from within a venv. |
| 107 | +# Taken from https://github.com/pyinstaller/pyinstaller/blob/master/PyInstaller/hooks/pre_find_module_path/hook-distutils.py |
| 108 | +def find_system_module_path(): |
| 109 | + # opcode is not a virtualenv module, so we can use it to find the stdlib. Technique taken from virtualenv's |
| 110 | + # "distutils" package detection at |
| 111 | + # https://github.com/pypa/virtualenv/blob/16.3.0/virtualenv_embedded/distutils-init.py#L5 |
| 112 | + import opcode |
| 113 | + |
| 114 | + system_module_path = os.path.normpath(os.path.dirname(opcode.__file__)) |
| 115 | + return system_module_path |
| 116 | + |
106 | 117 | # |
107 | 118 | # py2exe options |
108 | 119 | # |
@@ -183,10 +194,20 @@ def recursive_package_data(src, package_dir='overviewer_core'): |
183 | 194 | c_overviewer_files = ['overviewer_core/src/' + s for s in c_overviewer_files] |
184 | 195 | c_overviewer_includes = ['overviewer_core/src/' + s for s in c_overviewer_includes] |
185 | 196 |
|
| 197 | +# really ugly hack for our scuffed CI, remove this once we move |
| 198 | +# to something else. The problem is that virtualenv somehow |
| 199 | +# now overrides the base_prefix (which it shouldn't do) which |
| 200 | +# makes distutils unable to find our Python library |
| 201 | +python_lib_dir = "" |
| 202 | +if platform.system() == 'Windows': |
| 203 | + ci_python_dir = os.path.split(find_system_module_path())[0] |
| 204 | + python_lib_dir = os.path.join(ci_python_dir, "Libs") |
| 205 | + |
186 | 206 | setup_kwargs['ext_modules'].append(Extension( |
187 | 207 | 'overviewer_core.c_overviewer', |
188 | 208 | c_overviewer_files, |
189 | 209 | include_dirs=['.', numpy_include] + pil_include, |
| 210 | + library_dirs=[python_lib_dir], |
190 | 211 | depends=c_overviewer_includes, |
191 | 212 | extra_link_args=[] |
192 | 213 | )) |
@@ -296,9 +317,6 @@ def build_extensions(self): |
296 | 317 | e.extra_link_args.append("/MANIFEST") |
297 | 318 | e.extra_link_args.append("/DWINVER=0x060") |
298 | 319 | e.extra_link_args.append("/D_WIN32_WINNT=0x060") |
299 | | - # workaround for our extremely shitty build system |
300 | | - # yeet this into a fire once we move to github actions |
301 | | - e.extra_link_args.append("/LIBPATH:C:\Python37\Libs") |
302 | 320 | if c == "unix": |
303 | 321 | # customize the build options for this compilier |
304 | 322 | for e in self.extensions: |
|
0 commit comments