else: return repository_root(path.parent) sys.path.insert(0, str(repository_root())) # -- Project information ----------------------------------------------------- metadata = config.read_configuration('../../setup.cfg')['metadata'] project = metadata['name'] author = metadata['author'] copyright = f'2021, Office of Coast Survey (OCS), National Oceanic and Atmospheric Administration (NOAA)' # The full version, including alpha/beta/rc tags try: release = Version.from_any_vcs().serialize() except RuntimeError: release = os.environ.get('VERSION') # -- General configuration --------------------------------------------------- autoclass_content = 'both' # include both class docstring and __init__ autodoc_default_options = { # Make sure that any autodoc declarations show the right members 'members': True, 'inherited-members': True, 'private-members': True, 'member-order': 'bysource', 'exclude-members': '__weakref__', } autosummary_generate = True # Make _autosummary files and include them
import pathlib import setuptools try: try: from dunamai import Version except ImportError: import sys import subprocess subprocess.check_call( [sys.executable, '-m', 'pip', 'install', 'dunamai']) from dunamai import Version version = Version.from_any_vcs().serialize() except RuntimeError as error: logging.exception(error) version = '0.0.0' logging.info(f'using version {version}') metadata = setuptools.config.read_configuration( pathlib.Path(__file__).parent.absolute() / 'setup.cfg')['metadata'] setuptools.setup( name=metadata['name'], version=version, author=metadata['author'], author_email=metadata['author_email'], description=metadata['description'],
from setuptools import setup, find_packages from dunamai import Version, Style setup( version=Version.from_any_vcs().serialize(style=Style.SemVer), packages=find_packages(exclude=["docs", "tests"]), )
def test__version__from_any_vcs(tmp_path) -> None: with chdir(tmp_path): with pytest.raises(RuntimeError): Version.from_any_vcs() with pytest.raises(RuntimeError): Version.from_vcs(Vcs.Any)
def dunamai_get_from_vcs(dir_: Path) -> Version: from dunamai import Version with working_dir(dir_): return Version.from_any_vcs(f"(?x)v?{RE_PEP440_VERSION.pattern}")