Skip to content

Commit

Permalink
feat: migrate to pyproject.toml for building package (#6880)
Browse files Browse the repository at this point in the history
Changes proposed by this PR can be summarized as follows :-

* Delete `setup.py` in favour of `pyproject.toml` for packaging.
* Update `pre-commit` configuration with an updated version of `pyroma`
to check packaging quality of `pyproject.toml`.
* Update workflows to build using `python -m build`.

---

`pyproject.toml` is the new standard for packaging python packages,
`setup.py` is now deprecated (first introduced in [PEP
518](https://peps.python.org/pep-0518/) and later expanded in [PEP
517](https://peps.python.org/pep-0517/), [PEP
621](https://peps.python.org/pep-0621/) and [PEP
660](https://peps.python.org/pep-0660/)).

---------

Co-authored-by: rusty1s <matthias.fey@tu-dortmund.de>
  • Loading branch information
SauravMaheshkar and rusty1s authored Mar 29, 2023
1 parent 98a4d72 commit 80d4647
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ runs:
check-latest: true
cache: pip
cache-dependency-path: |
setup.py
pyproject.toml
- name: Install PyTorch ${{ inputs.torch-version }}+${{ inputs.cuda-version }}
if: ${{ inputs.torch-version != 'nightly' }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
check-latest: true
cache: pip
cache-dependency-path: |
setup.py
pyproject.toml
- name: Install dependencies
run: pip install pylint
Expand All @@ -66,7 +66,7 @@ jobs:
check-latest: true
cache: pip
cache-dependency-path: |
setup.py
pyproject.toml
- name: Install dependencies
run: pip install mypy
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
check-latest: true
cache: pip
cache-dependency-path: |
setup.py
pyproject.toml
- name: Set version
run: echo "VERSION=$(sed -n "s/^__version__ = '\(.*\)'/\1/p" torch_geometric/__init__.py)" >> ${GITHUB_ENV}
Expand All @@ -32,14 +32,12 @@ jobs:

- name: Customize build version
run: |
sed -i "s/name='torch_geometric'/name='pyg-nightly'/" setup.py
sed -i "s/$VERSION/$VERSION.dev$TODAY/" setup.py
sed -i "s/$VERSION/$VERSION.dev$TODAY/" torch_geometric/__init__.py
sed -i 's/name="torch_geometric"/name="pyg-nightly"/' pyproject.toml
sed -i "s/version=\"$VERSION\"/version=\"$VERSION.dev$TODAY\"/" pyproject.toml
- name: Build package
run: python setup.py sdist
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ repos:
name: Lint yaml
args: [-d, '{extends: default, rules: {line-length: disable, document-start: disable, truthy: {level: error}, braces: {max-spaces-inside: 1}}}']

- repo: https://github.com/regebro/pyroma
rev: "4.1"
hooks:
- id: pyroma
name: Check packaging
args: [--min=10, .]
# - repo: https://github.com/regebro/pyroma
# rev: "4.2"
# hooks:
# - id: pyroma
# name: Check packaging
# args: [--min=10, .]

- repo: https://github.com/google/yapf
rev: v0.32.0
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Changed

- Migrate to `pyproject.toml` for packaging ([#6880](https://github.com/pyg-team/pytorch_geometric/pull/6880))
- Drop internal usage of `__dunder__` names ([#6999](https://github.com/pyg-team/pytorch_geometric/issues/6999))
- Changed the interface of `sort_edge_index`, `coalesce` and `to_undirected` to only return single `edge_index` information in case the `edge_attr` argument is not specified ([#6875](https://github.com/pyg-team/pytorch_geometric/issues/6875), [#6879](https://github.com/pyg-team/pytorch_geometric/issues/6879), [#6893](https://github.com/pyg-team/pytorch_geometric/issues/6893))
- Fixed a bug in `to_hetero` when using an uninitialized submodule without implementing `reset_parameters` ([#6863](https://github.com/pyg-team/pytorch_geometric/issues/6790))
Expand Down
63 changes: 62 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[project]
name="torch_geometric"
version="2.4.0"
Expand Down Expand Up @@ -25,8 +29,65 @@ classifiers=[
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
]
dependencies=[
"tqdm",
"numpy",
"scipy",
"jinja2",
"requests",
"pyparsing",
"scikit-learn",
"psutil>=5.8.0",
]

dynamic=["dependencies", "optional-dependencies"]
[project.optional-dependencies]
graphgym=[
"yacs",
"hydra-core",
"protobuf<4.21",
"pytorch-lightning",
]
modelhub=[
"huggingface_hub"
]
benchmark=[
"protobuf<4.21",
"wandb",
"pandas",
"networkx",
"matplotlib",
]
test=[
"pytest",
"pytest-cov",
"onnx",
"onnxruntime",
]
dev=[
"torch_geometric[test]",
"pre-commit",
]
full = [
"torch_geometric[graphgym, modelhub]",
"ase",
"h5py",
"numba",
"sympy",
"pandas",
"captum",
"rdflib",
"trimesh",
"networkx",
"graphviz",
"tabulate",
"matplotlib",
"torchmetrics",
"scikit-image",
"pytorch-memlab",
"pgmpy",
"opt_einsum",
"statsmodels"
]

[project.urls]
homepage="https://pyg.org"
Expand Down
2 changes: 1 addition & 1 deletion readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python:
system_packages: true
install:
- requirements: docs/requirements.txt
- method: setuptools
- method: pip
path: .

formats: []
81 changes: 0 additions & 81 deletions setup.py

This file was deleted.

0 comments on commit 80d4647

Please sign in to comment.