# scikit-build-cpp-python ## Why and What use scikit-build-core to setup a python-cmake project that can be installed with `pip install -e .` ## Conclusion - package name has nothing to do with the import path. pacakge named my_package is installed with `pip install .`, uninstalled with `pip uninstall my_package`, but can be used as `import kk.ss as ks`. - installation of cpp files: ```cmake install(TARGET mylib LIBRARY DESTINATION .) ``` and set ``` [tool.scikit-build] wheel.install-dir = "kk/ss" ``` - installation of python files: ``` [tool.scikit-build.wheel.packages] "mm/tt" = "python/myproj/simulation" [tool.scikit-build] wheel.exclude = ["CMakeLists.txt","*.cc","*.h"] ``` ## special variable - `${SKBUILD_PLATLIB_DIR}`: The original platlib directory. Anything here goes directly to site-packages when a wheel is installed. - `${SKBUILD_DATA_DIR}`: The data directory. Anything here goes to the root of the environment when a wheel is installed (use with care). - `${SKBUILD_HEADERS_DIR}`: The header directory. Anything in here gets installed to Python's header directory. - `${SKBUILD_SCRIPTS_DIR}`: The scripts directory. Anything placed in here will go to `bin` (Unix) or `Scripts` (Windows). - `${SKBUILD_METADATA_DIR}`: The dist-info directory. Licenses go in the `licenses` subdirectory. _Note that CMake is not run in the `prepare_metadata_\*` hooks, so anything written to this directory will only be present when writing wheels.\_ - `${SKBUILD_NULL_DIR}`: Anything installed here will not be placed in the wheel. ## style and lint check ### notebook otuput stripping - use pre-commit 1. install ```bash pip install pre-commit nbstripout ``` 2. set ```yaml repos: - repo: https://github.com/kynan/nbstripout rev: master # Pin to a specific version if desired hooks: - id: nbstripout files: \.ipynb$ ``` 3. install ```bash pre-commit install ``` ## vscode extensions to install - "isort", which sort python import ``` Name: isort Id: ms-python.isort Description: Import organization support for Python files using isort. Version: 2023.10.1 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.isort ``` - "pylint", for complrehensive code analysis ``` Name: Pylint Id: ms-python.pylint Description: Linting support for Python files using Pylint. Version: 2024.0.0 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.pylint ```