Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
domna committed Oct 30, 2023
1 parent b216afa commit 9894b38
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
5 changes: 2 additions & 3 deletions pynxtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()
30 changes: 18 additions & 12 deletions pynxtools/_build_wrapper.py
Original file line number Diff line number Diff line change
@@ -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]:
Expand All @@ -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")
Expand All @@ -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

0 comments on commit 9894b38

Please sign in to comment.