Version issues when building pytorch from source

Dear community,
I build pytorch from the source with v1.12.1 in conda env.
git branch shown below.

(pytorch_compile_2) .../mypath/.../pytorch$ git branch
* (HEAD detached at v1.12.1)
  main

When I build successfully, the version looks like this:

>>> import torch
>>> print(torch.__version__)
1.12.0a0+git664058f

How do I successfully build v1.12.1 version of pytorch.

The commit is the right one as it’s pointing to the HEAD of v1.12.1. If you want to show the release version alone you might want to set the PYTORCH_VERSION environment variable.

Thank you for the quick answer.

(pytorch_compile_2) .../mypath/.../pytorch$ git branch
* (HEAD detached at v1.12.1)
  main
(pytorch_compile_2) .../mypath/.../pytorch$ export PYTORCH_VERSION=v1.12.1
(pytorch_compile_2) .../mypath/.../pytorch$ python setup.py install
Building wheel torch-1.12.0a0+git664058f
-- Building version 1.12.0a0+git664058f
cmake --build . --target install --config Release
[0/1] Install the project...
-- Install configuration: "Release"
running install
...
...

How to set the PYTORCH_VERSION environment variable.
Even after setting it using export PYTORCH_VERSION=v1.12.1, the installation is not successful. When trying to install in the v1.12.1 folder, it shows Building wheel torch-1.12.0a0+git664058f.

Thanks.