Skip to content
Merged
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
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ if(pybind11_FOUND)
OUTPUT_NAME "ga"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/python"
)
if(SKBUILD)
install(TARGETS ga_python_module
LIBRARY DESTINATION .
RUNTIME DESTINATION .
)
else()
install(TARGETS ga_python_module
LIBRARY DESTINATION lib/python
RUNTIME DESTINATION lib/python
)
Comment on lines +183 to +186
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The non-SKBUILD install destination lib/python is unlikely to be on Python’s default import path (it’s not a standard site-packages location), so cmake --install / make install will produce an installed module that typically can’t be imported. Consider installing to the discovered Python site-packages (e.g., CMake’s Python3 site variables) or only defining install rules under SKBUILD if non-skbuild installs aren’t supported.

Suggested change
install(TARGETS ga_python_module
LIBRARY DESTINATION lib/python
RUNTIME DESTINATION lib/python
)
# For non-SKBUILD installs, install into Python's site-packages directory
unset(_python_install_dir CACHE)
if(Python3_FOUND)
if(Python3_SITEARCH)
set(_python_install_dir "${Python3_SITEARCH}")
elseif(Python3_SITELIB)
set(_python_install_dir "${Python3_SITELIB}")
endif()
endif()
if(DEFINED _python_install_dir)
install(TARGETS ga_python_module
LIBRARY DESTINATION "${_python_install_dir}"
RUNTIME DESTINATION "${_python_install_dir}"
)
else()
message(WARNING
"Python site-packages directory not found; "
"skipping installation of 'ga_python_module'. "
"Use SKBUILD or ensure Python3_SITEARCH/SITELIB is available."
)
endif()

Copilot uses AI. Check for mistakes.
endif()
Comment on lines +177 to +187
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title/description focus on license metadata alignment, but this change set also adds pip install documentation and new CMake install rules for SKBUILD/non-SKBUILD builds. Please update the PR description (or title) to reflect these additional packaging/install behavior changes so reviewers and downstream consumers aren’t surprised.

Copilot uses AI. Check for mistakes.
message(STATUS "Python bindings: ENABLED (pybind11 ${pybind11_VERSION})")
else()
message(STATUS "Python bindings: DISABLED (pybind11 not found — install with: pip install pybind11)")
Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[build-system]
requires = ["scikit-build-core>=0.10", "pybind11>=2.6"]
build-backend = "scikit_build_core.build"

[project]
name = "genetic-algorithm"
version = "1.0.0"
description = "Genetic Algorithm framework with C++ core and Python bindings"
readme = "README.md"
requires-python = ">=3.8"
license = { text = "Apache-2.0" }
authors = [{ name = "Rahuldrabit" }]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: C++",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
]

[project.urls]
Homepage = "https://github.com/Rahuldrabit/Genetic_algorithm"
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 = []
20 changes: 20 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ cmake --build build --target ga_python_module

The module is produced under `build/python`.

## Install with pip

From the repository root:

```bash
python3 -m pip install .
```

Or for editable/development install:

```bash
python3 -m pip install -e .
```
Comment on lines +25 to +29
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README’s pip install -e . guidance can be misleading for scikit-build-core editable installs: editable support is experimental and often requires extra caveats (e.g., recommended --no-build-isolation, rebuild expectations for compiled code, and/or persistent build dir if using rebuild-on-import). Please document these caveats or adjust the wording so users don’t expect automatic rebuild behavior.

Copilot uses AI. Check for mistakes.

Then import directly:

```python
import ga
```

## Example

Run the bundled example:
Expand Down
Loading