colcon-python-setup-py

0.2.9 · active · verified Fri Apr 17

colcon-python-setup-py is an extension for the colcon build system that enables it to properly discover, configure, and build Python packages that define their metadata using a `setup.py` file. It ensures `colcon` can correctly handle Python packages, resolve their dependencies, and integrate them into a larger workspace. The current version is 0.2.9, with active development and infrequent but stable releases, typically every 3-9 months.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to set up a `colcon` workspace, create a basic Python package with a `setup.py` file, and then use `colcon build` to compile and install it. The `colcon-python-setup-py` extension automatically detects the `setup.py` file and uses it to build the package.

# First, install colcon-core if you haven't already:
# pip install colcon-core

# Then, install the python setup.py extension:
# pip install colcon-python-setup-py

# 1. Create a colcon workspace and source directory
mkdir -p colcon_ws/src
cd colcon_ws/src

# 2. Create a simple Python package with setup.py
mkdir my_python_pkg
cd my_python_pkg

# Create setup.py
cat <<EOF > setup.py
from setuptools import setup, find_packages

setup(
    name='my_python_pkg',
    version='0.0.1',
    packages=find_packages(),
    install_requires=[],
    zip_safe=True,
    maintainer='Your Name',
    maintainer_email='your.email@example.com',
    description='A sample Python package for colcon.',
    license='Apache-2.0',
)
EOF

# Create a simple Python module
mkdir my_python_pkg
cat <<EOF > my_python_pkg/__init__.py
def hello_world():
    return "Hello from colcon-python-setup-py!"
EOF

# 3. Go back to the workspace root and build
cd ../..
colcon build

echo "\nBuild complete. Check 'colcon_ws/install' for the installed package."

view raw JSON →