python >= 3.9(with dev headers)setuptools(pip install setuptools)build(pip install build)
Edit local.properties in the project root:
architecture- set toarm64orx86_64depending on your Python architecture.enable_python_package- set totruefor working with Python package.python.include_path- path to Pythonincludedirectory where Python.h located. To get this path you can runpython -c "from sysconfig import get_paths as gp; print(gp()['include'])".python.bin_path- path to your Python bin directory. To get this path you can runpython -c "from sysconfig import get_paths as gp; print(gp()['scripts'])".
There are two ways to build the Python package:
This method builds both the Kotlin multiplatform binaries and the Python package:
./gradlew :python-package-build:buildNote: The target Python version for this build is determined by the configuration in local.properties file (see Configuration section above).
If you've only made changes to Python code, you can rebuild just the Python wheel:
python -m build -wPrerequisites for Python build:
- Must be in the
python-packagedirectory - Need an active Python environment with the
buildpackage installed - The resulting wheel will target the Python version of your active environment
- change dir to
lets-plot/python-package - create / activate a Python environment (if needed)
- run shell command:
pip install --no-index --find-links=dist/ lets-plot --no-deps --force-reinstall
When the "dev" version is built, lets-plot embeds current "dev" js into Jupyter notebook.
If necessary, this default can be temporarily overwritten by editing dev_xxx settings in _global_settings.py
The "dev" version of JS library can be served from js-package/build/kotlin-webpack/js/developmentExecutable folder (in js-package project):
$ cd lets-plot
# Build developened JS package:
$ ./gradlew js-package:jsBrowserDevelopmentWebpack
# Start local web-server to serve dev js script:
$ python -m http.server 8080
from lets_plot import *
data = dict(time=['Lunch', 'Lunch', 'Dinner', 'Dinner', 'Dinner'])
p = ggplot(data) + geom_bar(aes(x='time', fill='..count..'))
p += scale_fill_hue()
p