# `ScotchPy`
This project provides a `Python3` interface for the [Scotch graph partitioning library](https://gitlab.inria.fr/scotch/scotch)
[](https://gitlab.inria.fr/ppavia/scotchpy/-/commits/main)
[](https://ppavia.gitlabpages.inria.fr/scotchpy/html)
## Requirements
- `Python >= 3.10`
- `NumPy`, to handle integer arrays
- `pytest`, to test the `ScotchPy` module
- Optional :
- `mpi4py`, to use the features of PT-ScotchPy
- `Sphinx`, to build the documentation
- `networkx` and `matplotlib`, to view some examples
- A recent *DYNAMIC/SHARED* `Scotch` library (>=`v7.0.9`), if you do not have access to the Internet
## Configuring, compiling and testing `ScotchPy`
### Configure
Before using `pip` you need to generate the `pyproject.toml` and select which version of the package you need:
- integer size (32/64) -> `export INTSIZE=64,` for instance
- ptscotch -> `export PTSCOTCH=ON`
```bash
./configure
```
At the time being, the scotchpy package supports 4 configurations:
| config | INTSIZE=32 | INTSIZE=64 |
|------------|------------|--------------|
| sequential | scotchpy | scotchpy64 |
| parallel | ptscotchpy | ptscotchpy64 |
Before using `pip` you need to generate the `pyproject.toml` and select which version of the package you need:
- integer size (32/64) -> `export INTSIZE=64,` for instance
- ptscotch -> `export PTSCOTCH=1`
```bash
./configure
```
We *strongly* recommand to have the same integer size for scotch than the `numpy.dtype`.
### If you already have a Scotch library >= 7.0.8 installed on your system
```bash
virtualenv /some/path
SCOTCHPY_SCOTCH="dir/containing/the/lib" /some/path/bin/pip -v install .
export SCOTCHPY_ERR=${$(find /some/path/lib/ -name "*scotchpy_err*.so"):h}
SCOTCHPY_SCOTCH="dir/containing/the/lib" /some/path/bin/python -m pytest
```
### Scotch library older than 7.0.9 or not available
The building system (`scikit-build-core`) will download sources from the Internet and compile it for you.
```bash
virtualenv /some/path
/some/path/bin/pip -v install . # This step uses scikit-build-core
/some/path/bin/python -m pytest
```
## Using a binary wheel from the Internet (*experimental*, only for Linux and sequential version at the time being)
```bash
virtualenv /tmp/test_sotchpy
/tmp/test_sotchpy/bin/pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple scotchpy64==1.0.1
/tmp/test_sotchpy/bin/python -c 'import scotchpy; print(scotchpy.num_sizeof())'
```
## Testing `ScotchPy`
To use `ScotchPy` locally, you can run some examples like `load_part.py` provided below:
```python
import scotchpy
import scotchpy
from scotchpy.common import proper_int as scotch_num
import importlib.resources as resources
import os
# Allocate a graph
graf = scotchpy.Graph()
# Read a graph from the scotchpy/data dir
data_dir = resources.files("scotchpy").joinpath("data")
graf.load(os.path.join(data_dir, "m4x4.grf"))
# Partition a graph into 4 parts
parttab = np.zeros(graf.vertnbr, dtype=scotch_num)
graf.part(partnbr = 4, parttab = parttab)
# Export the graph to the dot format
if scotchpy.graph._nx_found:
import networkx as nx
graf_nx = graf.tonx()
color = { 0:"red" , 1:"blue", 2:"green", 3:"black"}
for i in graf_nx.nodes:
graf_nx.nodes[i]["color"] = color[parttab[i]]
try:
nx.nx_pydot.to_pydot(graf_nx).write_dot("m4x4.dot")
except ModuleNotFoundError:
pass
```
from a `Python` prompt.
## Generating the documentation
```bash
sphinx-build -b html doc/source build/doc
```
The HTML pages will be in `build/doc`.
## Testing
To run all `ScotchPy` tests, type:
```bash
tmpdir=$(mktemp -d)
cp -R path/to/scotchpy/sources/tests $tmpdir
cd $tmpdir
/path/to/an/installed/scotchpy/bin/python -m pytest
```
For parallel tests (e.g. those involving `mpi4py` and the submodule `scotchpy.dgraph`), we use the plugin `pytest-isolate-mpi` that you can find on
[pypi.org](https://pypi.org/project/pytest-isolate-mpi/)
## Contributing
Contributions are welcome!
To apply the `pylint` syntax checking tool, type:
```bash
pylint --disable=R0902,R0903,R0904,R0912,R0913,C0114,C0116 scotchpy
```
## Authors
- Pierre PAVIA: initial core development, while intern at Inria Bordeaux-Sud Ouest (2020-2021)
- Aymen ALI YAHIA (aymenali.aay@gmail.com): final core development, while intern at Inria Bordeaux-Sud Ouest (2024)
- Marc FUENTES (marc.fuentes@inria.fr): support and packaging
- François PELLEGRINI (francois.pellegrini@u-bordeaux.fr): project architect and syntax nitpicker
## License
This project is distributed under the 2-clause BSD License.
Raw data
{
"_id": null,
"home_page": null,
"name": "scotchpy64",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Marc Fuentes <marc.fuentes@inria.fr>",
"keywords": "graph, partitioning, mapping, reordering, sparse matrix",
"author": "Pierre PAVIA",
"author_email": "Aymen ALI YAHIA <aymenali.aay@gmail.com>, Marc FUENTES <marc.fuentes@inria.fr>, Francois PELLEGRINI <francois.pellegrini@u-bordeaux.fr>",
"download_url": null,
"platform": null,
"description": "# `ScotchPy`\n\nThis project provides a `Python3` interface for the [Scotch graph partitioning library](https://gitlab.inria.fr/scotch/scotch)\n\n[](https://gitlab.inria.fr/ppavia/scotchpy/-/commits/main)\n[](https://ppavia.gitlabpages.inria.fr/scotchpy/html)\n\n## Requirements\n\n- `Python >= 3.10`\n- `NumPy`, to handle integer arrays\n- `pytest`, to test the `ScotchPy` module\n- Optional :\n - `mpi4py`, to use the features of PT-ScotchPy\n - `Sphinx`, to build the documentation\n - `networkx` and `matplotlib`, to view some examples\n - A recent *DYNAMIC/SHARED* `Scotch` library (>=`v7.0.9`), if you do not have access to the Internet\n\n## Configuring, compiling and testing `ScotchPy`\n\n### Configure\nBefore using `pip` you need to generate the `pyproject.toml` and select which version of the package you need:\n- integer size (32/64) -> `export INTSIZE=64,` for instance\n- ptscotch -> `export PTSCOTCH=ON`\n```bash\n./configure\n```\nAt the time being, the scotchpy package supports 4 configurations:\n\n | config | INTSIZE=32 | INTSIZE=64 |\n |------------|------------|--------------|\n | sequential | scotchpy | scotchpy64 |\n | parallel | ptscotchpy | ptscotchpy64 |\n\nBefore using `pip` you need to generate the `pyproject.toml` and select which version of the package you need:\n- integer size (32/64) -> `export INTSIZE=64,` for instance\n- ptscotch -> `export PTSCOTCH=1`\n```bash\n./configure\n```\nWe *strongly* recommand to have the same integer size for scotch than the `numpy.dtype`.\n\n### If you already have a Scotch library >= 7.0.8 installed on your system\n\n```bash\nvirtualenv /some/path\nSCOTCHPY_SCOTCH=\"dir/containing/the/lib\" /some/path/bin/pip -v install .\nexport SCOTCHPY_ERR=${$(find /some/path/lib/ -name \"*scotchpy_err*.so\"):h}\nSCOTCHPY_SCOTCH=\"dir/containing/the/lib\" /some/path/bin/python -m pytest\n```\n\n### Scotch library older than 7.0.9 or not available\n\nThe building system (`scikit-build-core`) will download sources from the Internet and compile it for you.\n```bash\nvirtualenv /some/path\n/some/path/bin/pip -v install . # This step uses scikit-build-core\n/some/path/bin/python -m pytest\n```\n\n## Using a binary wheel from the Internet (*experimental*, only for Linux and sequential version at the time being)\n```bash\nvirtualenv /tmp/test_sotchpy\n/tmp/test_sotchpy/bin/pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple scotchpy64==1.0.1\n/tmp/test_sotchpy/bin/python -c 'import scotchpy; print(scotchpy.num_sizeof())'\n```\n\n## Testing `ScotchPy`\n\nTo use `ScotchPy` locally, you can run some examples like `load_part.py` provided below:\n```python\nimport scotchpy\nimport scotchpy \nfrom scotchpy.common import proper_int as scotch_num\nimport importlib.resources as resources\nimport os\n\n# Allocate a graph\n\ngraf = scotchpy.Graph()\n\n# Read a graph from the scotchpy/data dir\n\ndata_dir = resources.files(\"scotchpy\").joinpath(\"data\")\ngraf.load(os.path.join(data_dir, \"m4x4.grf\"))\n\n# Partition a graph into 4 parts\n\nparttab = np.zeros(graf.vertnbr, dtype=scotch_num)\ngraf.part(partnbr = 4, parttab = parttab)\n\n# Export the graph to the dot format\n\nif scotchpy.graph._nx_found:\n import networkx as nx\n graf_nx = graf.tonx()\n color = { 0:\"red\" , 1:\"blue\", 2:\"green\", 3:\"black\"}\n for i in graf_nx.nodes:\n graf_nx.nodes[i][\"color\"] = color[parttab[i]]\n try:\n nx.nx_pydot.to_pydot(graf_nx).write_dot(\"m4x4.dot\")\n except ModuleNotFoundError:\n pass\n```\nfrom a `Python` prompt.\n\n\n## Generating the documentation\n\n```bash\nsphinx-build -b html doc/source build/doc\n```\nThe HTML pages will be in `build/doc`.\n\n## Testing\n\nTo run all `ScotchPy` tests, type:\n```bash\ntmpdir=$(mktemp -d)\ncp -R path/to/scotchpy/sources/tests $tmpdir\ncd $tmpdir\n/path/to/an/installed/scotchpy/bin/python -m pytest\n```\nFor parallel tests (e.g. those involving `mpi4py` and the submodule `scotchpy.dgraph`), we use the plugin `pytest-isolate-mpi` that you can find on \n[pypi.org](https://pypi.org/project/pytest-isolate-mpi/)\n\n\n## Contributing\n\nContributions are welcome!\n\nTo apply the `pylint` syntax checking tool, type:\n```bash\npylint --disable=R0902,R0903,R0904,R0912,R0913,C0114,C0116 scotchpy\n```\n\n\n## Authors\n\n- Pierre PAVIA: initial core development, while intern at Inria Bordeaux-Sud Ouest (2020-2021)\n- Aymen ALI YAHIA (aymenali.aay@gmail.com): final core development, while intern at Inria Bordeaux-Sud Ouest (2024)\n- Marc FUENTES (marc.fuentes@inria.fr): support and packaging\n- Fran\u00e7ois PELLEGRINI (francois.pellegrini@u-bordeaux.fr): project architect and syntax nitpicker\n\n## License\n\nThis project is distributed under the 2-clause BSD License.\n",
"bugtrack_url": null,
"license": null,
"summary": "The official Python interface to the Scotch and PT-Scotch graph partitioning libraries",
"version": "1.0.1",
"project_urls": null,
"split_keywords": [
"graph",
" partitioning",
" mapping",
" reordering",
" sparse matrix"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "bcd1ef71e3836625fc31e9578c275ddcf197fcbc60362dce822369aa1ecde422",
"md5": "83028ddf48569ec0bbfdc65a34117502",
"sha256": "276fd237f27ad5e71731ea5fac3e78964062ae98112be6d1eef579cff7c864e8"
},
"downloads": -1,
"filename": "scotchpy64-1.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "83028ddf48569ec0bbfdc65a34117502",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 2123704,
"upload_time": "2025-08-31T09:46:50",
"upload_time_iso_8601": "2025-08-31T09:46:50.596907Z",
"url": "https://files.pythonhosted.org/packages/bc/d1/ef71e3836625fc31e9578c275ddcf197fcbc60362dce822369aa1ecde422/scotchpy64-1.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bdb35e171536989e4fa154b22a480f256dd5fada8d9ce47614c77b747adb250c",
"md5": "aae9447275ac29166f40d34cf4dc606f",
"sha256": "78b17354dafe8d99471ff01fc54ce2d26fca2061ea27db95c8f8bb73813fc579"
},
"downloads": -1,
"filename": "scotchpy64-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "aae9447275ac29166f40d34cf4dc606f",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.10",
"size": 2123702,
"upload_time": "2025-08-31T09:46:54",
"upload_time_iso_8601": "2025-08-31T09:46:54.365956Z",
"url": "https://files.pythonhosted.org/packages/bd/b3/5e171536989e4fa154b22a480f256dd5fada8d9ce47614c77b747adb250c/scotchpy64-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5fbe3b344a1beba0abd011d0193f151d510a286787d3910c3ae3d7940dd70931",
"md5": "88269dcbe8efa3dad9fb7a20576e8a40",
"sha256": "87705f9c4105740306d5048c7c44a51e62b2f03c9a95fa7610d6a3386989e8c5"
},
"downloads": -1,
"filename": "scotchpy64-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "88269dcbe8efa3dad9fb7a20576e8a40",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.10",
"size": 2123702,
"upload_time": "2025-08-31T09:46:58",
"upload_time_iso_8601": "2025-08-31T09:46:58.227796Z",
"url": "https://files.pythonhosted.org/packages/5f/be/3b344a1beba0abd011d0193f151d510a286787d3910c3ae3d7940dd70931/scotchpy64-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3bea12491425a0148b8b0ccbe3694a24d2b498a99c21084c8cec09e3e94dd78f",
"md5": "d0c7760c94c597b49d0ac0ac0e9ca17e",
"sha256": "e2ea7f50b3a7797e0cd71537b2c072114dd9bb6ca48dc5f826d555370eb3150a"
},
"downloads": -1,
"filename": "scotchpy64-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "d0c7760c94c597b49d0ac0ac0e9ca17e",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.10",
"size": 2123703,
"upload_time": "2025-08-31T09:47:02",
"upload_time_iso_8601": "2025-08-31T09:47:02.125091Z",
"url": "https://files.pythonhosted.org/packages/3b/ea/12491425a0148b8b0ccbe3694a24d2b498a99c21084c8cec09e3e94dd78f/scotchpy64-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "82cdb2f1f81a7adbec6e4c70cea0b518f89c5b2650e2fdc669aed380bcbb2bb4",
"md5": "24d0c497a208c1bd3bb8eb4e4ff39496",
"sha256": "3cd52831289d592cca3ca9ec4093467855f3c77d0af0966ba182fe49ceadc4d2"
},
"downloads": -1,
"filename": "scotchpy64-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "24d0c497a208c1bd3bb8eb4e4ff39496",
"packagetype": "bdist_wheel",
"python_version": "cp314",
"requires_python": ">=3.10",
"size": 2123703,
"upload_time": "2025-08-31T09:47:04",
"upload_time_iso_8601": "2025-08-31T09:47:04.906596Z",
"url": "https://files.pythonhosted.org/packages/82/cd/b2f1f81a7adbec6e4c70cea0b518f89c5b2650e2fdc669aed380bcbb2bb4/scotchpy64-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e4f025613cd7f193b23dd5f886555b04012816fcebe0589c39d51e75f9fcb687",
"md5": "ceb96387834686daf6f46f3aa7c63d68",
"sha256": "e0c8c77a8aa5cc75d59b40cfb47f02814c5bdfb605fc82deaa57cac4f486f125"
},
"downloads": -1,
"filename": "scotchpy64-1.0.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "ceb96387834686daf6f46f3aa7c63d68",
"packagetype": "bdist_wheel",
"python_version": "cp314",
"requires_python": ">=3.10",
"size": 2123708,
"upload_time": "2025-08-31T09:47:07",
"upload_time_iso_8601": "2025-08-31T09:47:07.665665Z",
"url": "https://files.pythonhosted.org/packages/e4/f0/25613cd7f193b23dd5f886555b04012816fcebe0589c39d51e75f9fcb687/scotchpy64-1.0.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-31 09:46:50",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "scotchpy64"
}