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

Convert to python module (pyproject.toml) #659

Closed
wants to merge 2 commits into from

Conversation

VannTen
Copy link
Member

@VannTen VannTen commented Sep 19, 2022

possible followup to #658

@sesheta sesheta added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 19, 2022
Copy link
Member

@harshad16 harshad16 left a 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:
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Hum.
Relevant:

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 ?)

Copy link
Member

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
Copy link
Member

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__}"
Copy link
Member

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.

Copy link
Member

@harshad16 harshad16 left a 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
Comment on lines 1 to 15
[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]
Copy link
Member

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.

@sesheta
Copy link
Member

sesheta commented Jan 18, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign harshad16 for approval by writing /assign @harshad16 in a comment. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@VannTen
Copy link
Member Author

VannTen commented Jan 20, 2023 via email

@harshad16
Copy link
Member

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.
is there a PEP standard for having a version on pyproject.toml, it seems project which use poetry use that?
as this project is just a component, it feel version.py file is more easy and convenient.
WDYT ?

@VannTen
Copy link
Member Author

VannTen commented Jan 20, 2023 via email

@harshad16
Copy link
Member

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.
side question: what is the reason to have version in pyproject.toml in projects which are not python modules ?

@VannTen
Copy link
Member Author

VannTen commented Jan 20, 2023 via email

@harshad16
Copy link
Member

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

@VannTen
Copy link
Member Author

VannTen commented Jan 20, 2023 via email

Use [project.script] instead of invoking python.
@sesheta sesheta added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 20, 2023
@VannTen VannTen changed the title Dynamic versionning (git tags) Convert to python module (pyproject.toml) Jan 20, 2023
@harshad16
Copy link
Member

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 ?)

yeah that is related to kebechet
maybe can plan this future

@VannTen VannTen closed this Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants