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

[python] Provide pyproject.toml that supersedes setup.py #172

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

jenisys
Copy link
Contributor

@jenisys jenisys commented Sep 26, 2024

🤔 What's changed?

  • Provide pyproject.toml file that supersedes setup.py file
  • Use setuptools-scm to derive version-info from git-tags (in the future)
  • Remove outdated version info from
    cucumber_tag_expressions/__init__.py, pytest.ini
  • README.rst: Update badges to be displayed in one line on pypi.org.

CLEANUP:

  • REMOVE: setup.py, setup.cfg
  • REMOVE: .bumversion.cfg (superseded-by: setuptools-scm mechanism)

⚡️ What's your motivation?

  • development: Improvements to make the project better for the future

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

@jenisys jenisys requested a review from brasmusson September 26, 2024 22:07
@mpkorstanje mpkorstanje self-requested a review September 26, 2024 22:15

# -- PREPARED:
[tool.setuptools.dynamic]
version = {attr = "cucumber_tag_expressions.__version__"}
Copy link
Contributor

@mpkorstanje mpkorstanje Sep 27, 2024

Choose a reason for hiding this comment

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

We are using polyglot-release to prepare a release and update the version numbers for all different languages It currently only recognizes version in pyproject.toml or setup.py. It will not update the __version__ attribute.

Is there a need to also keep it as an attribute in the source code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my opinion, yes.
It was probably overlooked in the past that the version was there.
You normally use tools like https://pypi.org/project/bumpversion/ or similar to accomplish this in one step.

Event if the version info is removed from Python package,
the pyproject.toml and/or setup.py should/must contain it (for readability). Note that setup.py will be removed in the future when Python2 compatibility of the package is dropped.

EXAMPLE:

SEE ALSO:

TECHNICAL ALTERNATIVE:

Copy link
Contributor

@mpkorstanje mpkorstanje Sep 27, 2024

Choose a reason for hiding this comment

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

Thanks for explaining the different options.

It wasn't overlooked. Rather it wasn't looked at at all. Releases are made with a script. This is necessary because nobody can remember the intricacies of releasing (currently) 13 different languages.

And after this PR there would be three different ways of doing this just for Python.

So for the sake of the sanity of everyone involved in the release there should be exactly one conventional location for every python project in the Cucumber org to keep its version.

Currently the preferred place is directly in pyproject.toml.

I am open to better ways of doing this, but then I'd like to see a set of merge requests apply that change to all repositories at once.

So for now could you remove the __version__ attribute? The other changes look like a general improvement so I think it would be okay to keep them.

Copy link

Choose a reason for hiding this comment

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

I think we should just remove the __version__ attribute from __init__.py.
The recommended way of getting the version of an installed package is to use importlib.metadata.version(package_name): https://docs.python.org/3/library/importlib.metadata.html#distribution-versions

Copy link
Contributor

Choose a reason for hiding this comment

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

@youtux - Can you maybe move to get this as an agreed consensus with other notable python contributors and then make a set of changes across all python implementations.

For ease (And lack of bugs), if you could make the PR's - but not merge them and tag one of myself or @mpkorstanje or @davidjgoss then we could liaise with yourself and others to get them all merged simultaneously whilst updating our polyglot-release repo, then this would be the smallest amount of friction.

Any help / queries, I'm in discord

@mpkorstanje mpkorstanje requested a review from youtux September 27, 2024 09:36
Copy link

@youtux youtux left a comment

Choose a reason for hiding this comment

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

please split this across multiple independent PRs, so that they are easier to review and self-contained changes.

"enum34; python_version < '3.4'",
]
keywords= ["BDD", "testing", "tag-expressions", "cucumber", "behave"]
# source-includes = [
Copy link

Choose a reason for hiding this comment

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

let's remove commented code right?

# "**/*.rst",
# "**/*.txt",
# ]
requires-python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*"
Copy link

Choose a reason for hiding this comment

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

do we still support python 2?

# ]
requires-python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*"
# requires-python = ">=3.7"
license = { text = "MIT"}
Copy link

Choose a reason for hiding this comment

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

