{ "info": { "author": "John Thorvald Wodder II", "author_email": "read-version@varonathe.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Software Distribution" ], "description": ".. image:: http://www.repostatus.org/badges/latest/active.svg\n :target: http://www.repostatus.org/#active\n :alt: Project Status: Active \u2014 The project has reached a stable, usable\n state and is being actively developed.\n\n.. image:: https://travis-ci.org/jwodder/read_version.svg?branch=master\n :target: https://travis-ci.org/jwodder/read_version\n\n.. image:: https://codecov.io/gh/jwodder/read_version/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/jwodder/read_version\n\n.. image:: https://img.shields.io/pypi/pyversions/read_version.svg\n :target: https://pypi.org/project/read_version/\n\n.. image:: https://img.shields.io/github/license/jwodder/read_version.svg\n :target: https://opensource.org/licenses/MIT\n :alt: MIT License\n\n.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg\n :target: https://saythanks.io/to/jwodder\n\n`GitHub `_\n| `PyPI `_\n| `Issues `_\n\nWhen creating a ``setup.py`` for a new project, do you find yourself always\nwriting the same block of code for parsing ``__version__`` from your project's\nsource? Something like this?\n\n::\n\n with open(join(dirname(__file__), 'package_name', '__init__.py')) as fp:\n for line in fp:\n m = re.search(r'^\\s*__version__\\s*=\\s*([\\'\"])([^\\'\"]+)\\1\\s*$', line)\n if m:\n version = m.group(2)\n break\n else:\n raise RuntimeError('Unable to find own __version__ string')\n\n setup(\n version = version,\n ...\n )\n\nSomeone needs to put all that into a reusable package, am I right? Well,\nsomeone did, and this is that package.\n\nInstallation\n============\nJust use `pip `_ (You have pip, right?) to install\n``read_version``::\n\n pip install read_version\n\n\nUsage\n=====\n1. Install ``read_version`` in your development environment.\n\n2. Add a ``pyproject.toml`` file to your project declaring ``read_version`` as\n a build dependency. (This is needed so that other people can build your\n package from source; see `PEP 518\n `_ for more information.) The\n contents of the file should look like::\n\n [build-system]\n requires = [\n \"read_version ~= 0.1.0\",\n \"setuptools\",\n \"wheel\"\n ]\n\n3. In your ``setup.py``, get rid of your boilerplate ``__version__``-finding\n code and replace it with::\n\n from read_version import read_version\n\n setup(\n version = read_version('packagename', '__init__.py'),\n ...\n )\n\n4. Done!\n\n\nAPI\n===\n``read_version`` exports a single function, also named ``read_version``, whose\nsignature is::\n\n read_version(*filepath, variable='__version__', default=NOTHING)\n\n``read_version()`` takes one or more file path components pointing to a Python\nsource file to parse. The path components will be joined together with\n``os.path.join()``, and then, if the path isn't absolute, the path to the\ndirectory containing the script calling ``read_version()`` will be prepended to\nthe path. (No more ``join(dirname(__file__), ...)`` boilerplate needed!)\n``read_version()`` then parses the given Python file and searches through the\nparse tree for any assignments to a variable named ``__version__``, returning\nthe last value assigned.\n\nThe ``variable`` keyword argument can be set to the name of a variable other\nthan ``__version__`` to search for assignments to a different variable instead.\n\nIf no assignments to the variable are found, a ``ValueError`` is raised. To\ninstead return a default value when this happens, set the ``default`` keyword\nargument.\n\n\nRestrictions\n============\n``read_variable`` only finds assignments that occur at the top level of the\nmodule, outside of any blocks.\n\nOnly assignments of literal values are supported; assignments to\n``__version__`` involving more complicated expressions will cause an error to\nbe raised.\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jwodder/read_version", "keywords": "packaging,setuptools,version", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "read-version", "package_url": "https://pypi.org/project/read-version/", "platform": "", "project_url": "https://pypi.org/project/read-version/", "project_urls": { "Bug Tracker": "https://github.com/jwodder/read_version/issues", "Homepage": "https://github.com/jwodder/read_version", "Say Thanks!": "https://saythanks.io/to/jwodder", "Source Code": "https://github.com/jwodder/read_version" }, "release_url": "https://pypi.org/project/read-version/0.1.1/", "requires_dist": null, "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "summary": "Extract your project's __version__ variable", "version": "0.1.1" }, "last_serial": 5197701, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "60da49f76f94443c3540e8508ac80d87", "sha256": "8fde70d61299adf73fee5e2357541ac9b78ad0c4367ae78118965546461871bb" }, "downloads": -1, "filename": "read_version-0.1.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "60da49f76f94443c3540e8508ac80d87", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5413, "upload_time": "2018-09-25T18:12:33", "url": "https://files.pythonhosted.org/packages/ca/cf/fed9a9316d7e94c7a706329ac67faff5924b192b644bda014d4d81368969/read_version-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f580ad7c19f05d5e4948cebb86efcc4e", "sha256": "2712e39d402a8229eca551b4d7c729ed1ba35823ff47412ad710f97412378b86" }, "downloads": -1, "filename": "read_version-0.1.0.tar.gz", "has_sig": true, "md5_digest": "f580ad7c19f05d5e4948cebb86efcc4e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 6152, "upload_time": "2018-09-25T18:12:35", "url": "https://files.pythonhosted.org/packages/9a/ae/2d6cb9cd3a3d54489a0c5883ce3e1472e60697d523b34f9f232324912a37/read_version-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "6a1084949d082ea41fb2419ea91ed8e2", "sha256": "bd193812a07e39c4a6058c1bb58128593e01f8a1988c36bfc0e7dbe8711784bc" }, "downloads": -1, "filename": "read_version-0.1.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "6a1084949d082ea41fb2419ea91ed8e2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5488, "upload_time": "2019-04-27T20:20:03", "url": "https://files.pythonhosted.org/packages/11/53/e1ef81ad3722eb27cf73f8ab858ac064f01785db75e9b7d2692817c609bc/read_version-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0f340a795b48f66d3e8cacd59be457b2", "sha256": "7baa75871f557d8cf4580bac19c41ca83514163a451690d3296bc54a22bfc26e" }, "downloads": -1, "filename": "read_version-0.1.1.tar.gz", "has_sig": true, "md5_digest": "0f340a795b48f66d3e8cacd59be457b2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 6888, "upload_time": "2019-04-27T20:20:06", "url": "https://files.pythonhosted.org/packages/76/db/3c52971f2c40de0dad4691c86df8b0b006e5cae4c94025ecbcc2cce6d023/read_version-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6a1084949d082ea41fb2419ea91ed8e2", "sha256": "bd193812a07e39c4a6058c1bb58128593e01f8a1988c36bfc0e7dbe8711784bc" }, "downloads": -1, "filename": "read_version-0.1.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "6a1084949d082ea41fb2419ea91ed8e2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 5488, "upload_time": "2019-04-27T20:20:03", "url": "https://files.pythonhosted.org/packages/11/53/e1ef81ad3722eb27cf73f8ab858ac064f01785db75e9b7d2692817c609bc/read_version-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0f340a795b48f66d3e8cacd59be457b2", "sha256": "7baa75871f557d8cf4580bac19c41ca83514163a451690d3296bc54a22bfc26e" }, "downloads": -1, "filename": "read_version-0.1.1.tar.gz", "has_sig": true, "md5_digest": "0f340a795b48f66d3e8cacd59be457b2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", "size": 6888, "upload_time": "2019-04-27T20:20:06", "url": "https://files.pythonhosted.org/packages/76/db/3c52971f2c40de0dad4691c86df8b0b006e5cae4c94025ecbcc2cce6d023/read_version-0.1.1.tar.gz" } ] }