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

dynamic version #1314

Closed
2 tasks done
dpgaspar opened this issue Aug 22, 2019 · 7 comments
Closed
2 tasks done

dynamic version #1314

dpgaspar opened this issue Aug 22, 2019 · 7 comments

Comments

@dpgaspar
Copy link

dpgaspar commented Aug 22, 2019

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Question

I'm migrating a project to poetry

I would like to make the version based on the contents of a file, say JSON or __init__.py any advice you can offer?

@dpgaspar dpgaspar changed the title poetry install questions dynamic version Aug 22, 2019
@finswimmer
Copy link
Member

finswimmer commented Sep 11, 2019

I'm looking for the exact same thing.

The reason for this is, that I need the version number within my package as well.

I could imagine somthing like this:

[tool.poetry]
name = "my_package"
version = {path = "/path/to/package.json"}

Where package.json must contain a key version:

{
  "version": "0.1.0"
}

@finswimmer
Copy link
Member

Another way I could think of, is that there is in option for poetry version to write the bumped version to a __version__.py as well. Because this is a place where lots of people store their package version number as well. (poetry as well ;) )

@dmontagu
Copy link

dmontagu commented Sep 18, 2019

I have been using (and loving) the trick from this comment: #144 (comment)

In order to adapt it to your own project, all you need to do is change x12_utils/__init__.py to the path to whatever file you want to contain your project's version number. (And maybe also change the path to pyproject.toml if necessary.)

Then you can run that make command (or shell script, if you use that approach) to have poetry set the version in pyproject.toml, and have sed set the version (output by poetry) in the version file.

The only restriction is that the same version string shouldn't show up in an unrelated way in the file (e.g., don't run it on a file that includes version numbers for all of your dependencies).

@finswimmer
Copy link
Member

finswimmer commented Sep 18, 2019

Thanks for pointing me to that issue!

Having a custom script, that do the version bumping in all files, is one workaround, but would introduce a new "tool" beside poetry. But I like other solutions mentioned there and in linked issues:

With the last one, one can get all metadata shipped with the package and is intended to get integrated in python3.8 (before one has to install it via pip).

To think in a bigger context: The underlying question in all 3 issues is how and where to store metadata that is needed by poetry during build process and also by the package itself, in a way that only one location is needed.

The most cleanest way seems to me having the metadata in the pyproject.toml and using one of the mentioned packages to fetch metadata during runtime of the package.

@kasteph kasteph removed the question label Sep 23, 2019
@stale
Copy link

stale bot commented Nov 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 22, 2019
@stale
Copy link

stale bot commented Nov 29, 2019

Closing this issue automatically because it has not had any activity since it has been marked as stale. If you think it is still relevant and should be addressed, feel free to open a new one.

Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants