• Zeyi (Rice) Fan's avatar
    make fb_py_win_main to dynamically find Python3.dll · 59701670
    Zeyi (Rice) Fan authored
    Summary:
    In EdenFS's latest Windows package. We are seeing DLL import errors coming from `asyncio` as it requires a system native module `_overlapped.pyd`.
    
    The underlying cause is because when we build EdenFS CLI on Sandcastle, we are linking with Python 3.6.2. The Python36.dll shipped with the EdenFS package is also coming from that version.
    
    However, on Windows laptop. We have Python 3.6.3. Since we are not shipping the Python system libraries with us. It uses the libraries installed in the system, and it attempts to import the `_overlapped.pyd` located at `C:\Pythone36\DLLs\`. This version is compiled against Python 3.6.3, which is incompatible with the Python36.dll we are using.
    
    ----
    
    To resolve this, we need either ship an embedded copy of Python along with EdenFS, or teach EdenFS to use the Python distribution installed in the system. This commit tweaks the executable we prepend to the archive created with zipapp to locate `Python3.dll` dynamically. This allows us to use the Python installed in the system so we can avoid the version mismatch issue.
    
    With this setup, we can also be shipping an embedded Python version along with EdenFS, and the Python loader can look for that path. This is demonstrated with the relative DLL loading `..\python`.
    
    In theory, we can have a package structure like this:
    
    ```
    .
    ├── python
    │   ├── ....
    │   └── python3.dll
    └── bin
        ├── ...
        ├── edenfsctl.exe
        └── edenfs.exe
    ```
    
    Reviewed By: xavierd
    
    Differential Revision: D22325210
    
    fbshipit-source-id: 96a3f9503e7865a5f9d95710ff13f019afcf04f1
    59701670
fb_py_win_main.c 3.98 KB