Project-Version-Finder
Simple package to provide version informaion. The stratagy is
* first look in pyproject.toml, if it is found. This is most accurate during develompent, but when running from an install it probably will not be found, so
* second, use importlib.metadata (or importlib_metadata, if appropriate), which works if it is installed.
All you should need is
```py
from project_version_finder import get_version
__version__ = get_version('project-name')
```
(and make project-version-finder a dependancy of your project).
If you do not want the search for pyproject.toml to start in the current working directory (which is often where you will automatically find your project in development in the python path), you can add a second argument specifying a file in the directory you wish to begin the search. Some suggestions (which may require all version tests during development to NOT have an installed version also available) are:
```py
from project_version_finder import get_version
# start search in directory of the file that defines __version__
__version__ = get_version('project-name', __file__)
```
or
```py
from project_version_finder import get_version
# start search in directory of the file that defines some function fn
__version__ = get_version('project-name', fn.__globals__['__file__'])
```
The key is to have a way to get the name of a file in the directory from which you wish the search to start. Bonus points if (like the default current working directory) this name will not follow the install files: then the result will work during development even if you have an older version installed.
It isn't fool proof, but since you provide the project name, if it finds the wrong pyproject.toml it should only fail if that happens to be for a different project with the same name.
[Repository](https://codeberg.org/Pusher2531/project-version-finder.git)
[PyPI](https://pypi.org/project/project-version-finder/)
Raw data
{
"_id": null,
"home_page": null,
"name": "project-version-finder",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.6",
"maintainer_email": null,
"keywords": "development, finder, installed, manager, typed, version",
"author": null,
"author_email": "Doug Sojourner <doug@sojournings.org>",
"download_url": "https://files.pythonhosted.org/packages/f0/55/ca323737b30588ee49b9b6be3b295a7f91b438f835bb2492fd45c7e2ea53/project_version_finder-0.3.0.tar.gz",
"platform": null,
"description": "Project-Version-Finder\n\nSimple package to provide version informaion. The stratagy is \n* first look in pyproject.toml, if it is found. This is most accurate during develompent, but when running from an install it probably will not be found, so \n* second, use importlib.metadata (or importlib_metadata, if appropriate), which works if it is installed. \n\nAll you should need is \n```py\nfrom project_version_finder import get_version\n__version__ = get_version('project-name')\n```\n(and make project-version-finder a dependancy of your project).\n\nIf you do not want the search for pyproject.toml to start in the current working directory (which is often where you will automatically find your project in development in the python path), you can add a second argument specifying a file in the directory you wish to begin the search. Some suggestions (which may require all version tests during development to NOT have an installed version also available) are:\n```py\nfrom project_version_finder import get_version\n# start search in directory of the file that defines __version__\n__version__ = get_version('project-name', __file__)\n```\nor\n```py\nfrom project_version_finder import get_version\n# start search in directory of the file that defines some function fn\n__version__ = get_version('project-name', fn.__globals__['__file__'])\n```\n\nThe key is to have a way to get the name of a file in the directory from which you wish the search to start. Bonus points if (like the default current working directory) this name will not follow the install files: then the result will work during development even if you have an older version installed.\n\nIt isn't fool proof, but since you provide the project name, if it finds the wrong pyproject.toml it should only fail if that happens to be for a different project with the same name.\n\n[Repository](https://codeberg.org/Pusher2531/project-version-finder.git) \n[PyPI](https://pypi.org/project/project-version-finder/) \n",
"bugtrack_url": null,
"license": "GNU General Public License v3 (GPLv3)",
"summary": "Find __version__ for __init__.py",
"version": "0.3.0",
"project_urls": {
"issues": "https://codeberg.org/Pusher2531/project-version-finder/issues",
"repository": "https://codeberg.org/Pusher2531/project-version-finder.git"
},
"split_keywords": [
"development",
" finder",
" installed",
" manager",
" typed",
" version"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8a176b69a878e0dc104d8c59c06b6db2b0b474115114ddfbebb345a22ddf15aa",
"md5": "75dde58d0531b5d82edab685d9022c37",
"sha256": "fe705c8b013ea57e90ff21fd020ff4b8fff1e0db3fe86c3fe205ce54582c42d1"
},
"downloads": -1,
"filename": "project_version_finder-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "75dde58d0531b5d82edab685d9022c37",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.6",
"size": 4727,
"upload_time": "2025-09-13T23:21:20",
"upload_time_iso_8601": "2025-09-13T23:21:20.630723Z",
"url": "https://files.pythonhosted.org/packages/8a/17/6b69a878e0dc104d8c59c06b6db2b0b474115114ddfbebb345a22ddf15aa/project_version_finder-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f055ca323737b30588ee49b9b6be3b295a7f91b438f835bb2492fd45c7e2ea53",
"md5": "c97522c8995d95cecbf6e54e4f54f472",
"sha256": "59a13e662d2f5f2fdd33dfdf501ba215543d2e456190364f42611196d5d5d5e3"
},
"downloads": -1,
"filename": "project_version_finder-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "c97522c8995d95cecbf6e54e4f54f472",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.6",
"size": 4156,
"upload_time": "2025-09-13T23:21:21",
"upload_time_iso_8601": "2025-09-13T23:21:21.839965Z",
"url": "https://files.pythonhosted.org/packages/f0/55/ca323737b30588ee49b9b6be3b295a7f91b438f835bb2492fd45c7e2ea53/project_version_finder-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-13 23:21:21",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": true,
"codeberg_user": "Pusher2531",
"codeberg_project": "project-version-finder",
"lcname": "project-version-finder"
}