Skip to content

[Setup] Add support for development install

Context

Add capacity in setup.py to do pip editable installs (or development mode), i.e.:

  • modification to python files do not need a reinstallation,
  • C++ build can be incrementally rebuild and reinstalled from the build/ directory

In order to use editable mode even with recent versions of python one should do pip install -v --no-build-isolation -e . instead of the default install with pip install -v .

This MR allows editable mode to speedup day to day development basically with the changes:

  • moved the installation of the python binding library into the cmake build system, instead of the setup script
  • detect editable mode and in this case install the python binding library directly in the source python package

Note that due to behavior changes depending on the python/setuptools versions, the portable method to ensure incremental build on C++ files is to use the first time (pre-install build dependencies, and use --no-build-isolation):

pip install setuptools setuptools_scm[toml] cmake
pip install --no-build-isolation -v -e .

Then, when C++ files changes:

make -C build install -j $(nproc)

Modified files

Refer to the list of commits in the MR for details.

I separated them in 6 listed below, the first 5 are preparatory commits or complements to the recent merge of pip_release branch:

  • [Setup] Remove useless copy of version.txt in python package: not necessary anymore as the python version is managed by setuptools_scm
  • [CMake] Minor update for comment location: no functionnal change
  • [Setup] Allow empty AIDGE_BUILD_GEN type: allow for specifying AIDGE_BUILD_GEN= (empty) to fall back to default
  • [Setup] Remove additional build dependency on toml: prefer to limit the number of dependencies at most for setup.py
  • [CMake] Add installation of python binding: responsibility of python bindings lib installation is now in the build system
  • [Setup] Add support for editable mode: redirect installation locally in editable mode and document in README.md

Tests

Tested with:

  • normal mode on python 3.9
  • normal model on python 3.12
  • development mode on python 3.9
  • development model on python 3.12
  • normal mode on windows 3.12
  • development mode on windows 3.12
  • expected to fail: on windows: setting the Ninja backend fails, no compiler found

TODO / To be discussed

  • ninja dependency: Yes, available as a python package ninja. Let optional for the developper.
  • symlinks. Removed necessity to have symlinks has the build system installs the library itself
  • version.txt. Since changes in packaing, no need to copy version.txt anymore
Edited by Christophe Guillon

Merge request reports

Loading