| """Tiny package whose only purpose is to drop transformers_shim.pth into | |
| site-packages. Python loads .pth files at interpreter startup, before the | |
| HF inference toolkit's `webservice_starlette` imports — so we get a hook | |
| to patch transformers BEFORE the toolkit's old API call tries to import | |
| names that 5.x dropped. | |
| setuptools' data_files paths are relative to the install prefix ("data" | |
| scheme path). To land the .pth in purelib (site-packages) we compute the | |
| relative path from data → purelib at build time. Pip builds the wheel | |
| on the target machine when given `./shim` so this resolves correctly. | |
| """ | |
| import os | |
| from sysconfig import get_paths | |
| from setuptools import setup | |
| paths = get_paths() | |
| pth_dest = os.path.relpath(paths["purelib"], paths["data"]) | |
| setup( | |
| name="transformers-shim", | |
| version="0.1.0", | |
| py_modules=["transformers_shim_runtime"], | |
| data_files=[(pth_dest, ["transformers_shim.pth"])], | |
| ) | |