-
Notifications
You must be signed in to change notification settings - Fork 459
Building From Source
Compiling ExaBGP and Creating Distribution Packages
This guide covers building ExaBGP from source code, creating Debian (.deb) packages, and creating RPM packages. Most users should install via pip or package managers (see Installation Guide), but building from source is useful for development, testing unreleased versions, or packaging for internal distribution.
- When to Build From Source
- Prerequisites
- Building from Git
- Creating Debian Packages
- Creating RPM Packages
- Testing Your Build
- Development Workflow
- Common Issues
- See Also
Consider building from source if you:
- β
Need unreleased features from
mainbranch - β Want to test bug fixes before release
- β Contribute to ExaBGP development
- β Create custom packages for internal distribution
- β Run ExaBGP on unsupported platforms
- β Need to apply custom patches
Use package manager instead if you:
- β Just want to use ExaBGP in production
- β Prefer stable, tested releases
- β Want automatic updates
Python Version:
- Minimum: Python 3.7
- Recommended: Python 3.9+
- Latest: Python 3.11+ (best performance)
Required Tools:
# Git for source code
git --version
# Python development tools
python3 --version
python3 -m pip --version# Basic build tools
sudo apt-get update
sudo apt-get install -y git python3 python3-pip python3-dev python3-setuptools
# For building .deb packages
sudo apt-get install -y \
git-core \
devscripts \
build-essential \
lintian \
python3-all \
python3-setuptools \
dh-python# Basic build tools
sudo dnf install -y git python3 python3-pip python3-devel python3-setuptools
# For building RPM packages
sudo dnf install -y \
rpm-build \
rpmdevtools \
python3-devel \
python3-setuptools# Install Homebrew if needed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Python and git
brew install python gitLatest development version (main branch):
git clone https://github.com/Exa-Networks/exabgp.git
cd exabgpSpecific release (recommended for stability):
git clone https://github.com/Exa-Networks/exabgp.git
cd exabgp
git tag -l # List available tags
git checkout 4.2.21 # Checkout specific versionSpecific branch:
git clone https://github.com/Exa-Networks/exabgp.git
cd exabgp
git checkout -b my-branch origin/some-feature-branchEditable install (for development):
# Install in development mode (changes reflect immediately)
python3 -m pip install -e .
# Verify installation
exabgp --version
which exabgp # Should show your git checkout pathStandard install:
# Install to system Python
sudo python3 setup.py install
# Or install to user directory (no sudo)
python3 setup.py install --user
# Verify
exabgp --versionExaBGP has NO runtime dependencies!
ExaBGP is designed to have zero external dependencies for maximum portability.
Development dependencies (optional, for testing):
# For running tests
python3 -m pip install pytest pytest-cov
# For code linting
python3 -m pip install flake8 pycodestyleBuild .deb packages for Debian, Ubuntu, Mint, etc.
π‘ Attribution: Based on community contributions. Debian packaging is maintained by the Debian Python team.
sudo apt-get install -y \
git-core \
devscripts \
build-essential \
lintian \
python3-all \
python3-setuptools \
dh-pythonStep 1: Clone and checkout version
git clone https://github.com/Exa-Networks/exabgp.git
cd exabgp
# Checkout specific version (example: 4.2.21)
git checkout 4.2.21Step 2: Retrieve Debian packaging files
# Get debian/ directory from packaging branch
git checkout origin/debian/sid -- debianStep 3: Update changelog
# Update version in changelog
dch -v 4.2.21-1 "New upstream release"
# Or manually edit
editor debian/changelogStep 4: Prepare build
# Remove incompatible settings (if needed)
rm -f debian/source/format
# Clean up any version-specific issues
# (Adjust based on your version)Step 5: Build packages
# Build unsigned packages (for local use)
debuild -us -uc
# You may see warning about missing .orig tarball
# Answer 'y' to continue
# Build with signing (for distribution)
debuild -saStep 6: Install built packages
# Packages are created in parent directory
cd ..
ls -la *.deb
# Install packages
sudo dpkg -i exabgp_*.deb
# Fix dependencies if needed
sudo apt-get install -fPackages created:
-
exabgp_X.Y.Z-N_all.deb- Main ExaBGP package -
exabgp-common_X.Y.Z-N_all.deb- Common files (if separate)
Installation locations:
- Binary:
/usr/sbin/exabgp - Python modules:
/usr/lib/python3/dist-packages/exabgp/ - Configuration:
/etc/exabgp/ - Systemd unit:
/lib/systemd/system/exabgp.service - Documentation:
/usr/share/doc/exabgp/
Build RPM packages for RHEL, CentOS, Fedora, etc.
π‘ Attribution: EPEL packaging guidance by @garybuhrmaster (Issue #1166).
# Install build tools
sudo dnf install -y rpm-build rpmdevtools python3-devel python3-setuptools
# Setup RPM build environment
rpmdev-setuptreeFor EPEL 9 (Fedora 36+, RHEL 9+):
π‘ Quote from Gary Buhrmaster: "The packaging has been modified from the generic spec file on this site to use (what the RH python packagers call) 'modern' python build macros available in Fedora and EL9."
The ExaBGP SPEC file for Fedora/EPEL is maintained in Fedora dist-git:
- Fedora SPEC: https://src.fedoraproject.org/rpms/python-exabgp/tree/rawhide
- EPEL 9 SPEC: https://src.fedoraproject.org/rpms/python-exabgp/tree/epel9
Download and use:
# Get the SPEC file from Fedora dist-git
curl -O https://src.fedoraproject.org/rpms/python-exabgp/raw/epel9/f/python-exabgp.spec
# Download source tarball
spectool -g python-exabgp.spec
# Copy to rpmbuild
cp python-exabgp.spec ~/rpmbuild/SPECS/
cp exabgp-*.tar.gz ~/rpmbuild/SOURCES/
# Build RPM
cd ~/rpmbuild/SPECS
rpmbuild -ba python-exabgp.specStep 1: Create source tarball
git clone https://github.com/Exa-Networks/exabgp.git
cd exabgp
git checkout 4.2.21
# Create tarball
git archive --format=tar.gz --prefix=exabgp-4.2.21/ \
-o ~/rpmbuild/SOURCES/exabgp-4.2.21.tar.gz 4.2.21Step 2: Create basic SPEC file
# Use Fedora SPEC as template (recommended)
# Or create minimal SPEC:
cat > ~/rpmbuild/SPECS/exabgp.spec << 'EOF'
%global srcname exabgp
Name: python-%{srcname}
Version: 4.2.21
Release: 1%{?dist}
Summary: BGP route injector
License: BSD
URL: https://github.com/Exa-Networks/exabgp
Source0: %{srcname}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
%description
ExaBGP is a BGP route injector.
%prep
%autosetup -n %{srcname}-%{version}
%build
%py3_build
%install
%py3_install
# Install systemd unit
install -D -m 644 etc/systemd/exabgp.service %{buildroot}%{_unitdir}/exabgp.service
# Install configuration
install -D -m 644 etc/exabgp/exabgp.conf %{buildroot}%{_sysconfdir}/exabgp/exabgp.conf
%files
%license COPYRIGHT
%doc README.md CHANGELOG.rst
%{_bindir}/exabgp
%{python3_sitelib}/%{srcname}/
%{python3_sitelib}/%{srcname}-*.egg-info/
%{_unitdir}/exabgp.service
%config(noreplace) %{_sysconfdir}/exabgp/
%changelog
* $(date +"%a %b %d %Y") Your Name <[email protected]> - 4.2.21-1
- New upstream release
EOFStep 3: Build RPM
cd ~/rpmbuild/SPECS
rpmbuild -ba exabgp.spec
# Check built packages
ls -la ~/rpmbuild/RPMS/noarch/
ls -la ~/rpmbuild/SRPMS/Step 4: Install
sudo dnf install ~/rpmbuild/RPMS/noarch/python3-exabgp-*.rpmPackage name: python3-exabgp
Installation locations:
- Binary:
/usr/bin/exabgp - Python modules:
/usr/lib/python3.X/site-packages/exabgp/ - Configuration:
/etc/exabgp/ - Systemd unit:
/usr/lib/systemd/system/exabgp.service - Documentation:
/usr/share/doc/python3-exabgp/
# Check version
exabgp --version
# Validate configuration syntax
exabgp --test /etc/exabgp/exabgp.conf
# Run in foreground (test mode)
exabgp --debug /etc/exabgp/exabgp.conf
# Should see:
# "Listening for BGP session on..."
# Press Ctrl+C to stopcd /path/to/exabgp/source
# Install test dependencies
python3 -m pip install pytest pytest-cov
# Run all tests
python3 -m pytest
# Run specific test
python3 -m pytest tests/test_neighbor.py
# Run with coverage
python3 -m pytest --cov=exabgp tests/# Create minimal test config
cat > /tmp/test-exabgp.conf << 'EOF'
process monitor {
run python3 -c "import sys; print('ExaBGP API test'); sys.stdout.flush()";
encoder text;
}
neighbor 127.0.0.1 {
router-id 10.0.0.1;
local-address 127.0.0.1;
local-as 65001;
peer-as 65001;
}
EOF
# Run test
exabgp --debug /tmp/test-exabgp.conf
# Should see "ExaBGP API test" output# Clone repo
git clone https://github.com/Exa-Networks/exabgp.git
cd exabgp
# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate
# Install in editable mode
pip install -e .
# Now you can edit code and test immediately
# No reinstall needed - changes reflect immediately# Set PYTHONPATH to source directory
export PYTHONPATH=/path/to/exabgp/src:$PYTHONPATH
# Run directly
./src/exabgp/application/cli.py --version# Install linters
pip install flake8 pycodestyle
# Check code style
flake8 src/exabgp/
# Auto-format (optional)
pip install black
black src/exabgp/Problem: SyntaxError or ModuleNotFoundError
Solution:
# Check Python version
python3 --version # Must be 3.7+
# Use specific Python version
python3.11 -m pip install -e .
python3.11 ./src/exabgp/application/cli.pyProblem: [Errno 13] Permission denied when binding to port 179
Solution:
# Option 1: Run as root (not recommended)
sudo exabgp /etc/exabgp/exabgp.conf
# Option 2: Use capability (Linux)
sudo setcap cap_net_bind_service=+ep $(which exabgp)
# Option 3: Use high port for testing
# In config: neighbor 127.0.0.1 { local-address 127.0.0.1 port 1790; }Problem: expected exabgp_X.Y.Z.orig.tar.gz
Solution:
# Create .orig tarball
git archive --format=tar.gz --prefix=exabgp-4.2.21/ \
-o ../exabgp_4.2.21.orig.tar.gz 4.2.21
# Then run debuild again
debuild -us -ucProblem: Unknown tag: %py3_build
Solution:
# Install python3-rpm-macros
sudo dnf install python3-rpm-macros
# Fedora modern macros
sudo dnf install python3-rpm-generators- Installation Guide - Standard installation methods
- Quick Start - Getting started with ExaBGP
- Configuration Syntax - Configuration file format
- Debugging - Troubleshooting ExaBGP issues
- ExaBGP GitHub: https://github.com/Exa-Networks/exabgp
- Fedora SPEC File: https://src.fedoraproject.org/rpms/python-exabgp
- Debian Packaging: https://salsa.debian.org/python-team/packages/exabgp
- Python Packaging Guide: https://packaging.python.org/
π» Ghost written by Claude (Anthropic AI)
π Home
π Getting Started
π§ API
π‘οΈ Use Cases
π Address Families
βοΈ Configuration
π Operations
π Reference
- Architecture
- BGP State Machine
- Communities (RFC)
- Extended Communities
- BGP Ecosystem
- Capabilities (AFI/SAFI)
- RFC Support
π Migration
π Community
π External
- GitHub Repo β
- Slack β
- Issues β
π» Ghost written by Claude (Anthropic AI)