Setup

This document is designed to help you set up your development environment for gfw-api-python-client and serve as a guide and reference for the development process. If you encounter any issues, please open an issue on the issue tracker.

Getting the Source Code

To begin working on gfw-api-python-client, you’ll need to obtain the source code. The source code is available on GitHub.

git clone https://github.com/GlobalFishingWatch/gfw-api-python-client.git
cd gfw-api-python-client

Setting Up Your Development Environment

gfw-api-python-client is a Python package, and a suitable Python installation (version 3.12 or higher) is required for development. You can download Python from the official website.

We strongly recommend using a virtual environment to isolate the project’s dependencies.

Here’s how to set up your development environment:

python3.12 -m venv .venv
source .venv/bin/activate

Running From Source Tree

To run the gfw-api-python-client executable directly from your source tree during development, perform an editable install of gfw-api-python-client within your active virtual environment:

make install

This allows you to develop and test your changes without needing to reinstall the package each time.

Running Tests

We use the pytest framework for our tests.

To execute all unit tests:

make test

To execute integration tests (which interact with live APIs):

make test-integration

Running Linters and Code Formatting

To maintain a consistent code style, we use pre-commit to manage linters and formatters. pre-commit runs configured checks on your staged files before you commit.

To run all pre-commit checks manually:

make pre-commit

It’s recommended to run these checks before pushing your code.

Building Documentation

Our documentation is built using Sphinx. It’s written in a combination of reStructuredText and Markdown (using MyST Parser).

To build the HTML documentation locally:

make docs

The generated HTML files will be in the docs/build/html directory. Open docs/build/html/index.html in your web browser to view the documentation.

For a live-reloading documentation server during development:

make servedocs

Security and Dependency Auditing

To check for known security vulnerabilities in our dependencies:

make audit

Useful Make Commands

To list all make commands to help you during development at any time:

make help

Next Steps and Useful Resources

We encourage you to explore the following resources to better understand the project and our development practices:

Project Specific Resources

General Python Development

Dependencies

  • httpx: Modern HTTP client.

  • Pydantic: Data validation and settings management.

  • pandas: Data analysis and manipulation.

  • geopandas: Spatial data analysis.

Linting and Code Quality

Testing

Development Workflow

Build and Deployment

Documentation