Installation¶
A virtual environment is highly recommended. This ensures project dependencies do not conflict with the system-wide Python installation.
Create a new virtual environment folder within your project directory. It is conventional to name this folder .venv.
# macOS / Linux / Windows
python3 -m venv .venvActivating the environment tells your shell to use the Python interpreter and pip packages located inside the .venv folder.
macOS / Linux:¶
source .venv/bin/activateWindows (PowerShell):¶
.venv\Scripts\Activate.ps1Windows (Command Prompt), DOS¶
.venv\Scripts\activate.batOnce activated, your terminal prompt will typically show (.venv). You can now install dependencies safely.
# Install specific packages, for example, the "requests" package
pip install requests
# Or install the entire Rattlesnake development in editable mode
pip install -e .[dev]Confirm that your shell is pointing to the correct Python binary.
# macOS / Linux
which python
# Windows
where pythonThe output should point to a path inside your project’s .venv folder.
To exit the virtual environment and return to the global system stack:
deactivateBest Practice: Never commit the
.venvdirectory to version control. Add.venv/to your.gitignorefile.
Now that you have a virtual environment, you are ready to populate it with libraries specific to the project.
Documentation¶
The online documentation is made with Jupyter Book. Below are instructions for setting up a local development environment, building the book locally, and publishing the updates to the repository.
Install documentation dependencies either with pip
pip install "jupyter-book>=2.0.0"or with uv
uv add "jupyter-book"Local Build¶
Within this documentation folder, the myst.yml file specifies how Jupyter Book should build the documentation. Importantly, it links to Markdown files that contain the book’s content.
cd rattlesnake-vibration-controller/documentation
jupyter book build --html --strictThis will build the Jupyter Book documentation.
The output will be similar to:
building myst-cli session with API URL: https://api.mystmd.org
(node:93011) Warning: `--localstorage-file` was provided without a valid path
(Use `node --trace-warnings ...` to show where the warning was created)
🌎 Building Jupyter Book (via myst) site
📖 Built book/src/_generated/random_vibration_run_doc.md in 64 ms.
📖 Built book/src/chapter_13.md in 124 ms.
📖 Built book/src/notation.md in 117 ms.
📖 Built book/src/contributing.md in 117 ms.
<--(snip)-->
📚 Built 32 pages for project in 813 ms.To view the Jupyter Book output locally:
jupyter book startThe ouput will be similar to:
📚 Built 32 pages for project in 974 ms.
<--(snip)-->
🔌 Server started on port 3000! 🥳 🎉
👉 http://localhost:3000 👈In a local web browser, navigate to the web address indicated above.
Bibliography¶
The documentation uses the myst-nb and standard MyST bibliography support.
Prepare your bibliography file:
References are stored in documentation/book/bibliography.bib using the standard BibLaTeX (.bib) format. Populate the file with references, e.g.,
@book{knuth1986computer,
title={The Computer Science of TeX and Metafont: An Inaugural Lecture},
author={Knuth, Donald E},
year={1986},
publisher={American Mathematical Society}
}Configure
myst.yml
The bibliography is configured in documentation/myst.yml under the project.bibliography section:
project:
bibliography:
- book/bibliography.bibAdd in-text citations
In a markdown file, use the cite role to reference an entry by its key:
{cite} knuth1986computer
Build the book
Run the jupyter book build command from the documentation directory. The build system will automatically process the citations and generate the bibliography.
cd documentation
jupyter book buildContinuous Integration/Continuous Deployment (CI/CD)¶
The separate the concerns of test, build, release, and publish are contained in the .github/workflows/ files.
Continuous Integration (CI)
Test (Verification)
Purpose: To ensure that the code is functional and hasn’t introduced regressions (broken existing features).
Scope: Tests are run on one or more versions of Python and on multiple operating systems (e.g., Linux, macOS, Windows).
What happens: Automated tool run unit tests, integration tests, and code quality assessments are performed.
Testing (e.g., pytest) runs your unit and integration tests.
Code coverage (e.g., pytest with a coverage report) assesses number of lines of code covered by tests.
Linting (static code analysis, e.g., pylint) and
Code Formatting (e.g., ruff) checks ensure code consistency.
Documentation may also be assembled and compiled. This is particularly important for interactive documentation that has examples that depend on source code functionality.
Key Outcome: Confidence. If this stage fails, the process stops immediately, preventing broken code from ever reaching a user.
Build (Packaging)
Purpose: To transform your “human-readable” source code into “machine-installable” artifacts. This is the bridge between CI and CD. Once the code is verified (integrated), it can be packaged into a deployable format (Wheels/SDists).
What happens: Tools (like
python -m build) bundle your code into standard formats, such as a Wheel (.whl) or a Source Distribution (.tar.gz).Key Outcome: Portability. You now have a single file (an “artifact”) that contains everything needed to install your library on any compatible system.
Release (Documentation & Tagging)
Purpose: To create an official “point-in-time” snapshot of the project for project management and users. It uses an immutable Git tag and GitHub Release page.
What happens: A permanent Git tag (like v1.0.0) is assigned to a specific commit. A GitHub Release page is generated with a Changelog (i.e., What’s New?) and the build artifacts are attached to it as “Release Assets.”
Key Outcome: Traceability. It provides a clear history of the project’s evolution and a stable place for users to download specific versions.
Continuous Delivery (CD)
Publish (Distribution)
Purpose: To make the software easily available to the global ecosystem.
What happens: The built artifacts are uploaded to a package registry, such as PyPI (the Python Package Index).
Key Outcome: Accessibility. Once published, anyone in the world can install your software using a simple command like
pip install rattlesnake-vibration-controller.