Skip to content

🛠️ Local Dev environment setup

I develop data science python projects in Linux OS or MAC OS. (For Windows OS I recommend WSL and run commands as Linux OS).

I setup my local development environment using the following steps:

💻 Computer setup to develop with Python

  1. Install Git
    • Linux: sudo apt-get install git
    • MAC: brew install git
  2. Install Make
    • Linux: sudo apt-get install make
    • MAC: brew install make
  3. Install locally UV to Manage python versions, dependencies and virtual environments.

    • Linux:

      Install uv in Linux or MACOS
      curl -LsSf https://astral.sh/uv/install.sh | sh
      
      • Check the installation version executing in terminal: uv version
  4. Install Python using UV, at this time I am using Python 3.11

    • uv python install 3.11 # Install Python 3.11 in computer
  5. In the folder of the project, set the Python version and create a virtual environment.

  6. If the project has uv.lock file
    • uv sync # Create virtual Environment and install dependencies.
    • source .venv/bin/activate # Activate Environment 2.
    • uv venv --python 3.11 # Create a Python 3.11 virtual environment
    • source .venv/bin/activate # Activate the Python 3.11 virtual environment
    • Check the installation version executing in terminal: python --version

Note: To deactivate the virtual enviroment in terminal type: deactivate

🐍 General Python tools

General Tools that I use to develop Python projects, The most important is UV to manage python versions, virtual environments, manage dependencies for the projects and to have tools in isolated environments, because applications runs in its own virtual environment to avoid dependencies conflicts and they are available everywhere.

UV Highligths

  1. Cruft allows you to maintain all the necessary boilerplate for packaging and building projects separate from the code you intentionally write. Fully compatible with existing Cookiecutter templates.
    • uv tool install cruft
  2. (optional) Pre-commit to local check the security of the dependencies of the project.
    • uv tool install pip-audit
  3. (optional) Pip-audit to local check the security of the dependencies of the project.
    • uv tool install pip-audit
  4. (optional) Actionlint to check the syntax of the GitHub Actions configuration files of the project.
    • uv tool install actionlint

Note: UV replace tool like Pyenv, Poetry and other ones to manage the python versions, environments and dependencies.

📁 Start a new data science project

  1. Start a new project using the Cruft with the Data Science Project Template.

    create project
    cruft create https://github.com/JoseRZapata/data-science-project-template
    
  2. Answer the questions to create the project.

  3. Run make init_env to init Git Or You can do the same running this commands:

    init environment
        git init -b main
        git add .
        git commit -m "🎉 Begin a project, Initial commit"
    
  4. Run make install to install the dependencies of the project. Or You can do the same running this commands:

    install dependencies
        uv sync --all-groups
    
  5. 🎉 Congrats Start coding your project.