-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add standalone lib build with Python install #417
Conversation
96ecd3d
to
ff55f1f
Compare
ff55f1f
to
6316cc8
Compare
@kpu this should drastically reduce the number of "how do I install KenLM, I'm trying to do X" issues given that a lot of those downstream needs are coming from Python packages requiring it. Hope to merge this shortly -- let me know if you have any questions. |
@jacobkahn had you tested non-default max order like May I suggest the use of scikit-build? |
@ZJaume thanks for letting me know. This change doesn't affect the default Python library build at all, so all of those build options should stay exactly the same... I'll test those again now and see what's going on. With respect to build speed, this quite literally performs the identical build twice once using the CMake version in order to produce dylib that C++ binaries can consume, so I'm not sure why build speed would suffer so significantly. I'll spend some time on fixing this right now given those issues; I'll give scikit build a try as well. I'll tag you in the fix. |
@ZJaume — after further investigation, the increase in build time is due to the confluence of multiple things:
In #420, I've changed the behavior to read from a I explored scikit-build briefly (https://github.com/jacobkahn/kenlm/tree/scikit_build_python), but had some problems. We can revisit this down the line. cc @kpu |
Augments the Python build to also ship C++ library builds of KenLM that are dynamically usable by other C++ libs. Specifically,
pip install .
in the repo (orpip install git+https://github.com/kpu/kenlm
, as it'll likely be most often used) now installs:kenlm.cpython-[platform].{so,pyd}
(as before) -- openable by Pythonlibkenlm.{so,dll,lib}
[new] -- not loadable by Python but usable by C++ libraries.In particular, this PR:
KENLM_MAX_ORDER
CMake definition to the beginning of the buildBuildStandalone.cmake
, enabled byBUILD_PYTHON_STANDALONE
, which buildslibkenlm
as a shared lib containing symbols from all project sources-dynamiclib
on macOS and let CMake handle this. MSVC will build apyd
(special DLL) anyways on Windows, so we need a cross-platform way to build shared libs that are dlopen'ed in C++ land by Python libs.setup.py
and run them with the regular cython extension build.setuptools
,wheel
,cmake
) are all available from PyPI and are installed automatically.