Skip to content

Commit

Permalink
Merge pull request #370 from FAIRmat-NFDI/remove-setuptools
Browse files Browse the repository at this point in the history
Remove setuptools from dependencies
  • Loading branch information
lukaspie authored Jul 4, 2024
2 parents 8cd8755 + 96f8e00 commit 7e752fb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/pynxtools/_build_wrapper.py → _build_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]:
"--match",
tag_match,
],
cwd=os.path.join(os.path.dirname(__file__), "../pynxtools/definitions"),
cwd=os.path.join(
os.path.dirname(__file__), "src/pynxtools/definitions"
),
check=True,
capture_output=True,
)
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=64.0.1", "setuptools-scm[toml]>=6.2"]
backend-path = ["src/pynxtools"]
backend-path = ["."]
build-backend = "_build_wrapper"

[project]
Expand Down Expand Up @@ -35,7 +35,6 @@ dependencies = [
"importlib-metadata",
"lxml>=4.9.1",
"anytree",
"setuptools>=64.0.1"
]

[project.urls]
Expand Down
31 changes: 30 additions & 1 deletion src/pynxtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,42 @@
import os
import re
from datetime import datetime
from subprocess import CalledProcessError, run
from typing import Optional

from pynxtools._build_wrapper import get_vcs_version
from pynxtools.definitions.dev_tools.globals.nxdl import get_nxdl_version

MAIN_BRANCH_NAME = "fairmat"


def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]:
"""
The version of the Nexus standard and the NeXus Definition language
based on git tags and commits
"""
try:
return (
run(
[
"git",
"describe",
"--dirty",
"--tags",
"--long",
"--match",
tag_match,
],
cwd=os.path.join(os.path.dirname(__file__), "../pynxtools/definitions"),
check=True,
capture_output=True,
)
.stdout.decode("utf-8")
.strip()
)
except (FileNotFoundError, CalledProcessError):
return None


def _build_version(tag: str, distance: int, node: str, dirty: bool) -> str:
"""
Builds the version string for a given set of git states.
Expand Down
6 changes: 3 additions & 3 deletions tests/dataconverter/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import logging
import os
from pathlib import Path
import shutil

import click
import h5py
import pytest
from click.testing import CliRunner
from setuptools import distutils

import pynxtools.dataconverter.convert as dataconverter
from pynxtools.dataconverter.readers.base.reader import BaseReader
Expand All @@ -34,7 +34,7 @@

def move_xarray_file_to_tmp(tmp_path):
"""Moves the xarray file, which is used to test linking into the tmp_path directory."""
distutils.file_util.copy_file(
shutil.copy(
os.path.join(
os.getcwd(), "src", "pynxtools", "data", "xarray_saved_small_calibration.h5"
),
Expand All @@ -49,7 +49,7 @@ def restore_xarray_file_from_tmp(tmp_path):
os.getcwd(), "src", "pynxtools", "data", "xarray_saved_small_calibration.h5"
)
)
distutils.file_util.move_file(
shutil.move(
os.path.join(tmp_path, "xarray_saved_small_calibration.h5"),
os.path.join(
os.getcwd(), "src", "pynxtools", "data", "xarray_saved_small_calibration.h5"
Expand Down
4 changes: 2 additions & 2 deletions tests/dataconverter/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import os
import xml.etree.ElementTree as ET
from typing import Optional
import shutil

import numpy as np
import pytest
from setuptools import distutils

from pynxtools.dataconverter import helpers
from pynxtools.dataconverter.template import Template
Expand Down Expand Up @@ -148,7 +148,7 @@ def fixture_filled_test_data(template, tmp_path):
# Copy original measurement file to tmp dir,
# because h5py.ExternalLink is modifying it while
# linking the nxs file.
distutils.file_util.copy_file(
shutil.copy(
os.path.join(
os.getcwd(), "src", "pynxtools", "data", "xarray_saved_small_calibration.h5"
),
Expand Down

0 comments on commit 7e752fb

Please sign in to comment.