Tooling for managing asset compression, storage, and retrieval
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
922 B

  1. import importlib.metadata
  2. import logging
  3. import os
  4. import pathlib
  5. import toml
  6. LOG = logging.getLogger("acm.version")
  7. def __get_version():
  8. """
  9. Automatically determine the version of the application being run
  10. """
  11. # Attempt to read the installed package information
  12. try:
  13. return importlib.metadata.version('asset-compression-manager')
  14. except importlib.metadata.PackageNotFoundError:
  15. LOG.debug("The package is not installed, reading the version from another source")
  16. # Fallback on parsing the pyproject.toml file
  17. root_dir = pathlib.Path(__file__).parent.parent.resolve()
  18. with open(os.path.join(root_dir, "pyproject.toml"), "r") as project_file:
  19. project = toml.load(project_file)
  20. return project["tool"]["poetry"]["version"]
  21. LOG.debug("Falling back on UNKNOWN version identifier")
  22. return "UNKNOWN"
  23. # Application Version
  24. VERSION = __get_version()