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

Implement packaging using pyproject.toml #476

Merged
merged 34 commits into from
May 19, 2024

Conversation

abhi8893
Copy link
Contributor

@abhi8893 abhi8893 commented May 3, 2024

Description

scikit-surprise currently relies on the legacy setup.py to describe the python package build. While this is needed for including cythonized extensions, most of the config can be moved to pyproject.toml.

This would probably solve open installation issues: #466, #468, #470 etc

This PR does the following:

  1. add build to dev requirements
  2. remove setup.cfg
  3. document version directly in surprise.__init__.py
  4. create minimal required setup.py, and transfer most conf to pyproject.toml
  5. create sdist using build, test on sdist with [test] requirements installed

Merging this will gave back the community a really good recommender system library! 🙂

@pshelby
Copy link

pshelby commented May 7, 2024

@NicolasHug I'm currently having trouble installing Surprise with Poetry. This would be a great improvement! Thanks @abhi8893 !

@bhatiaakshay8
Copy link

bhatiaakshay8 commented May 8, 2024

@NicolasHug This solved the problem for me! Please merge and make a new release.

thanks @abhi8893

@rodrigc
Copy link

rodrigc commented May 8, 2024

I didn't realize @abhi8893 came up with this, and implemented something very similar in #477.
However, this PR is slightly better, so I closed #477 in favor of this.

I only have some minor suggestions for this PR, please consider incorporating.

pyproject.toml Outdated
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
]
license = { "text" = "GPLv3+" }
Copy link

@rodrigc rodrigc May 8, 2024

Choose a reason for hiding this comment

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

Suggested change
license = { "text" = "GPLv3+" }
license = { "file" = "LICENSE.md" }

Copy link

Choose a reason for hiding this comment

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

The license is not GPLv3+, so just point it to the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

@@ -1,5 +1,3 @@
from pkg_resources import get_distribution
Copy link

Choose a reason for hiding this comment

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

Suggested change
from pkg_resources import get_distribution
from pkg_resources import get_distribution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See discussion here in this PR: #476 (comment)

@@ -1,5 +1,3 @@
from pkg_resources import get_distribution

Copy link

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See discussion here in this PR: #476 (comment)

@@ -47,4 +45,4 @@
"model_selection",
]

__version__ = get_distribution("scikit-surprise").version
Copy link

Choose a reason for hiding this comment

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

Suggested change
__version__ = get_distribution("scikit-surprise").version
__version__ = get_distribution("scikit-surprise").version

Copy link

Choose a reason for hiding this comment

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

Add back get_distribution(). I don't think you want to hardcode the version number here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, there are 2 considerations:

  1. If we rely on pkg_resources (which comes from setuptools) inside surprise, then it becomes a direct dependency of surprise. Depending on the python distribution, setuptools may or may not be bundled with python. Hence to avoid this, I declare version directly in surprise.__init__.py
  2. Most popular packages, like scikit-learn follow the same style: https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/__init__.py

Let me know if this makes sense 🙂

Copy link

Choose a reason for hiding this comment

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

OK, thanks for the explanation. That makes sense. 👍
In that case, I would recommend changing the docstring in setup.py
in the section Change __version__ to reflect that the version is now in __init__.py.

This is a valid change, because in pyproject.toml you specified that version is dynamic.

@rodrigc
Copy link

rodrigc commented May 8, 2024

You can delete requirements.txt and requirements_dev.txt since you copied those dependencies into pyproject.toml

setup.py Show resolved Hide resolved
@abhi8893
Copy link
Contributor Author

abhi8893 commented May 9, 2024

Thanks @rodrigc for reviewing! I have incorporated the comments. On the versioning part, I have a differing view, but let me know what you think 🙂

@dhpancor
Copy link

Good job on this PR.
@NicolasHug please merge and make a new release.

@NicolasHug
Copy link
Owner

@abhi8893 thank you so much for putting out this PR
@rodrigc thank you so much as well for your previous PR and for reviewing this one.

I've pushed a bunch of minor changes but I think it's good to merge now. I'll try to push 1.1.4 soon.
🙏

@NicolasHug NicolasHug merged commit 79bcd39 into NicolasHug:master May 19, 2024
9 checks passed
@abhi8893
Copy link
Contributor Author

Thanks a lot for merging this and making a new release so quickly @NicolasHug! Confirming it installs flawlessly now, even with uv ! 🚀

@rodrigc
Copy link

rodrigc commented May 19, 2024

Nice job @abhi8893 and @NicolasHug !

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

6 participants