Skip to content

Commit d330d6a

Browse files
committed
chore: drop git magic
1 parent 3a1251d commit d330d6a

File tree

3 files changed

+12
-36
lines changed

3 files changed

+12
-36
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "spras"
3-
dynamic = ["version"] # update spras_version in setup.py!
3+
version = "0.6.0"
44
description = "Signaling Pathway Reconstruction Analysis Streamliner"
55
authors = [
66
{ name = "Anthony Gitter", email = "gitter@biostat.wisc.edu" },

setup.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

spras/config/config.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import hashlib
1818
import importlib.metadata
1919
import itertools as it
20-
import subprocess
21-
import tomllib
2220
import warnings
2321
from pathlib import Path
2422
from typing import Any
@@ -36,11 +34,18 @@
3634
def spras_revision() -> str:
3735
"""
3836
Gets the current revision of SPRAS.
39-
40-
Note that the SPRAS package version is dynamically dependent on setup.py.
41-
"""
42-
return importlib.metadata.version('spras')
4337
38+
Note that this is not dependent on the SPRAS version nor the git commit, but rather solely on the PyPA RECORD file,
39+
(https://packaging.python.org/en/latest/specifications/recording-installed-packages/#the-record-file), which contains
40+
hashes of all files associated with the package distribution [other than itself], and is also included in the package distribution.
41+
"""
42+
try:
43+
record_path = str(importlib.metadata.distribution('spras').locate_file(f"spras-{importlib.metadata.version('spras')}.dist-info/RECORD"))
44+
with open(record_path, 'rb', buffering=0) as f:
45+
# Truncated to the magic value 8, the length of the short git revision.
46+
return hashlib.file_digest(f, 'sha256').hexdigest()[:8]
47+
except importlib.metadata.PackageNotFoundError as err:
48+
raise RuntimeError('spras is not an installed pip-module: did you forget to install SPRAS as a module?') from err
4449
def attach_spras_revision(label: str) -> str:
4550
return f"{label}_{spras_revision()}"
4651

0 commit comments

Comments
 (0)