-
Notifications
You must be signed in to change notification settings - Fork 107
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
Switch from setup.cfg + setup.py to pyproject.toml only #708
Conversation
ci(precommit): add codespell to precommit config
Erase setup.py and setup.cfg
Hey @baggiponte, thanks for this PR! I have no opinion on whether we should use ruff or not, despite its popularity. However, for the sake of passing the CI, you might want to fix the ruff errors, since many flake8 ignored rules are not mirrored. See the error in the CI. Using pyproject.toml with setuptools as its backend, it's good to mention that we can still generate bdist_wheel and sdist using either wheel: pip wheel . --no-deps -w my_dist or build (might need to be pip install): python -m build What do the other maintainers think? cc @GaelVaroquaux who might be interested in this. |
Hi Vincent! Thank you for your review. I would have gotten it done this weekend but I was busy. I shall get back to it tomorrow and fix it asap 💪🏼 |
Don't worry, there's no rush :) |
Hey @baggiponte, do you need help on this? :) |
One thing worth considering is that when using setuptools, to include package data (non-python files that need to be shipped with the code) ATM with setuptools if we don't use setup.py, according to the documentation the 2 options are (i) list the data files in a MANIFEST.in (a bit tedious and there is the risk of forgetting some) or (ii) use the setuptools-scm plugin to include files that are tracked by git. |
Ciao @Vincent-Maladiere, sorry if it took me so long to get back to this.
UPDATE 1 CircleCI fails because it expects setup.py to be there:
I shall check the build_docs.sh script next! UPDATE 2 Now this error is raised in CircleCI. My understanding is that is due to something else with sphinx, but I can't really figure out why. Does it normally work? Do you understand what might be going on? Error is here.
|
The project was already installed with `pip install .[doc]`
Ciao @baggiponte! @jeromedockes raises a crucial point regarding package data (non-python files) and setup.py. We need to address this point before moving forward with pyproject.toml! Switching packaging tools can take time since there are a lot of things to consider. In the meantime, feel free to tackle another issue :) |
There is a nice cookie-cutter based on |
Ciao @Vincent-Maladiere, thanks for the review. I saw @jeromedockes comment indeed, but did not talk about it as I wanted to wait for your reply before opening a new thread. This makes a lot of sense. IIUC, there's only one non-Python file to include, which is Currently, I don't mean to push my idea, just trying to write out all possible alternatives. Up to you to decide the road to take :) I'll gladly look at the other issues. |
Hi, yes ATM there is only the VERSION.txt; a few more are likely to appear at
some point (eg tiny example datasets).
Such files are perfectly manageable without a setup.py; I just meant at
some point we may need to choose between using a MANIFEST.in, using
setuptools-scm, or using a different build backend than setuptools (all
of which are easy to do).
It is probably better to keep the version in a txt file rather than a
Python module because it is needed in the package metadata during the
build & installation of skrub, when skrub cannot yet be imported.
It's not a problem because in practice setuptools copies it to the build
directory. And we could always add a small MANIFEST.in for now just to
be safe.
|
Hi @baggiponte, after discussing with other skrub members, we think it's a good idea to go forward with the pyproject.toml! We're fine with ruff and having a small MANIFEST.in :) |
Great! Do let me know how can I be of help to finish implementing this. I guess I should:
Something I forgot? |
Finish the migration from flake8 to ruff, or is it done already? |
Let me double check but I recall it was done. |
As discussed today during the sprint, here is the PR to move to using pyproject.toml only. This can be done with ease because you do not need to compile any C-extension or anything. You can try out installing
skrub
configured withpyproject.toml
only by running the following command in a fresh new env:pip install -e "git+https://github.com/baggiponte/skrub@switch-to-pyproject#egg=skrub[dev]"
(if you use
@...
you can tell git to install from any commit/tag/branch; the#egg=skrub
tells pip where the package is so that it can build the wheel; the[dev]
at the end installs the package and dev dependencies. this will raise a deprecation warning: do not worry, it's just because you are installing from a branch in my fork, because I did not want to push the changes that I made to main)The fact that the package is installed means that wheels can be built, i.e. the package can be published and distributed.
I simply ported everything inside setup.cfg following the official pyproject specification here as well as how to configure setuptools with pyproject.
I changed flake8 to ruff because flake8 cannot be configured with pyproject; ruff is a drop in replacement written in rust, very fast, extremely widely adopted (pandas, scipy, apache airflow, and many many more all use it). If you don't like the new tool, we can just leave the flake8 section in setup.cfg or in a .flake8 file.
I also edited the precommit config accordingly. I realised that while you configured codespell, it was not running in precommit, so I added that too. precommit runs fine; please do tell me of other ways to test whether something is broken! 😃