Skip to content

This repo contains a jupyter book with things to study if you are a python starter

License

Notifications You must be signed in to change notification settings

rafaelortegar/Python_cheat_sheets_book

Repository files navigation

Python Cheat Sheets Book Repository

Welcome to the Python Cheat Sheets Book repository! This project is designed to help you build and serve Jupyter Books while working with Jupyter Notebooks, Docker, Poetry, Pyenv, Pre-Commit, and GitHub Actions. Follow this guide to set up and contribute to the project.


Table of Contents


Features

  • Docker: Containerized environment for consistent development.
  • Poetry: Dependency and environment management.
  • Jupyter Book: Generate structured documentation from notebooks and markdown files.
  • Jupyter Notebooks: Interactive notebooks for development and analysis.
  • Pre-Commit Hooks: Ensure code quality and consistency.
  • Pyenv: Manage Python versions.
  • GitHub Actions: Automated workflows for linting, testing, and book building.
  • Tests: Unit tests to validate the functionality of scripts.

Folder Structure

.
├── LICENSE                  # License file for the project
├── README.md                # Main documentation for the repository
├── README_1.md              # Additional or alternate README
├── book                     # Jupyter Book content
│   ├── _build               # Built files for the Jupyter Book
│   │   ├── html             # HTML output
│   │   └── jupyter_execute  # Executed notebooks
│   ├── _config.yml          # Global configuration for the Jupyter Book
│   ├── _toc.yml             # Table of contents for the Jupyter Book
│   ├── intro.md             # Introduction chapter
│   ├── logo.png             # Logo for the book
│   ├── markdown-notebooks.md  # Example Markdown documentation
│   ├── markdown.md          # Example Markdown file
│   ├── notebooks.ipynb      # Example Jupyter Notebook
│   ├── references.bib       # References used in the book
│   └── requirements.txt     # Dependencies for the Jupyter Book
├── cheat_sheets_book        # Main source code for the cheat sheets book
├── dockerfiles              # Docker configurations
│   └── Dockerfile_jupyter_book_dev  # Dockerfile for the development environment
├── notebooks                # Additional Jupyter Notebooks
├── poetry.lock              # Poetry lock file for dependencies
├── pyproject.toml           # Poetry configuration file
├── pytest.ini               # Configuration for pytest
├── requirements.txt         # Dependencies for non-Poetry users
└── tests                    # Unit tests for the project
    └── test_example.py      # Example test case

Initial Setup

On Linux

  1. Install Pyenv:

    curl https://pyenv.run | bash
    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    eval "$(pyenv virtualenv-init -)"
    exec $SHELL
  2. Install Python:

    pyenv install 3.10.12
    pyenv virtualenv 3.10.12 python_cheat_sheets_book
    pyenv activate python_cheat_sheets_book
  3. Install Poetry:

    curl -sSL https://install.python-poetry.org | python3 -
    export PATH="$HOME/.local/bin:$PATH"
    exec $SHELL
  4. Install Dependencies:

    poetry install

On Windows

  1. Install Pyenv-Win:

    pip install pyenv-win

    Add the following to your system PATH:

    • %USERPROFILE%\.pyenv\pyenv-win\bin
    • %USERPROFILE%\.pyenv\pyenv-win\shims
  2. Install Python:

    pyenv install 3.10.12
    pyenv virtualenv 3.10.12 python_cheat_sheets_book
    pyenv activate python_cheat_sheets_book
  3. Install Poetry:

    (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
  4. Install Dependencies:

    poetry install

Using This Repo

Run with Docker

  1. Build the Docker Image:

    docker build -t jupyter-book-dev -f dockerfiles/Dockerfile_jupyter_book_dev .
  2. Run the Container:

    docker run -it -p 8888:8888 -p 8000:8000 -v $(pwd):/notebooks jupyter-book-dev
  3. Access the Services:

Run Locally with Poetry

  1. Activate the environment:

    poetry shell
  2. Run Jupyter Notebook:

    jupyter notebook
  3. Build the Jupyter Book:

    jupyter-book build book/

Run Tests

  1. Execute all tests:
    pytest

Updating a Package

  1. Update the Dependency:

    poetry add <package>@<version>
  2. Rebuild the Docker Image:

    docker build -t jupyter-book-dev -f dockerfiles/Dockerfile_jupyter_book_dev .
  3. Run the Updated Container:

    docker run -it -p 8888:8888 -p 8000:8000 -v $(pwd):/notebooks jupyter-book-dev

Contributing

  1. Fork the Repo: Clone your fork locally.
  2. Install Pre-Commit Hooks:
    pre-commit install
  3. Create a Feature Branch:
    git checkout -b feature/<feature-name>
  4. Make Changes: Commit with meaningful messages.
  5. Run Tests:
    pytest
  6. Push and Create a Pull Request.

GitHub Actions

This repository includes workflows for:

  • Linting: Ensures code quality with tools like Black and Flake8.
  • Testing: Runs unit tests automatically.
  • Book Building: Builds and deploys the Jupyter Book to GitHub Pages.

If you encounter any issues or have questions, feel free to open an issue or contribute to the project!

About

This repo contains a jupyter book with things to study if you are a python starter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published