diff --git a/pynxtools/__init__.py b/pynxtools/__init__.py index 57d3ebab6..23460b4a7 100644 --- a/pynxtools/__init__.py +++ b/pynxtools/__init__.py @@ -21,6 +21,7 @@ import os from glob import glob +from pynxtools.definitions.dev_tools.globals.nxdl import get_nxdl_version from pynxtools._build_wrapper import get_vcs_version @@ -37,9 +38,7 @@ def get_nexus_version() -> str: if not os.path.exists(version_file): # We are in the limbo, just get the nxdl version from nexus definitions - from pynxtools.definitions.dev_tools.globals.nxdl import get_nxdl_version - return get_nxdl_version() - with open(version_file) as vfile: + with open(version_file, encoding='utf-8') as vfile: return vfile.read().strip() diff --git a/pynxtools/_build_wrapper.py b/pynxtools/_build_wrapper.py index bcb58cd8a..475c62e08 100644 --- a/pynxtools/_build_wrapper.py +++ b/pynxtools/_build_wrapper.py @@ -1,10 +1,13 @@ +""" +Build wrapper for setuptools to create a nexus-version.txt file +containing the nexus definitions verison. +""" import os -from glob import glob from subprocess import CalledProcessError, run from typing import Optional from setuptools import build_meta as _orig -from setuptools.build_meta import * +from setuptools.build_meta import * # pylint: disable=wildcard-import,unused-wildcard-import def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]: @@ -27,7 +30,7 @@ def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]: return None -def _write_version_to_metadata(directory: str): +def _write_version_to_metadata(): version = get_vcs_version() if version is None or not version: raise ValueError("Could not determine version from nexus_definitions") @@ -40,21 +43,24 @@ def _write_version_to_metadata(directory: str): file.write(version) -def build_editable(wheel_directory, config_settings=None, metadata_directory=None): - _write_version_to_metadata(metadata_directory) - ret = _orig.build_editable(wheel_directory, config_settings, metadata_directory) - - return ret - - +# pylint: disable=function-redefined def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): - _write_version_to_metadata(metadata_directory) + """ + PEP 517 compliant build wheel hook. + This is a wrapper for setuptools and adds a nexus version file. + """ + _write_version_to_metadata() ret = _orig.build_wheel(wheel_directory, config_settings, metadata_directory) return ret +# pylint: disable=function-redefined def build_sdist(sdist_directory, config_settings=None): - _write_version_to_metadata(os.path.join(os.path.dirname(__file__), "../")) + """ + PEP 517 compliant build sdist hook. + This is a wrapper for setuptools and adds a nexus version file. + """ + _write_version_to_metadata() sdist_dir = _orig.build_sdist(sdist_directory, config_settings) return sdist_dir