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.
- 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.
.
├── 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
-
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
-
Install Python:
pyenv install 3.10.12 pyenv virtualenv 3.10.12 python_cheat_sheets_book pyenv activate python_cheat_sheets_book
-
Install Poetry:
curl -sSL https://install.python-poetry.org | python3 - export PATH="$HOME/.local/bin:$PATH" exec $SHELL
-
Install Dependencies:
poetry install
-
Install Pyenv-Win:
pip install pyenv-win
Add the following to your system PATH:
%USERPROFILE%\.pyenv\pyenv-win\bin
%USERPROFILE%\.pyenv\pyenv-win\shims
-
Install Python:
pyenv install 3.10.12 pyenv virtualenv 3.10.12 python_cheat_sheets_book pyenv activate python_cheat_sheets_book
-
Install Poetry:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
-
Install Dependencies:
poetry install
-
Build the Docker Image:
docker build -t jupyter-book-dev -f dockerfiles/Dockerfile_jupyter_book_dev .
-
Run the Container:
docker run -it -p 8888:8888 -p 8000:8000 -v $(pwd):/notebooks jupyter-book-dev
-
Access the Services:
- Jupyter Notebook: http://localhost:8888
- Jupyter Book: http://localhost:8000
-
Activate the environment:
poetry shell
-
Run Jupyter Notebook:
jupyter notebook
-
Build the Jupyter Book:
jupyter-book build book/
- Execute all tests:
pytest
-
Update the Dependency:
poetry add <package>@<version>
-
Rebuild the Docker Image:
docker build -t jupyter-book-dev -f dockerfiles/Dockerfile_jupyter_book_dev .
-
Run the Updated Container:
docker run -it -p 8888:8888 -p 8000:8000 -v $(pwd):/notebooks jupyter-book-dev
- Fork the Repo: Clone your fork locally.
- Install Pre-Commit Hooks:
pre-commit install
- Create a Feature Branch:
git checkout -b feature/<feature-name>
- Make Changes: Commit with meaningful messages.
- Run Tests:
pytest
- Push and Create a Pull Request.
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!