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

feat: dynamic versioning for hatch #156

Merged
merged 8 commits into from
Jul 31, 2023

Conversation

Saransh-cpp
Copy link
Member

@Saransh-cpp Saransh-cpp commented Jul 26, 2023

Pull Request description

This PR switches hatch to use dynamic versioning, similar to flit -

and pdm

in this repository. There are also some minor fixes which I found while using the repo -

  • redundant noqa
  • typo in workflow file

Fixes #153

How to test these changes

  • ...

Pull Request checklists

This PR is a:

  • bug-fix
  • new feature
  • maintenance

About this PR:

  • it includes tests.
  • the tests are executed on CI.
  • the tests generate log file(s) (path).
  • pre-commit hooks were executed locally.
  • this PR requires a project documentation update.

Author's checklist:

  • I have reviewed the changes and it contains no misspelling.
  • The code is well commented, especially in the parts that contain more complexity.
  • New and old tests passed locally.

Additional information

Reviewer's checklist

Copy and paste this template for your review's note:

## Reviewer's Checklist

- [ ] I managed to reproduce the problem locally from the `main` branch
- [ ] I managed to test the new changes locally
- [ ] I confirm that the issues mentioned were fixed/resolved .

@Saransh-cpp Saransh-cpp changed the title Dynamic versioning for hatch feat: dynamic versioning for hatch Jul 26, 2023
@Saransh-cpp
Copy link
Member Author

Hmm weird, this does not fail locally + if I add the noqa statements, the CI does log a warning.

@Anavelyz
Copy link
Collaborator

Hmm weird, this does not fail locally + if I add the noqa statements, the CI does log a warning.

Hi @Saransh-cpp

When you run makim tests.lint this error appears. The noqa was added to find a solution later. On Discord we once talked about it...

@Saransh-cpp
Copy link
Member Author

Oh, I missed that. Thanks, @Anavelyz! Will revert this.

@xmnlab
Copy link
Member

xmnlab commented Jul 27, 2023

@Saransh-cpp thanks for working on that!
I have some questions about that.

  • how does hatch handles the version information? using git?
  • how to release a new version with hatch?
  • I saw that you hard-coded 0.0.1, shouldn't it come from the user input? for example, if the project uses semantic-release, it doesn't work very well with 0.* versions (although I use it 0.* approach anyway), so maybe some uses would like to start with a specific version.
  • probably we should offer an option for versioning type dynamic or static

@Saransh-cpp
Copy link
Member Author

Thanks for the quick review, @xmnlab!


how does hatch handles the version information? using git?

hatch reads it from __init__.py (similar to the other backends), the only difference being it uses regex to read that, which means that it does not execute functions while looking for the version. Hence, the get_version function would not work with hatch, we'll have to write down the version in the file.

hatch can read version from git too, but that would be another PR (adding VCS versioning to scicookie). My explanation might be a bit confusing, but "dynamic" version here is not the same as "VCS" version, dynamic just means reading the version from a file that is not pyproject.toml and VCS would mean using git tags to automatically set the version. Both of them are Semantic versions, I think.

how to release a new version with hatch?

That would be very similar to the other backends, but it would just require updating the version manually in __init__.py. We would be able to do it without the manual work if the VCS versioning is integrated (hatch-vcs).

I saw that you hard-coded 0.0.1, shouldn't it come from the user input? for example, if the project uses semantic-release, it doesn't work very well with 0.* versions (although I use it 0.* approach anyway), so maybe some uses would like to start with a specific version.

Yes, that could be an issue.

probably we should offer an option for versioning type dynamic or static

Yes, that would be nice. Right now every backend offers dynamic versioning by default, the only difference being that they do execute functions while obtaining that version from __init__.py.


I'd be happy to convert this PR into "static/dynamic" choice PR, or keep this as it is and offer users only "dynamic" versions! :)

@xmnlab
Copy link
Member

xmnlab commented Jul 28, 2023

@Saransh-cpp thanks for the explanation!
I was a bit confused about the name .. dynamic sounds like different than the static ... but according to your explanation for hatch, it is actually static .. but not in the pyproject.toml, is that correct?

if so, in this case it would still be static .. so it looks good to me in general.

but I think that the hard-coded 0.0.1 should be replaced by "{{ cookiecutter.project_version }}", it will be converted to the actual value defined by the user before any hatch run command

@Saransh-cpp
Copy link
Member Author

Yes! Agreed, I will switch to "{{ cookiecutter.project_version }}".

@xmnlab
Copy link
Member

xmnlab commented Jul 31, 2023

thanks for working on that @Saransh-cpp ! LGTM!

@xmnlab xmnlab merged commit bea6ad2 into osl-incubator:main Jul 31, 2023
11 checks passed
__version__ = version
{%- endif %}
__author__ = {{ QUOTE }}{{ cookiecutter.project_version }}{{ QUOTE }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Saransh-cpp Why did you change this?

Copy link
Member

Choose a reason for hiding this comment

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

ohhh good catch!! and sorry for my dynamic reading in the review XD
I really need some vacations! I can fix that!

Copy link
Member Author

Choose a reason for hiding this comment

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

Woops, I completely missed that. Thank you for fixing the mess, @xmnlab and @Anavelyz!

xmnlab added a commit that referenced this pull request Jul 31, 2023
@Saransh-cpp Saransh-cpp deleted the dynamic-hatch branch July 31, 2023 20:13
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

🎉 This PR is included in version 0.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the hatch-pyproject.toml
3 participants