diff --git a/.githooks/post-checkout b/.githooks/post-checkout new file mode 100755 index 00000000..8e5f7089 --- /dev/null +++ b/.githooks/post-checkout @@ -0,0 +1,6 @@ +#!/bin/sh +if [ "$3" = "1" ]; then + echo "Updating submodules..." + git submodule update --init --recursive +fi + diff --git a/.github/workflows/on_external_dispatch.yml b/.github/workflows/on_external_dispatch.yml index 46252f0d..33a807db 100644 --- a/.github/workflows/on_external_dispatch.yml +++ b/.github/workflows/on_external_dispatch.yml @@ -53,5 +53,5 @@ jobs: DUCKDB_SHA="${{ inputs.duckdb-sha }}" aws s3 cp \ artifacts \ - s3://duckdb-staging/${DUCKDB_SHA:0:7}/${{ github.repository }}/ \ + s3://duckdb-staging/${DUCKDB_SHA:0:10}/${{ github.repository }}/ \ --recursive diff --git a/.gitmodules b/.gitmodules index 2f4bbe0e..d4c01492 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,5 @@ path = external/duckdb url = https://github.com/duckdb/duckdb.git branch = main +[submodule] + recurse = true diff --git a/CMakeLists.txt b/CMakeLists.txt index c927920e..7c6c5332 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,6 @@ setup_compiler_launcher_if_available() # ──────────────────────────────────────────── # Create compile_commands.json for IntelliSense and clang-tidy set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# If we're not building through scikit-build-core then we have to set a different dest dir -include(GNUInstallDirs) -set(_DUCKDB_PY_INSTALL_DIR "${SKBUILD_PLATLIB_DIR}") -if(NOT _DUCKDB_PY_INSTALL_DIR) - set(_DUCKDB_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") -endif() # ──────────────────────────────────────────── # Policy hygiene @@ -87,4 +81,16 @@ target_link_libraries(_duckdb PRIVATE _duckdb_dependencies) # ──────────────────────────────────────────── # Put the object file in the correct place # ──────────────────────────────────────────── + +# If we're not building through scikit-build-core then we have to set a different dest dir +include(GNUInstallDirs) +if(DEFINED SKBUILD_PLATLIB_DIR) + set(_DUCKDB_PY_INSTALL_DIR "${SKBUILD_PLATLIB_DIR}") +elseif(DEFINED Python_SITEARCH) + set(_DUCKDB_PY_INSTALL_DIR "${Python_SITEARCH}") +else() + message(WARNING "Could not determine Python install dir. Falling back to CMAKE_INSTALL_LIBDIR.") + set(_DUCKDB_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") +endif() + install(TARGETS _duckdb LIBRARY DESTINATION "${_DUCKDB_PY_INSTALL_DIR}") diff --git a/README.md b/README.md index c5cdd815..13e9569d 100644 --- a/README.md +++ b/README.md @@ -44,19 +44,27 @@ pip install 'duckdb[all]' ## Development -### Building wheels and sdists +### Cloning - To build a wheel and sdist for your system and the default Python version: -```bash -uv build -```` +When you clone the repo or your fork, make sure you initialize the duckdb submodule: +```shell +git clone --recurse-submodules +``` - To build a wheel for a different Python version: -```bash -# E.g. for Python 3.9 -uv build -p 3.9 +... or, if you already have the repo locally: +```shell +git clone +cd +git submodule update --init --recursive +``` + +If you'll be switching between branches that are have the submodule set to different refs, then make your life +easier and add the git hooks in the .githooks directory to your local config: +```shell +git config --local core.hooksPath .githooks/ ``` + ### Editable installs (general) It's good to be aware of the following when creating an editable install: @@ -72,7 +80,7 @@ uv build -p 3.9 # install all dev dependencies without building the project (needed once) uv sync -p 3.9 --no-install-project # build and install without build isolation -uv sync --no-build-isolation +uv sync --no-build-isolation ``` ### Editable installs (IDEs) @@ -82,6 +90,28 @@ uv sync --no-build-isolation compilation and editable rebuilds. This will skip scikit-build-core's build backend and all of uv's dependency management, so for "real" builds you better revert to the CLI. However, this should work fine for coding and debugging. + +### Cleaning + +```shell +uv cache clean +rm -rf build .venv uv.lock +``` + + +### Building wheels and sdists + +To build a wheel and sdist for your system and the default Python version: +```bash +uv build +```` + +To build a wheel for a different Python version: +```bash +# E.g. for Python 3.9 +uv build -p 3.9 +``` + ### Running tests Run all pytests: diff --git a/duckdb_packaging/setuptools_scm_version.py b/duckdb_packaging/setuptools_scm_version.py index f555e384..956cf38a 100644 --- a/duckdb_packaging/setuptools_scm_version.py +++ b/duckdb_packaging/setuptools_scm_version.py @@ -12,8 +12,8 @@ # Import from our own versioning module to avoid duplication from ._versioning import parse_version, format_version -# MAIN_BRANCH_VERSIONING default should be 'True' for main branch and feature branches -MAIN_BRANCH_VERSIONING = True +# MAIN_BRANCH_VERSIONING should be 'True' on main branch only +MAIN_BRANCH_VERSIONING = False SCM_PRETEND_ENV_VAR = "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DUCKDB" SCM_GLOBAL_PRETEND_ENV_VAR = "SETUPTOOLS_SCM_PRETEND_VERSION" diff --git a/external/README_GIT_SUBMODULE.md b/external/README_GIT_SUBMODULE.md deleted file mode 100644 index 777bb495..00000000 --- a/external/README_GIT_SUBMODULE.md +++ /dev/null @@ -1,36 +0,0 @@ -# DuckDB vendored as submodule - -The submodule has a relative path. Git resolves it against the super-project’s remote, so a clone of `git@github.com:alice/duckdb-python.git` will automatically look for `git@github.com:alice/duckdb.git`, while a clone of the canonical repo falls back to -`https://github.com/duckdb/duckdb.git`. - -### Clone python repo - -From the main repo: -```shell -git clone --recurse-submodules git@github.com:duckdb/duckdb-python.git -``` - -Or from your fork (NOTE that you must also fork duckdb): -```shell -git clone --recurse-submodules git@github.com:/duckdb-python.git -``` - -### Switch submodule to fork -```shell -git submodule set-url external/duckdb git@github.com:/duckdb.git -``` - -### Work on a feature branch -```shell -git -C external/duckdb checkout my-branch -``` - -### Jump to latest DuckDB tag -```shell -git -C external/duckdb fetch --tags && git -C external/duckdb checkout v1.3.1 # Example -``` - -### Pull latest changes -```shell -git submodule update --remote --merge external/duckdb -``` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5532f41b..d0642b3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,6 +112,7 @@ if.state = "editable" if.env.COVERAGE = false build-dir = "build/debug/" editable.rebuild = true +editable.mode = "redirect" cmake.build-type = "Debug" # Separate override because we have to append to cmake.define with `inherit` in order not to overwrite other defines.