Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pyproject.toml🆕 #23

Merged
merged 9 commits into from
Feb 6, 2024
Merged

Add support for pyproject.toml🆕 #23

merged 9 commits into from
Feb 6, 2024

Conversation

KarelZe
Copy link
Contributor

@KarelZe KarelZe commented Nov 20, 2023

This PR adds support for a pyproject.toml-based project setup, which is recommended over setup.py, as stated here. Sister projects like shap have adopted a similar setup.

In the future, it will allow us to configure the project as well as tools such as linters, formatters, type checkers etc in a single file.

Changes:

  • update required python version to supported versions
  • add dependency groups [notebook] for dependencies used in notebooks and [dev] for development-related dependencies
  • add pre-commit hooks with basic checks such as a valid toml
  • add github action to create a build for different versions

@iancovert Could you please review?

PS: Are you open to a PR for a linter/formatter e.g., ruff?

@iancovert
Copy link
Owner

Thanks for suggesting this! I've been meaning to read about the different options for building the package, I've noticed that many others use this approach. I need a little time to look into this more - from your changes it looks like you know what you're doing here, but I should probably understand a bit better before merging it in.

@KarelZe
Copy link
Contributor Author

KarelZe commented Dec 8, 2023

Thanks for your feedback.😊 Regarding building: Currently, the github action is just trying to build the package using the information form pyproject.toml, but not preserving the build artifacts. Regarding building and publishing on (test) pypi, I could alter/extend the GitHub action, so that whenever you create a release on GitHub (other triggers possible), a new release is published on (test) pypi. Also, I'll preserve the build artifacts. The process is well explained here: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ I'll update my pr to make the idea more clear👍

@KarelZe
Copy link
Contributor Author

KarelZe commented Jan 6, 2024

@iancovert I extended the PR, so that it supports automatic releases to pypi and test-pypi.

The workflow is based on this python guide: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/. Whenever you push to GitHub a release on test-pypi is created/updated for testing. For tagged commits (git tag 0.0.6 + git push --tag) a new GitHub release is created + a release on pypi. You may want to bump the version number in pyproject.toml before making a new release.

⚠️ In order for this to work, you need to set up trusted publishing (see previous guide) + create an account/project at test.pypi.org.

More over, I added a configuration for the dependabot to keep actions up-to-date.

@KarelZe
Copy link
Contributor Author

KarelZe commented Feb 4, 2024

@iancovert Did you have the chance to look into this yet?

@iancovert
Copy link
Owner

@KarelZe apologies for the delay, I was busy with a deadline that finally passed last week. Thanks again for putting this PR together, I think these are important improvements for the package. Separately, this was a good forcing function for me to learn about these things, and I spent most of today learning about pyproject.toml files, setting up pre-commit hooks, and using GitHub Actions to automatically publish to PyPI.

I've wrapped my head around most of the changes you introduced here. The one exception is the workflow files, but I imagine some of this is boilerplate you found in a tutorial or in similar packages? I'm comfortable merging this and seeing if the publishing action works properly, so I'll go ahead and do that.

@iancovert iancovert merged commit 13c609a into iancovert:master Feb 6, 2024
@KarelZe
Copy link
Contributor Author

KarelZe commented Feb 10, 2024

No worries.🤓 I'm very happy, that you found the changes useful and that everything went smoothly with the release.

The workflow file is an adaption of https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python (test if builds are possible for various python versions) and https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ (create gh release + deploy to pypi), but tailored to the repo. Dependabot is useful to keep gh actions, dependencies, etc. up-to-date.

I might put together a small PR in the next days for a linter / formatter configuration in the pyproject.toml / .pre-commit-config, if you like.

@iancovert
Copy link
Owner

Yes everything is working great with the new changes, thanks again for all your help.

And re: linting/formatting that would be great, I'd like to see how you set this up! I saw the ruff pre-commit hook in this repo of yours so maybe that's all it takes, but I'm curious to see.

@KarelZe
Copy link
Contributor Author

KarelZe commented Feb 11, 2024

@iancovert I prepared a PR for formatting/linting (#26) this morning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants