From a1f57920a725a0df64728f3f3664be824a671833 Mon Sep 17 00:00:00 2001 From: paschal533 Date: Fri, 4 Apr 2025 05:27:38 +0100 Subject: [PATCH] Add Windows development setup instructions to contributing.rst --- docs/contributing.rst | 108 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 14 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 7e4e4bc1..baed7880 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -29,7 +29,7 @@ On MacOS, you can install them using the following command: Setting the stage ~~~~~~~~~~~~~~~~~ -To get started, fork the repository to your own github account, then clone it +To get started, fork the repository to your own GitHub account, then clone it to your development machine: .. code:: sh @@ -37,7 +37,26 @@ to your development machine: git clone git@github.com:your-github-username/py-libp2p.git Next, install the development dependencies. We recommend using a virtual -environment, such as `virtualenv `_. +environment, such as `virtualenv `_ or +Python's built-in ``venv`` module. Instructions vary by platform: + +**Linux and macOS** + +.. code:: sh + + cd py-libp2p + python3 -m venv ./venv + . venv/bin/activate + python3 -m pip install -e ".[dev]" + pre-commit install + +On macOS, you must help the build command find and link against the ``gmp`` library: + +.. code:: sh + + CFLAGS="`pkg-config --cflags gmp`" LDFLAGS="`pkg-config --libs gmp`" python3 -m pip install -e ".[dev]" + +An alternative using ``virtualenv``: .. code:: sh @@ -47,22 +66,84 @@ environment, such as `virtualenv `_. python -m pip install -e ".[dev]" pre-commit install -An alternative to virtualenv is to use the built-in Python3 venv module: +**Windows Development Setup** -.. code:: sh +To set up ``py-libp2p`` on Windows, follow these steps: - cd py-libp2p - python3 -m venv ./venv - . venv/bin/activate - python3 -m pip install -e ".[dev]" - pre-commit install +*Prerequisites* -Currently, on MacOS you must help the build command find and link against the -gmp library. On MacOS run the following to build py-libp2p: +1. **Python 3.11+** + - Download and install Python from `python.org `_ or the Microsoft Store. + - Verify installation: + .. code-block:: powershell -.. code:: sh + python --version - CFLAGS="`pkg-config --cflags gmp`" LDFLAGS="`pkg-config --libs gmp`" python3 -m pip install -e ".[dev]" +2. **Git** + - Install Git using Windows Package Manager (``winget``): + .. code-block:: powershell + + winget install --id Git.Git -e + - Or download from `git-scm.com `_. + - Verify: + .. code-block:: powershell + + git --version + +3. **CMake** + - Install CMake with ``winget``: + .. code-block:: powershell + + winget install --id Kitware.CMake -e + - Or download from `cmake.org `_. + - Add CMake to your PATH during installation, then verify: + .. code-block:: powershell + + cmake --version + +4. **Make (Optional)** + - Option 1: Use Git Bash (included with Git) as a shell. + - Option 2: Install ``make`` via Chocolatey: + .. code-block:: powershell + + choco install make + - Install Chocolatey first if needed: `choco.io `_. + - Verify: + .. code-block:: powershell + + make --version + +*Setup Steps* + +1. **Clone the Repository** + - Open PowerShell or Git Bash and run: + .. code-block:: powershell + + git clone https://github.com/libp2p/py-libp2p.git + cd py-libp2p + +2. **Create a Virtual Environment** + - In PowerShell: + .. code-block:: powershell + + python -m venv venv + .\venv\Scripts\activate + +3. **Install Dependencies** + - Install the project and dev dependencies: + .. code-block:: powershell + + pip install -e ".[dev]" + +4. **Verify Setup** + - Run the tests to ensure everything works: + .. code-block:: powershell + + pytest -v + +*Notes* +- Use PowerShell, Command Prompt, or Git Bash as your shell. Git Bash is recommended if ``make`` is required. +- Ensure all tools (Python, Git, CMake) are in your system PATH. Requirements ^^^^^^^^^^^^ @@ -84,7 +165,6 @@ We can run all tests with: At this time, the interop tests are not passing. You can run just the internal tests with ``pytest tests/core``. - Code Style ~~~~~~~~~~