Skip to content

Commit

Permalink
Merge pull request #107 from lanl/setup
Browse files Browse the repository at this point in the history
Removed git commands in setup.py
  • Loading branch information
jpulidojr authored Aug 13, 2024
2 parents e037267 + 0fc8f3c commit 36d796a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name="dsi"
name="pydsinf"
license={text = "BSD-3-Clause"}
description="A Data Science Infrastructure Metadatabase"
readme = "README.rst"
authors=[
{name = 'Jesus Pulido', email = '[email protected]'},
{name = 'James Ahrens', email = '[email protected]'},
{name = 'Divya Banesh', email = '[email protected]'},
{name = 'Hugh Greenberg', email = '[email protected]'},
{name = 'Jesus Pulido', email = '[email protected]'},
{name = 'Ben Sims', email = '[email protected]'},
{name = 'Christine Sweeney', email = '[email protected]'},
{name = 'Terry Turton', email = '[email protected]'},
Expand Down
27 changes: 0 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,11 @@
import subprocess


def get_cmd_output(cmd: list) -> str:
proc = subprocess.run(cmd, capture_output=True, shell=True)
if proc.stderr != b"":
raise Exception(proc.stderr)
return proc.stdout.strip().decode("utf-8")


def insert_git_commit(replacement_target, sha):
with fileinput.FileInput(replacement_target, inplace=True) as fh:
for line in fh:
op = re.sub(r"git_commit_sha=.*",
r"git_commit_sha='{}'".format(sha), line)
print(op, end='')

# Get version from main folder
exec(open("dsi/_version.py").read())

# Get the current git hash
sha = get_cmd_output(cmd='git rev-parse HEAD')
# Get the root of the git project
git_root = get_cmd_output(cmd='git rev-parse --show-toplevel')

# String replace git_sha_commit placeholder for Plugin and Backend implementations
metadata = '/'.join([git_root, 'dsi/plugins/metadata.py'])
filesystem = '/'.join([git_root, 'dsi/backends/filesystem.py'])

class SetupWrapper(install):
def run(self):
insert_git_commit(metadata, sha)
insert_git_commit(filesystem, sha)
print(get_cmd_output(
cmd='git add {} {}'.format(metadata, filesystem)))
install.run(self)


Expand Down

0 comments on commit 36d796a

Please sign in to comment.