Skip to content

Commit 5ca23e1

Browse files
Move metadata from setup.py to pyproject.toml and build retworkx in a separate setup.py (#1419)
* Modernize setup.py * Farewell to retworkx * Add release note about retworkx removal * Move even more data to pyproject.toml * PEP 639 says this is deprecated * Add dependency groups later * Move even from setup.py to pyproject.toml * Migrate all setup.py to pyproject.toml * Move nox dependencies to pyproject.toml * Document new way to do debug builds now that we no longer use setup.py * Better way to phrase the documentation * Remove duplicate section * Try updating setuptools for coverage job * Add docs dependency group as well * Make description the same as the paper * Revert retworkx code * Say this will be the last retworkx release * Trying to make retworkx work * retworkx has its own setup.py * Account for new directory when publishing * Document setuptools-rust * Edit message saying it is the final release * sunset -> retired * Endline * Ensure setuptools-rust is up-to-date * Use setuptools>=70.1.0 and remove wheel * Apply suggestions from code review Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Black --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
1 parent 62181fb commit 5ca23e1

15 files changed

+202
-143
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
- name: Clippy
3838
run: cargo clippy --workspace --all-targets -- -D warnings
3939
- name: Black Codestyle Format
40-
run: black --check --diff retworkx rustworkx retworkx tests
40+
run: black --check --diff rustworkx tests retworkx
4141
- name: Python Lint
42-
run: ruff check rustworkx retworkx setup.py tests
42+
run: ruff check rustworkx setup.py tests retworkx
4343
- name: Check stray release notes
4444
run: python tools/find_stray_release_notes.py
4545
- name: rustworkx-core Rust Tests
@@ -141,21 +141,21 @@ jobs:
141141
- name: Download grcov
142142
run: curl -L https://github.com/mozilla/grcov/releases/download/v0.8.7/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf -
143143
- name: Install deps
144-
run: pip install -U setuptools-rust networkx testtools fixtures stestr
145-
- name: Build retworkx
144+
run: pip install -U setuptools setuptools-rust networkx testtools fixtures stestr
145+
- name: Build rustworkx
146146
run: python setup.py develop
147147
env:
148148
CARGO_INCREMENTAL: 0
149149
RUSTFLAGS: "-Cinstrument-coverage"
150-
LLVM_PROFILE_FILE: "retworkx-%p-%m.profraw"
150+
LLVM_PROFILE_FILE: "rustworkx-%p-%m.profraw"
151151
- name: Run tests
152152
run: cd tests && stestr run && cd ..
153153
env:
154-
LLVM_PROFILE_FILE: "retworkx-%p-%m.profraw"
154+
LLVM_PROFILE_FILE: "rustworkx-%p-%m.profraw"
155155
- name: Run grcov
156156
run: |
157157
set -e
158-
mv tests/retworkx*profraw .
158+
mv tests/rustworkx*profraw .
159159
./grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o ./coveralls.lcov
160160
- uses: actions/upload-artifact@v4
161161
with:

.github/workflows/wheels.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,10 @@ jobs:
202202
- name: Install deps
203203
run: pip install -U setuptools-rust wheel build
204204
- name: Build sdist
205-
run: python setup.py bdist_wheel
206-
env:
207-
RUSTWORKX_PKG_NAME: retworkx
205+
run: pushd retworkx && python setup.py bdist_wheel && popd
208206
- uses: actions/upload-artifact@v4
209207
with:
210-
path: ./dist/*
208+
path: ./retworkx/dist/*
211209
name: sdist-retworkx
212210
- name: Publish package distributions to PyPI
213211
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ retworkx/*pyd
2121
!/docs/source/images/*.svg
2222
*.jpg
2323
**/*.so
24-
retworkx-core/Cargo.lock
24+
rustworkx-core/Cargo.lock
2525
**/.DS_Store
2626
venv/
27+
.python-version

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ environment.
5959

6060
If there are no precompiled binaries published for your system you'll have to
6161
build the package from source. However, to be able to build the package
62-
from the published source package you need to have Rust >= 1.70 installed (and
62+
from the published source package you need to have Rust >= 1.79 installed (and
6363
also [cargo](https://doc.rust-lang.org/cargo/) which is normally included with
6464
rust) You can use [rustup](https://rustup.rs/) (a cross platform installer for
6565
rust) to make this simpler, or rely on
@@ -77,10 +77,10 @@ it just as it would if there was a prebuilt binary available.
7777
> [!NOTE]
7878
> To build from source you will need to ensure you have pip >=19.0.0
7979
installed, which supports PEP-517, or that you have manually installed
80-
`setuptools-rust` prior to running `pip install rustworkx`. If you receive an
80+
`setuptools-rust>=1.9` prior to running `pip install rustworkx`. If you receive an
8181
error about `setuptools-rust` not being found you should upgrade pip with
8282
`pip install -U pip` or manually install `setuptools-rust` with
83-
`pip install setuptools-rust` and try again.
83+
`pip install -U setuptools-rust` and try again.
8484

8585
### Optional dependencies
8686

@@ -157,17 +157,14 @@ changes reflected in your python environment.
157157
### Develop Mode
158158

159159
If you'd like to build rustworkx in debug mode and use an interactive debugger
160-
while working on a change you can use `python setup.py develop` to build
161-
and install rustworkx in develop mode. This will build rustworkx without
162-
optimizations and include debuginfo which can be handy for debugging. Do note
163-
that installing rustworkx this way will be significantly slower then using
164-
`pip install` and should only be used for debugging/development.
160+
while working on a change you can set `SETUPTOOLS_RUST_CARGO_PROFILE="dev"`
161+
as an environment variable to build and install rustworkx in develop mode.
162+
This will build rustworkx without optimizations and include debuginfo
163+
when running `pip install`. That can be handy for debugging.
165164

166165
> [!TIP]
167166
> It's worth noting that `pip install -e` does not work, as it will link the python
168-
packaging shim to your python environment but not build the rustworkx binary. If
169-
you want to build rustworkx in debug mode you have to use
170-
`python setup.py develop`.
167+
packaging shim to your python environment but not build the rustworkx binary.
171168

172169
## Project history
173170

docs/source/api/pydigraph_api_functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ API functions for PyDigraph
55

66
These functions are algorithm functions that are type specific for
77
:class:`~rustworkx.PyDiGraph` or :class:`~rustworkx.PyDAG` objects. Universal
8-
functions from Retworkx API that work for both graph types internally call
8+
functions from Rustworkx API that work for both graph types internally call
99
the functions from the explicitly typed based on the data type.
1010

1111
.. autosummary::

noxfile.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,12 @@
33
nox.options.reuse_existing_virtualenvs = True
44
nox.options.stop_on_first_error = True
55

6-
deps = [
7-
"setuptools-rust",
8-
"fixtures",
9-
"testtools>=2.5.0",
10-
"networkx>=2.5",
11-
"stestr>=4.1",
12-
]
6+
pyproject = nox.project.load_toml("pyproject.toml")
137

14-
lint_deps = [
15-
"black~=24.8",
16-
"ruff~=0.6",
17-
"setuptools-rust",
18-
"typos~=1.28",
19-
]
20-
21-
stubs_deps = [
22-
"mypy==1.11.2",
23-
"typing-extensions>=4.4",
24-
]
8+
deps = nox.project.dependency_groups(pyproject, "test")
9+
lint_deps = nox.project.dependency_groups(pyproject, "lint")
10+
stubs_deps = nox.project.dependency_groups(pyproject, "stubs")
11+
docs_deps = nox.project.dependency_groups(pyproject, "docs")
2512

2613
def install_rustworkx(session):
2714
session.install(*deps)
@@ -55,7 +42,7 @@ def lint(session):
5542
@nox.session(python=["3"])
5643
def docs(session):
5744
install_rustworkx(session)
58-
session.install("-r", "docs/source/requirements.txt", "-c", "constraints.txt")
45+
session.install(*docs_deps, "-c", "constraints.txt")
5946
session.run("python", "-m", "ipykernel", "install", "--user")
6047
session.run("jupyter", "kernelspec", "list")
6148
session.chdir("docs")

pyproject.toml

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,110 @@
1+
[project]
2+
name = "rustworkx"
3+
version = "0.17.0"
4+
description = "A High-Performance Graph Library for Python"
5+
requires-python = ">=3.9"
6+
dependencies = [
7+
"numpy>=1.16.0,<3"
8+
]
9+
readme = {file = "README.md", content-type = "text/markdown"}
10+
license-files = ["LICENSE"]
11+
license = "Apache-2.0"
12+
classifiers=[
13+
"Intended Audience :: Developers",
14+
"Intended Audience :: Science/Research",
15+
"Programming Language :: Rust",
16+
"Programming Language :: Python :: 3 :: Only",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"Programming Language :: Python :: 3.13",
22+
"Operating System :: MacOS :: MacOS X",
23+
"Operating System :: Microsoft :: Windows",
24+
"Operating System :: POSIX :: Linux",
25+
"Development Status :: 5 - Production/Stable",
26+
]
27+
keywords = ["Networks", "network", "graph", "Graph Theory", "DAG"]
28+
29+
[tool.setuptools]
30+
packages = ["rustworkx", "rustworkx.visualization"]
31+
include-package-data = true
32+
33+
[tool.distutils.bdist_wheel]
34+
py-limited-api = "cp39"
35+
36+
[[tool.setuptools-rust.ext-modules]]
37+
target = "rustworkx.rustworkx"
38+
path = "Cargo.toml"
39+
binding = "PyO3"
40+
41+
[project.optional-dependencies]
42+
mpl = ["matplotlib>=3.0"]
43+
graphviz = ["pillow>=5.4"]
44+
# TODO: use self-referential rustworkx[mpl] and rustworkx[graphivz]
45+
# once it is better suported.
46+
all = [
47+
"matplotlib>=3.0",
48+
"pillow>=5.4",
49+
]
50+
51+
[project.urls]
52+
issues = "https://github.com/Qiskit/rustworkx/issues"
53+
source = "https://github.com/Qiskit/rustworkx"
54+
documentation ="https://www.rustworkx.org/"
55+
releasenotes = "https://www.rustworkx.org/release_notes.html"
56+
57+
[[project.authors]]
58+
name = "Matthew Treinish"
59+
email = "mtreinish@kortar.org"
60+
61+
[[project.maintainers]]
62+
name = "Ivan Carvalho"
63+
email = "ivancarvalho@gatech.edu"
64+
165
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools-rust"]
66+
requires = ["setuptools>=70.1.0", "setuptools-rust>=1.9"]
367
build-backend = "setuptools.build_meta"
468

69+
[dependency-groups]
70+
test = [
71+
"setuptools-rust",
72+
"fixtures",
73+
"testtools>=2.5.0",
74+
"networkx>=2.5",
75+
"stestr>=4.1",
76+
]
77+
lint = [
78+
"black~=24.8",
79+
"ruff~=0.6",
80+
"setuptools-rust",
81+
"typos~=1.28",
82+
]
83+
stubs = [
84+
"mypy==1.11.2",
85+
"typing-extensions>=4.4",
86+
]
87+
docs = [
88+
"m2r2",
89+
"sphinx>=5.0",
90+
"jupyter-sphinx",
91+
"pydot",
92+
"pillow>=4.2.1",
93+
"reno>=3.4.0",
94+
"qiskit-sphinx-theme~=1.14.0rc1",
95+
"matplotlib>=3.4",
96+
"sphinx-reredirects",
97+
"sphinxemoji",
98+
"ipykernel",
99+
]
100+
5101
[tool.black]
6102
line-length = 100
7103
target-version = ['py39', 'py310', 'py311', 'py312']
8104

9105
[tool.ruff]
10106
line-length = 105 # more lenient than black due to long function signatures
11-
src = ["rustworkx", "setup.py", "retworkx", "tests"]
107+
src = ["rustworkx", "setup.py", "tests"]
12108
lint.select = [
13109
"E", # pycodestyle
14110
"F", # pyflakes

releasenotes/notes/0.11/prepare-0.11-af688e532712c830.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ features:
7070
7171
fixes:
7272
- |
73-
Fixed an issue with the :func:`~retworkx.generators.heavy_hex_graph`,
74-
:func:`~retworkx.generators.directed_heavy_hex_graph`,
75-
:func:`~retworkx.generators.heavy_square_graph`,
76-
and :func:`~retworkx.generators.directed_heavy_square_graph` generator
73+
Fixed an issue with the :func:`~rustworkx.generators.heavy_hex_graph`,
74+
:func:`~rustworkx.generators.directed_heavy_hex_graph`,
75+
:func:`~rustworkx.generators.heavy_square_graph`,
76+
and :func:`~rustworkx.generators.directed_heavy_square_graph` generator
7777
functions. When the input parameter ``d`` was set to 1 these functions
7878
would previously raise a ``pyo3_runtime.PanicException`` instead of
7979
returning the expected graph (a single node).
80-
Fixed `#452 <https://github.com/Qiskit/retworkx/issues/452>`__
80+
Fixed `#452 <https://github.com/Qiskit/rustworkx/issues/452>`__

releasenotes/notes/0.12/add-json-dump-func-91c43cb4a3cd6951.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
features:
33
- |
4-
Added a new function, :func:`~.retworkx.node_link_json`, which is used to
4+
Added a new function, :func:`~.rustworkx.node_link_json`, which is used to
55
generate JSON node-link data representation of an input :class:`~.PyGraph`
66
or :class:`~.PyDiGraph` object. For example, running::
77
8-
import retworkx
8+
import rustworkx
99
10-
graph = retworkx.generators.path_graph(weights=['a', 'b', 'c'])
11-
print(retworkx.node_link_json(graph, node_attrs=lambda n: {'label': n}))
10+
graph = rustworkx.generators.path_graph(weights=['a', 'b', 'c'])
11+
print(rustworkx.node_link_json(graph, node_attrs=lambda n: {'label': n}))
1212
1313
will output a JSON payload equivalent (identical except for whitespace) to:
1414

releasenotes/notes/0.13/graph-annotations-1d436930bf60c5c2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
features:
33
- |
44
Added partial type annotations to the library, including for the
5-
:class:`~retworkx.PyDiGraph` and :class:`~retworkx.PyGraph` classes.
5+
:class:`~rustworkx.PyDiGraph` and :class:`~rustworkx.PyGraph` classes.
66
This enables statically type checking with
77
`mypy <http://mypy-lang.org>`__.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
deprecations:
3+
- |
4+
We are saying goodbye to the legacy ``retworkx`` package that operates as a
5+
backwards compatibility alias for ``rustworkx``. It was originally marked as
6+
deprecated in the 0.12.0 release and this will be its last release it is supported. The ``rustworkx`` name has now existed
7+
longer than the ``retworkx`` name and the ``retworkx`` package is no longer needed.
8+
9+
This release will unpin the ``retworkx`` package from the ``rustworkx`` package.
10+
Historically, we have release ``retworkx`` and `rustworkx` at the same time, with
11+
``retworkx`` being an alias to the same ``rustworkx`` package. This will no longer
12+
be the case.
13+
14+
We encourage users to migrate to the new name. Thanks to all users that have
15+
used ``retworkx`` since the early days of the project!
File renamed without changes.
File renamed without changes.

retworkx/setup.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This code is licensed under the Apache License, Version 2.0. You may
2+
# obtain a copy of this license in the LICENSE.txt file in the root directory
3+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
4+
#
5+
# Any modifications or derivative works of this code must retain this
6+
# copyright notice, and modified files need to carry a notice indicating
7+
# that they have been altered from the originals.
8+
from setuptools import setup
9+
10+
11+
import sys
12+
import pathlib
13+
14+
if sys.version_info >= (3, 11):
15+
import tomllib
16+
else:
17+
# setuptools actually depends on this, so we can safely import it
18+
import tomli as tomllib
19+
20+
parent_dir = pathlib.Path(__file__).parent.parent
21+
22+
with open(parent_dir / "README.md") as f:
23+
original_readme = f.read()
24+
with open(parent_dir / "pyproject.toml", "rb") as f:
25+
pyproject = tomllib.load(f)
26+
27+
retworkx_readme_compat = f"""# retworkx
28+
29+
`retworkx` is the **deprecated** package name for `rustworkx`. `retworkx` has been
30+
retired and will no longer receive updates. We recommend using `rustworkx` instead,
31+
it should be a drop-in replacement. Thanks to all users that have used `retworkx`
32+
since the early days of the project!
33+
34+
{original_readme}
35+
"""
36+
37+
setup(
38+
name="retworkx",
39+
version=pyproject["project"]["version"],
40+
description=pyproject["project"]["description"],
41+
long_description=retworkx_readme_compat,
42+
long_description_content_type="text/markdown",
43+
author=pyproject["project"]["authors"][0]["name"],
44+
author_email=pyproject["project"]["authors"][0]["email"],
45+
license=pyproject["project"]["license"],
46+
classifiers=pyproject["project"]["classifiers"],
47+
keywords=pyproject["project"]["keywords"],
48+
project_urls=pyproject["project"]["urls"],
49+
python_requires=pyproject["project"]["requires-python"],
50+
install_requires=["rustworkx"],
51+
extras_require=pyproject["project"]["optional-dependencies"],
52+
)

0 commit comments

Comments
 (0)