Skip to content

Commit 4ded7c5

Browse files
committed
remove matplotlib hard requirement
1 parent e24c2e9 commit 4ded7c5

5 files changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,13 @@ jobs:
8080
python3 -m build
8181
8282
# Install the newly built .whl file to verify the package is installable.
83+
# Install with the 'visualize' extra so matplotlib is available for the
84+
# plotting tests (tests/test_visualize.py). This also validates that the
85+
# optional 'visualize' extra resolves correctly.
8386
- name: Install PyGAD from Wheel
8487
run: |
85-
pip install dist/*.whl
88+
WHEEL=$(ls dist/*.whl)
89+
pip install "${WHEEL}[visualize]"
8690
8791
- name: Install PyTest
8892
run: pip install pytest

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ Install PyGAD with the following command:
3333
pip install pygad
3434
```
3535

36+
PyGAD's core install is intentionally lightweight (only `numpy` and `cloudpickle`). Some features need extra libraries, which are available as optional extras:
37+
38+
```
39+
# Plotting features (e.g. plot_fitness(), plot_genes()) need matplotlib:
40+
pip install pygad[visualize]
41+
42+
# Training Keras/PyTorch models (pygad.kerasga, pygad.torchga):
43+
pip install pygad[deep_learning]
44+
```
45+
3646
To get started with PyGAD, read the documentation at [Read the Docs](https://pygad.readthedocs.io).
3747

3848
# PyGAD Source Code

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ classifiers = [
4242
keywords = ["genetic algorithm", "GA", "optimization", "evolutionary algorithm", "natural evolution", "pygad", "machine learning", "deep learning", "neural networks", "tensorflow", "keras", "pytorch"]
4343
dependencies = [
4444
"numpy",
45-
"matplotlib",
4645
"cloudpickle",
4746
]
4847

@@ -58,6 +57,7 @@ dependencies = [
5857

5958
[project.optional-dependencies]
6059
deep_learning = ["keras", "tensorflow", "torch"]
60+
visualize = ["matplotlib"]
6161

6262
# PyTest Configuration. Later, PyTest will support the [tool.pytest] table.
6363
[tool.pytest.ini_options]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
numpy
2-
matplotlib
32
cloudpickle

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
setuptools.setup(
77
name="pygad",
88
author="Ahmed Fawzy Gad",
9-
install_requires=["numpy", "matplotlib", "cloudpickle",],
9+
install_requires=["numpy", "cloudpickle",],
1010
extras_require={
1111
"deep_learning": ["keras", "tensorflow", "torch"],
12+
"visualize": ["matplotlib"],
1213
},
1314
author_email="ahmed.f.gad@gmail.com",
1415

0 commit comments

Comments
 (0)