From 5cfbdf61ec2f81da0cdd0b875ffff98ecef61cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Luna?= Date: Tue, 14 Jan 2025 02:52:11 -0300 Subject: [PATCH] refactor(setup): optimize cfoundation setup process and improve documentation - Implement sparse checkout for cfoundation cloning to exclude unnecessary files - Add clear instructions for virtual environment activation in README - Only clone essential files required for Python bindings Closes #20 --- README.md | 20 ++++++++++++++++---- setup.ps1 | 9 ++++++--- setup.sh | 9 ++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d7b69f0..b2c2c73 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ cd tidesdb-python # Run the setup script ./setup.sh + +# Activate the virtual environment +source venv/bin/activate # Your prompt should show (venv) at the beginning ``` #### Windows @@ -38,6 +41,10 @@ cd tidesdb-python # Run the setup script .\setup.ps1 + +# Activate the virtual environment +# For Windows (PowerShell or Command Prompt): +venv\Scripts\activate # Your prompt should show (venv) at the beginning ``` ### Understanding the Setup Process @@ -48,15 +55,20 @@ The installation process consists of several important steps: - The setup scripts automatically clone and configure the TidesDB C foundation (`cfoundation/`). - This component is crucial as it provides the core database functionality that the Python bindings interact with. - The scripts handle: - - Cloning the C foundation repository + - Cloning the C foundation repository (only essential files) - Configuring build options for optimal performance - Building and installing the C library - Integrating it seamlessly with the Python bindings 2. **Python Environment** - - Creates a virtual environment for isolated package management - - Installs all required Python dependencies - - Sets up the Python package in development mode + - The setup script automatically: + - Creates a virtual environment for isolated package management + - Installs all required Python dependencies + - Sets up the Python package in development mode + - After installation, you must manually activate the virtual environment: + - For Linux/macOS: `source venv/bin/activate` + - For Windows: `venv\Scripts\activate` + - Once activated, your prompt should show (venv) at the beginning #### Automated Setup Details diff --git a/setup.ps1 b/setup.ps1 index 9dc4556..2ded4b2 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -4,11 +4,14 @@ $ErrorActionPreference = "Stop" # Define C library repository $CLIB_REPO = "https://github.com/tidesdb/tidesdb" -# Clone and set up C foundation -Write-Host "Cloning TidesDB C foundation..." -git clone $CLIB_REPO cfoundation +# Clone with sparse checkout +Write-Host "Cloning TidesDB C foundation (minimal)..." +git clone --filter=blob:none --sparse $CLIB_REPO cfoundation Set-Location cfoundation +# Configure sparse checkout patterns +git sparse-checkout set --no-cone '/*' '!artwork/' '!test/' '!.github/' '!CODE_OF_CONDUCT.md' '!CONTRIBUTING.md' '!LICENSE' '!README.md' '!SECURITY.md' '!.gitignore' + # Remove .git directory as it will be part of the main project Write-Host "Cleaning up git history..." Remove-Item -Recurse -Force .git diff --git a/setup.sh b/setup.sh index 53c97db..020c635 100755 --- a/setup.sh +++ b/setup.sh @@ -5,11 +5,14 @@ set -e # Stop the script in case of error # Define C library repository CLIB_REPO="https://github.com/tidesdb/tidesdb" -# Clone and set up C foundation -echo "Cloning TidesDB C foundation..." -git clone "$CLIB_REPO" cfoundation +# Clone with sparse checkout +echo "Cloning TidesDB C foundation (minimal)..." +git clone --filter=blob:none --sparse "$CLIB_REPO" cfoundation cd cfoundation +# Configure sparse checkout patterns +git sparse-checkout set --no-cone '/*' '!artwork/' '!test/' '!.github/' '!CODE_OF_CONDUCT.md' '!CONTRIBUTING.md' '!LICENSE' '!README.md' '!SECURITY.md' '!.gitignore' + # Remove .git directory as it will be part of the main project echo "Cleaning up git history..." rm -rf .git