Skip to content

Commit

Permalink
Switch from setup.py to pyproject.toml (#573)
Browse files Browse the repository at this point in the history
* add toml

* Add .rst readme

* fix format

* undo readme changes

* remove setup.py from manifest

* try to fix rtd build

* try again

* Update .readthedocs.yaml

* Update .readthedocs.yaml

* fix

* fix optional dependency

* fix refs to `DiIDView`

* add metadata

* change find where

* Update pyproject.toml

* updated requirements

* updated README and pyproject.toml

* clean up install

* Update coverage.yml

* try fixing install

* Update coverage.yml

* attempt to fix tests

* try something else

* response to review

* update publishing commands

* clean up some dependencies

* removed unnecessary attribution

* reduce number of requests to zenodo

* format

* update tests

* fix tests

* try to be consistent
  • Loading branch information
nwlandry authored Aug 28, 2024
1 parent 3252b7f commit 9492352
Show file tree
Hide file tree
Showing 27 changed files with 278 additions and 232 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ jobs:
runs-on: ubuntu-latest
name: Test coverage
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install packages
run: |
python -m pip install --upgrade pip wheel setuptools
pip install -r requirements/default.txt -r requirements/test.txt
pip install .
python -m pip list
pip install --upgrade pip
pip install .[test]
pip list
- name: Run tests and collect coverage
run: |
cd tests/
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/publish_xgi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools
pip install --upgrade pip
pip install -U build twine
- name: Build package
run: |
python setup.py sdist
python -m build
- name: Verify the distribution
run: twine check --strict dist/*

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,18 @@ jobs:
os: [ubuntu, macos, windows]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install packages
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install -r requirements/default.txt -r requirements/test.txt -r requirements/documentation.txt
python -m pip install .
python -m pip list
pip install --upgrade pip
pip install .[test,docs]
pip list
- name: Test XGI
run: |
Expand Down
4 changes: 1 addition & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ python:
- method: pip
path: .
extra_requirements:
- documentation
- method: setuptools
path: .
- docs

formats:
- pdf
Expand Down
8 changes: 2 additions & 6 deletions HOW_TO_CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ Please note we have a [code of conduct](/CODE_OF_CONDUCT.md), please follow it i
3. Increase the version number in [\_\_init\_\_.py](xgi/__init__.py.py) and [conf.py](docs/source/conf.py) to the new version agreed upon by the core developers. The versioning scheme we use is [SemVer](http://semver.org/).
4. Commit these changes.
5. Create a new release on GitHub by selecting "Releases", then clicking "Draft a new release". Click "Choose a tag" and type "v" followed by the version number and then click "Create new tag". The release title will be this same string. Paste the contents of the CHANGELOG into the "Describe this release" field. Click "Publish release".
6. Run `python setup.py sdist` from the main folder. This will create a zipped file to upload to PyPI and save it to the "dist" folder.
6. Run `python -m build` from the main folder. This will create a zipped file to upload to PyPI and save it to the "dist" folder.
6. Using `twine` (a dependency in the [release](requirements/release.txt) requirements file), run `twine upload dist/xgi-[version number].tar.gz`. Enter your username and password.
4. The new version is now on PyPI.

## Attribution

This Contributing Statement is adapted from [this template by @PurpleBooth](https://gist.github.com/PurpleBooth/b24679402957c63ec426).
4. The new version is now on PyPI.
6 changes: 1 addition & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
include MANIFEST.in
include setup.py
include HOW_TO_CONTRIBUTE.md
include long_description.rst
include pyproject.toml
include README.md
include LICENSE.md
include CITATION.cff
include CODE_OF_CONDUCT.md
include pytest.ini

recursive-include logo *.pdf *.png *.svg
recursive-include requirements *.txt *.md
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ pip install -e .["all"]
```
* If that command does not work, you may try the following instead
````zsh
pip install -e .\[all\]
pip install -e ."[all]"
````
For more installation options, see the [guide](https://github.com/xgi-org/xgi/blob/main/requirements/README.md).


## Getting Started
Expand Down Expand Up @@ -131,4 +132,4 @@ This library may not meet your needs and if this is this case, consider checking


**R**
* [hyperG](https://cran.r-project.org/package=HyperG): An R package for storing and analyzing hypergraphs
* [hyperG](https://cran.r-project.org/package=HyperG): An R package for storing and analyzing hypergraphs
4 changes: 2 additions & 2 deletions docs/source/api/core/xgi.core.views.DiEdgeView.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ xgi.core.views.DiEdgeView
~DiEdgeView.dimembers
~DiEdgeView.head
~DiEdgeView.tail
~DiIDView.filterby
~DiIDView.filterby_attr
~IDView.filterby
~IDView.filterby_attr
4 changes: 2 additions & 2 deletions docs/source/api/core/xgi.core.views.DiNodeView.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ xgi.core.views.DiNodeView

~DiNodeView.memberships
~DiNodeView.dimemberships
~DiIDView.filterby
~DiIDView.filterby_attr
~IDView.filterby
~IDView.filterby_attr
~DiNodeView.isolates
74 changes: 0 additions & 74 deletions long_description.rst

This file was deleted.

105 changes: 105 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61.2", "wheel"]

[project]
name = "xgi"
dynamic = ["version"]
description = "XGI is a Python package for higher-order networks."
readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE.md"}
authors = [
{name = "XGI Developers", email = "[email protected]"}
]
maintainers = [
{name = "XGI Developers", email = "[email protected]"}
]
keywords = [
"networks",
"higher-order",
"higher-order network",
"hypergraph",
"simplicial complex",
"network science",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = [
"numpy>=1.20",
"scipy>=1.8",
"pandas>=1.3",
"networkx>=2.7",
"requests>=2.0",
"matplotlib>=3.4",
"seaborn>=0.10",
]

[project.urls]
Documentation = "https://xgi.readthedocs.io/en/stable/"
"Bug Reports" = "https://github.com/xgi-org/xgi/issues"
Source = "https://github.com/xgi-org/xgi"
PyPI = "https://pypi.org/project/xgi/"
"GitHub Discussions" = "https://github.com/xgi-org/xgi/discussions"

[project.optional-dependencies]
benchmark = [
"hypernetx>=1.0",
"asv>=0.5",
]
developer = [
"black[jupyter]>=24.3",
"isort==5.10.1",
"pylint>=3.0",
"nbqa",
]
docs = [
"sphinx~=6.0",
"sphinx_copybutton",
"sphinx-rtd-theme>=1.2",
"numpydoc>=1.1",
"pillow>=8.2",
"matplotlib>=3.3",
"sphinx-design",
"ipykernel",
"nbsphinx",
"nbsphinx-link",
]
release = [
"twine>=3.4",
"build>=1.2.1",
"wheel>=0.36",
"github-changelog",
]
test = [
"pytest>=7.2",
"pytest-cov>=4.0",
]
tutorial = [
"jupyter>=1.0",
"ipython<=8.12.0",
]
all = ["xgi[benchmark,developer,docs,release,test,tutorial]"]

[tool.setuptools.packages.find]
where = ["."]

[tool.setuptools.dynamic.version]
attr = "xgi.__version__"
37 changes: 26 additions & 11 deletions requirements/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
# pip requirements files
# Installation instructions

## Index
## pip installing with options

You may wish to selectively install dependencies required for testing, developing, or building certain parts of the project.
These options are the following:

- `benchmark`: Requirements needed to run the benchmarking notebooks
- `tutorial`: Requirements needed to run the Jupyter Notebooks with the examples
- `test`: Requirements needed to run the test suite
- `docs`: Requirements needed to build the documentation (see the [docs](https://github.com/xgi-org/xgi/tree/main/docs))
- `developer`: Requirements needed to format the codebase
- `release`: Requirements needed to release new versions of XGI

```sh
pip install xgi[option]
pip install xgi[option1,option2]
```

## pip installing dependencies (without installing XGI)

You may wish to install the dependencies without actually installing XGI itself. The following are the requirements files to do that:

- `benchmark.txt`: Requirements to run the benchmarking notebooks
- `default.txt`: Default requirements
- `tutorial.txt`: Requirements for running the Jupyter Notebooks with the examples
- `test.txt`: Requirements for running test suite
- `documentation.txt`: Requirements for building the documentation (see `../docs/`)
- `docs.txt`: Requirements for building the documentation (see `../docs/`)
- `developer.txt`: Requirements for developers
- `release.txt`: Requirements for making releases

## Examples

### Installing requirements

To install these dependencies, simply run
```bash
$ pip install -U -r requirements/default.txt
$ pip install -U -r requirements/{filename}
```

### Running the tests

where the filename is one of the ones listed above. For example, to install the requirements necessary to run the test suite, run
```bash
$ pip install -U -r requirements/default.txt
$ pip install -U -r requirements/test.txt
Expand Down
4 changes: 4 additions & 0 deletions requirements/benchmark.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated via tools/generate_requirements.py and pre-commit hook.
# Do not edit this file; modify pyproject.toml instead.
hypernetx>=1.0
asv>=0.5
2 changes: 0 additions & 2 deletions requirements/benchmarks.txt

This file was deleted.

Loading

0 comments on commit 9492352

Please sign in to comment.