@@ -169,7 +169,8 @@ def get_version():
169169 # If this is a hatchling project, use hatch to get
170170 # the dynamic version.
171171 if data .get ("build-system" , {}).get ("build-backend" ) == "hatchling.build" :
172- return run ("pipx run hatch version" ).split ("\n " )[- 1 ]
172+ cmd = _get_hatch_version_cmd ()
173+ return run (cmd ).split ("\n " )[- 1 ]
173174
174175 if SETUP_PY .exists ():
175176 warnings .warn ("Using deprecated setup.py invocation" )
@@ -236,6 +237,12 @@ def create_release_commit(version, release_message=None, dist_dir="dist"):
236237 return shas
237238
238239
240+ def _get_hatch_version_cmd ():
241+ if shutil .which ("hatch" ):
242+ return "hatch version"
243+ return "pipx run hatch version"
244+
245+
239246def bump_version (version_spec , * , changelog_path = "" , version_cmd = "" ):
240247 """Bump the version"""
241248 # Look for config files to determine version command if not given
@@ -252,7 +259,7 @@ def bump_version(version_spec, *, changelog_path="", version_cmd=""):
252259 if "tool.tbump" in pyproject_text :
253260 version_cmd = version_cmd or TBUMP_CMD
254261 elif "hatchling.build" in pyproject_text :
255- version_cmd = version_cmd or "pipx run hatch version"
262+ version_cmd = version_cmd or _get_hatch_version_cmd ()
256263
257264 if SETUP_CFG .exists ():
258265 if "bumpversion" in SETUP_CFG .read_text (encoding = "utf-8" ):
0 commit comments