diff --git a/CMakeLists.txt b/CMakeLists.txt index 45a93a9..a2da11f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 + ) + endif() message(STATUS "Python bindings: ENABLED (pybind11 ${pybind11_VERSION})") else() message(STATUS "Python bindings: DISABLED (pybind11 not found — install with: pip install pybind11)") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3c5e72b --- /dev/null +++ b/pyproject.toml @@ -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 = [] diff --git a/python/README.md b/python/README.md index 1f18a17..8b2bfce 100644 --- a/python/README.md +++ b/python/README.md @@ -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 . +``` + +Then import directly: + +```python +import ga +``` + ## Example Run the bundled example: