-
Notifications
You must be signed in to change notification settings - Fork 9
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
Convert to python module (pyproject.toml) #659
Conversation
bdb2a98
to
8e06110
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
just one thought , i would like to share.
producer.py
Outdated
@@ -46,14 +43,23 @@ | |||
from thoth.python import AIOSource | |||
from thoth.python.exceptions import NotFoundError | |||
|
|||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason the __version__
was kept in the version.py
is as we use kebechet for release, it currently only recognizes these list of files.
https://github.com/thoth-station/kebechet/blob/4c52e72a0ee0b9299b5165d77cc50c33b58f0350/kebechet/managers/version/release_triggers.py#L104
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum.
Relevant:
- Add option to automatically create new release kebechet#1062 (probably)
- [3pt] Move away from setuptools and use pyproject.toml instead core#360
Do you mean kebechet require handling version in those way to handle releases ? Should'nt that be separate ?
(I don't see support for pyproject.toml, setup.cfg / others here. Would that mean that python packages using those can't use kebechet for that purpose ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, correct, there isn't support for these in kebechet
thanks for the issue, let's make kebechet more better. 👍
producer.py
Outdated
try: | ||
__version__ = version(__package__) | ||
except PackageNotFoundError: | ||
__version__ = "v0.11.10" # TODO makes this unnecessary by fixing users of the package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have this default to dev
? I think local development is the most likely cause of version not being found.
producer.py
Outdated
__service_version__ = ( | ||
f"{__version__}+" | ||
+ ".".join(version(f"thoth-{p}") for p in ["storages", "common", "messaging"]) | ||
+ f".python.{__python__version__}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think python should be added to the above list as the python_version
is actually the thoth.python
version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On reviewing,
its seems, i missed earlier that this component is not module.
we don't need the project in pyproject.toml
and can keep the version.py for this component.
as it would be released as container image.
pyproject.toml
Outdated
[project] | ||
name = "package-releases-job" | ||
description = "Check packages updates on Python package indexes" | ||
readme = "README.rst" | ||
requires-python = ">=3.8" | ||
license = {file = "LICENSE"} | ||
dynamic = ["version"] | ||
|
||
[project.scripts] | ||
package-releases-job = "producer:main" | ||
|
||
[build-system] | ||
requires = ["setuptools", "wheel", "setuptools_scm"] | ||
|
||
[tool.setuptools_scm] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not be needed for this component, as this is not released as module, just as a container image on release.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
On Wed, Jan 18, 2023 at 02:26:34PM -0800, Harshad Reddy Nalla wrote:
@harshad16 requested changes on this pull request.
On reviewing,
its seems, i missed earlier that this component is not module.
we don't need the project in pyproject.toml
and can keep the version.py for this component.
as it would be released as container image.
> +[project]
+name = "package-releases-job"
+description = "Check packages updates on Python package indexes"
+readme = "README.rst"
+requires-python = ">=3.8"
+license = {file = "LICENSE"}
+dynamic = ["version"]
+
+[project.scripts]
+package-releases-job = "producer:main"
+
+[build-system]
+requires = ["setuptools", "wheel", "setuptools_scm"]
+
+[tool.setuptools_scm]
This might not be needed for this component, as this is not released as module, just as a container image on release.
I don't disagree ; I still think we could get some benefits from converting to pyproject.toml, mainly standardizing all of thoth repos on a common model so we can treat them the same in the CI.
|
we are using pyproject.toml. |
Actually we can have both if having version defined inside a file is desirable
setuptools support something like this in pyproject.toml
[project]
dynamic = ["version"]
[tool.setuptools.dynamic]
version = {attr: "version.version"}
The main point is to avoid repeating the version twice and then
forgetting to update it twice later on.
Would that work ?
|
yes, we can do this. |
Well, handling them as python modules allows to handle them in a more
general way. For example, using the repo as a pre-commit hook (like
we're currently doing in adviser) rely on it being a python module.
Some of the tooling (mypy in particular) seems to be a bit lost when it
can't identify a module.
Regarding scripts / job specifically, relying on [project.scripts]
instead of manually invoking the python file guarantee we'll have the
correct dependency in scope by just doing a `pip install .` of the repo.
All of the above is my opinion but TL;DR: easier integration with the
Python ecosystem and it's tooling.
|
Thank you for the explanation, i appreciate it. For this PR, can we bring back the version.py and introduce the dynamic version in pyproject.toml |
Do you think we can have the `__version__` directly in `producer.py` ?
Having one single file for that seems a bit strange.
(Or maybe that's related to kebechet ?)
|
Use [project.script] instead of invoking python.
8e06110
to
b554c37
Compare
yeah that is related to kebechet |
possible followup to #658