ploomber / pkgmt

A toolkit for managing Python packages. 📦🐍
https://pkgmt.readthedocs.io/
MIT License
10 stars 10 forks source link

support `pkgmt version` for projects with `pyproject.toml` #58

Closed edublancas closed 1 year ago

edublancas commented 1 year ago

In previous releases, we allowed pkgmt version to work in projects that don't have a setup.py; however, I'm having issues making it work with https://github.com/ploomber/kub-dashboard

I suggest the following:

If there is a pyproject.toml file with the following:

[tool.pkgmt]
version_file = 'path/to/version.py'

(you can load the pyproject.toml with the code in config.py)

Let's use that file as the "version file"

If pyproject.toml doesn't exist or if the version_file key doesn't exist. let's use the default logic where we look up the project root and then use the project_root/__version__.py file.

let's make sure the full workflow works because I had to add some if statements in versioneer.py (line 142) in a previous PR since I was getting some errors.

I think we can modify VersioneerNonSetup and have something like VersioneerNonSetup(version_file='path/to/version.py') (and assume the project root is the git repository root)

neelasha23 commented 1 year ago

Acceptance criteria:

  1. Add logic of read version file path from the .toml file
  2. If no version file mentioned in toml then resort to default logic.
  3. Add test cases.
  4. Ensure it works for kub-dashboard
  5. Add documentation for the new flow
  6. Changelog entry
neelasha23 commented 1 year ago

A few clarifications:

  1. Do we want to deprecate the previous functionality for non-setup (version_package parameter in version method)
  2. Where will the version.py file of kub-dashboard reside? I see a setup.py file with version in cloud-core. Do we want separate version files for api and cloud-core? @edublancas
edublancas commented 1 year ago
  1. I tried reading the code but didn't fully understand how the current logic works. So yes, I think we can deprecate it.
  2. we might change it in the future but for now, it's here: https://github.com/ploomber/kub-dashboard/blob/main/cloud-core/src/cloud_core/__init__.py

so if I add this pyproject.toml:

[tool.pkgmt]
version_file = 'cloud-core/src/cloud_core/__init__.py'

It should work. However, note that the changelog is still in the root directory: https://github.com/ploomber/kub-dashboard/blob/main/CHANGELOG.md and that should still work, since commands like pkgmt version rely on the CHANGELOG.md to reside in the root folder