this can be just one of the classifiers, no need to be in a license key anymore

Comment on lines 75 to 79
homepage = "https://github.com/cucumber/tag-expressions"
repository = "https://github.com/cucumber/tag-expressions"
download = "https://pypi.org/project/cucumber-tag-expressions"
documentation = "https://cucumber.io/docs/cucumber/api/#tag-expressions"
changelog = "https://github.com/cucumber/tag-expressions/blob/main/CHANGELOG.md"
Copy link

Choose a reason for hiding this comment

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

keys should be capitalised

download = "https://pypi.org/project/cucumber-tag-expressions"
documentation = "https://cucumber.io/docs/cucumber/api/#tag-expressions"
changelog = "https://github.com/cucumber/tag-expressions/blob/main/CHANGELOG.md"
"Issue Tracker" = "https://github.com/cucumber/tag-expressions/issues/"
Copy link

Choose a reason for hiding this comment

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

can call this Issues, that's what the PyPA recommends


# -- PREPARED:
[tool.setuptools.dynamic]
version = {attr = "cucumber_tag_expressions.__version__"}
Copy link

Choose a reason for hiding this comment

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

I think we should just remove the __version__ attribute from __init__.py.
The recommended way of getting the version of an installed package is to use importlib.metadata.version(package_name): https://docs.python.org/3/library/importlib.metadata.html#distribution-versions

python/setup.py Outdated
Copy link

Choose a reason for hiding this comment

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

can't we delete this one now?

@luke-hill luke-hill changed the title CORRECT-VERSION: 0.6.1 (was: 0.4.1) [python] Correct the version to 0.6.1 (was: 0.4.1) Oct 2, 2024
Copy link
Contributor

@luke-hill luke-hill left a comment

Choose a reason for hiding this comment

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

This PR seems to be doing a few things (As mentioned earlier).

I've updated the title but it seems as though this also isn't correct. I think it should say 6.1 instead of 0.6.1

If these things were all acceptable or rudimentary it would seem ok to merge them, but it seems like there are a few contentious things.

Maybe pop in on discord to the #committers-python channel to discuss some changes with the wider python community?

@jenisys jenisys force-pushed the python/fix_version_and_cleanup branch from ec81338 to 45f1ae9 Compare October 3, 2024 22:35
@jenisys jenisys changed the title [python] Correct the version to 0.6.1 (was: 0.4.1) [python] Provide pyproject.toml Oct 3, 2024
@jenisys jenisys changed the title [python] Provide pyproject.toml [python] Provide pyproject.toml that supersedes setup.py Oct 3, 2024
@jenisys jenisys force-pushed the python/fix_version_and_cleanup branch 2 times, most recently from d0f4aa4 to d0296bb Compare October 3, 2024 23:14
@jenisys
Copy link
Contributor Author

jenisys commented Oct 3, 2024

Replace the core changes by:

  • Provide pyproject.toml that supersedes setup.py
  • Use setuptools-scm to derive version info from git-tag(s) (in the future)
  • Remove bumpversion support (superseded-by: setuptools-scm mechanism)

OTHERWISE:

  • Other cleanup changes are left out here.

* "pyproject.toml" file supersedes "setup.py" file
* Use setuptools-scm to derive version-info from git-tags
* Remove outdated version info from
  "cucumber_tag_expressions/__init__.py", "pytest.ini"
* README.rst: Update badges to be displayed in one line on pypi.org.

CLEANUP:

* REMOVE: setup.py, setup.cfg
* REMOVE: .bumversion.cfg (superseded-by: setuptools-scm mechanism)
@jenisys jenisys force-pushed the python/fix_version_and_cleanup branch from d0296bb to e51d396 Compare October 3, 2024 23:25
@jenisys jenisys merged commit 6e6c5bc into cucumber:main Oct 6, 2024
27 checks passed
Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

@jenisys could you point out where the version declaration is currently kept? The current release process expects this to exist.

Again, I'm happy to facilitate anything else, but then I'd like to see that applied to all packages consistently. So it would be good to separate that from replacing pyproject.toml with setup.py.

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.

4 participants