Skip to content

replace setup.py with pyproject.toml workflow - #941

Merged
janfb merged 2 commits into
mainfrom
add-pyproject-toml
Feb 16, 2024
Merged

janfb merged 2 commits into
mainfrom
add-pyproject-toml

Conversation

@janfb

@janfb janfb commented Feb 14, 2024 •

Copy link
Copy Markdown
Contributor

This PR

  • replaces setup.py etc with pyproject.toml.
  • removes VSCode settings from the repository.

The pyproject.toml specifies

  • the built backend (setuptools>65 to allow for editable installs),
  • all the package meta data for PyPI.
  • It also list the dependencies and the dev-dependencies. If we want we could have them in a separate requirements.txt, but I think it's nice to have it all in one place.
  • configurations for black, isort and flake8, all copied from the previous setup.cfg. We might want to replace those with ruff in a future PR, see Switch to ruff for linting and formatting #934
  • pytest configurations, e.g., markers

Does this close any currently open issues?

Fixes #940
See #940

Any other comments?

Resources:

Uploading to PyPI

Previously, we used the upload command specified in setup.py to build the package with build and upload it to PyPI with twine.
With this PR, we now have to do it manually like this.
In the project root directory:

  • remove old builds: rm -r dist/
  • install latest pip: python -m pip install --upgrade pip
  • install build and twine: pip install build twine
  • python3 -m build
  • twine upload dist/*

These steps should be added to https://github.com/sbi-dev/sbi/wiki/Release-workflow to fix #940
We might want to set up GitHub actions that run the publishing pipeline with every release we make, as described here:
https://carpentries-incubator.github.io/python_packaging/instructor/05-publishing.html#extra-automating-package-publishing-with-github-actions

@janfb janfb added the docs Improvements or additions to documentation label Feb 14, 2024
@janfb janfb added this to the Pre Hackathon 2024 milestone Feb 14, 2024
@janfb janfb self-assigned this Feb 14, 2024
@janfb
janfb force-pushed the add-pyproject-toml branch from f0e1591 to cb84bd7 Compare February 14, 2024 09:00
@codecov

codecov Bot commented Feb 14, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (50a1185) 75.29% compared to head (4852b60) 75.29%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #941   +/-   ##
=======================================
  Coverage   75.29%   75.29%           
=======================================
  Files          80       80           
  Lines        6285     6286    +1     
=======================================
+ Hits         4732     4733    +1     
  Misses       1553     1553           
Flag Coverage Δ
unittests 75.29% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@michaeldeistler michaeldeistler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! What is the reason to remove .vscode?

Comment thread sbi/inference/__init__.py
simulate_for_sbi,
)
from sbi.inference.base import NeuralInference # noqa: F401
from sbi.inference.base import check_if_proposal_has_default_x, infer, simulate_for_sbi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit surprised about the black changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, I do not get these changes when I run black (v24.2.0) locally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised as well, but it seems to be due to isort and because of the comment.

@janfb

janfb commented Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

I removed .vscode because I think we don't need to have it on the root level of the repository. Not everyone is using vscode and local settings might change, or the settings in the current vscode are deprecated and need to be updated.

Therefore, I suggest to remove it from the git index.

But I am open for the discussion. What is the benefit of sharing the vscode settings as part of the SBI package?

@michaeldeistler

michaeldeistler commented Feb 15, 2024 •

Copy link
Copy Markdown
Contributor

I think I am fine with removing the vs code settings. The only advantage I see is that we can automatically define rulers etc here which match our black settings.

@michaeldeistler

Copy link
Copy Markdown
Contributor

Feel free to merge. I think it might be nice if somebody (@manuelgloeckler ?) could test if installation works smoothly on windows.

@janfb

janfb commented Feb 15, 2024 •

Copy link
Copy Markdown
Contributor Author

We can set formatting and linting settings in pyproject.toml for all users (not only vscode).

Yes, absolutely. Before I merge:

  • @manuelgloeckler can you please checkout this branch locally and start the installation from scratch, e.g., trying both pip install . and pip install -e ".[dev]"?

  • I also uploaded to TestPyPI. @michaeldeistler can you test whether installing via
    pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple sbi==0.22.1 works in an empty conda env?

@michaeldeistler

Copy link
Copy Markdown
Contributor

Worked like a charm.

@janfb
janfb force-pushed the add-pyproject-toml branch 2 times, most recently from 0638523 to 9bbc225 Compare February 15, 2024 10:55
@manuelgloeckler

Copy link
Copy Markdown
Contributor

Both pip install . and pip install -e ".[dev]" works on Windows in a clean conda environment. Also pre-commit run --all-files` runs through (sometimes this can cause problems).

@janfb
janfb merged commit f4cebfc into main Feb 16, 2024
@janfb
janfb deleted the add-pyproject-toml branch February 16, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adapt release workflow in wiki to pyproject.toml setup.

3 participants