Skip to content

Commit

Permalink
Add shell variable interface for ksconf.version
Browse files Browse the repository at this point in the history
  • Loading branch information
lowell80 committed Oct 12, 2023
1 parent 8c893f7 commit b078901
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ Ksconf v0.13.3 (2023-10-12)

* Created a new public interface :ref:py:mod:`ksconf.version`.
This provides a consistent means of getting the version information without any extra modules being loaded, now that ksconf is a namespace package.

Note that for v0.13.0 - 0.13.2, this was called ``ksconf._ksconf``.
Hopefully in that short time frame nobody got too attached to that terrible name.


* Changes for :ref:`ksconf_cmd_rest-publish`:

* Implement ``--insecure`` parameter.
Expand All @@ -43,6 +41,9 @@ Ksconf v0.13.3 (2023-10-12)
* Fix some incorrect/misleading CLI argument help.
* Internal improvements for long-term maintenance.

* Shell scripts: If you need the ksconf version from a shell script, it's possible to use ``python -m ksconf.version`` to spit out shell variables to get version information.
This previously worked with ``ksconf._version``, but that was never publicly documented and should be avoided in the future.


Ksconf v0.13.2 (2023-10-10)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 4 additions & 0 deletions ksconf/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@
| <\__ \ (_| (_) | | | | _|
|_|\_\___/\___\___/|_| |_|_|
""")

if __name__ == '__main__':
from ._version import SHELL_VER_VARS
print(SHELL_VER_VARS)
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_ver(_allow_git_fetch=True):
version = version.lstrip("v") # Tags format is v0.0.0
del gitout

# NOTE: pre-commit building complexities go away after v0.13.0
# NOTE: pre-commit building complexities go away after v0.14.0

# If version is hex string, assume there's an issue (aka running from pre-commit's install)
# Pre-commit has it's own shallow clone that doesn't check out that tags we need to build the
Expand Down Expand Up @@ -91,8 +91,11 @@ def get_ver(_allow_git_fetch=True):
vcs_info = {vc_info!r}
package_name = {package_name!r}
SHELL_VER_VARS = 'KSCONF_VERSION="{version}"\\nKSCONF_BUILD="{build_no}"\\nKSCONF_VCS_INFO="{vc_info}"'
if __name__ == '__main__':
print('KSCONF_VERSION="{version}"\\nKSCONF_BUILD="{build_no}"\\nKSCONF_VCS_INFO="{vc_info}"')
print("# Please use 'python -m ksconf.version' instead. This will eventually go away.")
print(SHELL_VER_VARS)
""")
open(ver_file, "w").write(code_block)
return version
Expand Down

0 comments on commit b078901

Please sign in to comment.