Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov ruff
pip install -e .

- name: Lint
run: |
ruff check genetic_algorithm tests/test_python_package.py

- name: Run Python tests with coverage
run: |
pytest --cov=genetic_algorithm
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish to PyPI

on:
release:
types: [published]
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Build distributions
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Genetic Algorithm Framework (C++)

![CI](https://github.com/Rahuldrabit/Genetic_algorithm/actions/workflows/ci.yml/badge.svg)

A reusable C++ genetic algorithm framework you can embed in any application. It exposes a small, modern C++ API and ships with a rich set of crossover, mutation, and selection operators.

## 🚀 Features
Expand Down
10 changes: 10 additions & 0 deletions genetic_algorithm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Python package alias for the compiled :mod:`ga` extension."""

import ga as _ga

if hasattr(_ga, "__all__"):
__all__ = _ga.__all__
else:
__all__ = [name for name in dir(_ga) if not name.startswith("_")]

globals().update({name: getattr(_ga, name) for name in __all__})
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Repository = "https://github.com/Rahuldrabit/Genetic_algorithm"
Issues = "https://github.com/Rahuldrabit/Genetic_algorithm/issues"

[tool.scikit-build]
# This project ships a compiled extension module (`ga`) and no pure-Python package tree.
wheel.packages = []
# Ship the compiled extension (`ga`) and a lightweight Python package alias.
wheel.packages = ["genetic_algorithm"]
5 changes: 5 additions & 0 deletions tests/test_python_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def test_genetic_algorithm_importable():
import genetic_algorithm

assert hasattr(genetic_algorithm, "Config")
assert hasattr(genetic_algorithm, "Result")
Loading