Add PEP 396 __version__
attribute to torch_tb_profiler
module
#268
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
The Python extension for VS Code needs to ensure that users upgrade to the latest version of the
torch_tb_profiler
module so that users can take advantage of the jump-to-source support being added in v0.2.0.We currently check version info for Python modules using the
__version__
attribute specified in PEP 396 (code pointer here).However, the
__version__
attribute is currently missing from torch_tb_profiler v0.1.0 and 0.2.0rc2:Description of changes
This PR makes
__init__.py
the single source of truth for version info. Specifically, it moves the version number fromversion.txt
to__init__.py
, andsetup.py
then reads the version number out of__init__.py
. This is the first approach described in https://packaging.python.org/guides/single-sourcing-package-version/ and also the approach adopted bypip
itself:Test plan
To verify that this change works and doesn't break setup, I did the following:
python3 -m pip install /workspaces/kineto/tb_plugin
to install the package locallypython3 -c "import torch_tb_profiler; print(torch_tb_profiler.__version__)"
now prints out the version number: