# `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.8`), 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=1`
```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.8 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==0.1.5
/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.8`), 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=1`\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.8 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==0.1.5\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.0",
"project_urls": null,
"split_keywords": [
"graph",
" partitioning",
" mapping",
" reordering",
" sparse matrix"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a60e6b2001fc6b935915f98cab914ee70a783967c1dec39ab1ff9aa0a6bd3e64",
"md5": "f9d35a98822eb5e868e1d94c57097125",
"sha256": "fc7cb7de40e7b6aeb04b21aa969f0cc04daa413adc9d943bbaa0e3dbd3bc252f"
},
"downloads": -1,
"filename": "scotchpy64-1.0.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "f9d35a98822eb5e868e1d94c57097125",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 2112682,
"upload_time": "2025-07-10T11:26:17",
"upload_time_iso_8601": "2025-07-10T11:26:17.697192Z",
"url": "https://files.pythonhosted.org/packages/a6/0e/6b2001fc6b935915f98cab914ee70a783967c1dec39ab1ff9aa0a6bd3e64/scotchpy64-1.0.0-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": "8dbdf5dd57fc95c268e97620cc817366b2bb3edd8967656301d82094563ac8ca",
"md5": "5728cc1ceead712aac93f4e638360865",
"sha256": "abe575a4214191e8a12d1da6aa50c24d5f917840044bd4b81cf21451b6edb8b2"
},
"downloads": -1,
"filename": "scotchpy64-1.0.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "5728cc1ceead712aac93f4e638360865",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.10",
"size": 2112683,
"upload_time": "2025-07-10T11:26:26",
"upload_time_iso_8601": "2025-07-10T11:26:26.043269Z",
"url": "https://files.pythonhosted.org/packages/8d/bd/f5dd57fc95c268e97620cc817366b2bb3edd8967656301d82094563ac8ca/scotchpy64-1.0.0-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": "f640b3591fcf9cea7a9f6ac9e97292efa02cc547eddc4607891a0796a551ab2f",
"md5": "b575e720e25598703f2dee6bae7c3870",
"sha256": "1775317ab628541d43ede404ccbcf77f9499c38529db82798ff6efa4e67a213d"
},
"downloads": -1,
"filename": "scotchpy64-1.0.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "b575e720e25598703f2dee6bae7c3870",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.10",
"size": 2112681,
"upload_time": "2025-07-10T11:26:28",
"upload_time_iso_8601": "2025-07-10T11:26:28.008159Z",
"url": "https://files.pythonhosted.org/packages/f6/40/b3591fcf9cea7a9f6ac9e97292efa02cc547eddc4607891a0796a551ab2f/scotchpy64-1.0.0-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": "92eaa5b2d76c8ddeb23c9b9c8f9adec9b2aa3c1c043725e1073513c7d9efc67a",
"md5": "38eba1f721c8d0b1089ed760be2323f2",
"sha256": "e14b4303bdb7acd7ec7e4844fbcc3c5c389aad35cdce9839e24283160e5e2a4b"
},
"downloads": -1,
"filename": "scotchpy64-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "38eba1f721c8d0b1089ed760be2323f2",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.10",
"size": 2112683,
"upload_time": "2025-07-10T11:26:29",
"upload_time_iso_8601": "2025-07-10T11:26:29.610775Z",
"url": "https://files.pythonhosted.org/packages/92/ea/a5b2d76c8ddeb23c9b9c8f9adec9b2aa3c1c043725e1073513c7d9efc67a/scotchpy64-1.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-10 11:26:17",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "scotchpy64"
}