Skip to content

Commit

Permalink
Merge branch 'rtd-build' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
RKrahl committed Feb 7, 2024
2 parents 9757d4c + 88b67fa commit 8b9b8f7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 44 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/rst-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Check ReST input files
on: [push, pull_request]
on:
push:
branches:
- develop
- master
pull_request:
jobs:
doc8:
runs-on: ubuntu-latest
Expand Down
7 changes: 3 additions & 4 deletions .requirements
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
jinja2<3.1
setuptools_scm
sphinx>=2,<3
sphinx-rtd-theme>=0.5,<1
git-props
setuptools
sphinx-rtd-theme
16 changes: 10 additions & 6 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

import os
from pathlib import Path
import sys
sys.path.insert(0, os.path.abspath('.'))

maindir = Path(__file__).resolve().parent
sys.path[0] = str(maindir)
sys.dont_write_bytecode = True

import _meta

# -- Project information -----------------------------------------------------

project = "PIDINST"
author = "RDA Persistent Identification of Instruments WG"
copyright = "2020, %s" % author
copyright = "2020–2024, %s" % author

# The full version, including alpha/beta/rc tags
# Dummy for the time being
release = _meta.__version__
release = _meta.version
# The short X.Y version
version = ".".join(release.split(".")[0:2])

today = _meta.__date__
today = _meta.date

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -62,7 +66,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
40 changes: 7 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,18 @@
import os
from pathlib import Path
import subprocess
import gitprops


class GitProps:
"""Determine properties of the git repository.
"""

def __init__(self, root="."):
self.root = Path(root).resolve()

def _exec(self, cmd):
proc = subprocess.run(cmd.split(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.root,
check=True,
env=dict(os.environ, LC_ALL='C'),
universal_newlines=True)
return proc.stdout.strip()

def is_dirty(self):
return bool(self._exec("git status --porcelain --untracked-files=no"))

def get_date(self):
if self.is_dirty():
return datetime.date.today()
else:
ts = int(self._exec("git log -1 --format=%cd --date=unix"))
return datetime.date.fromtimestamp(ts)
version = str(gitprops.get_version())


class meta(setuptools.Command):

description = "generate meta files"
user_options = []
meta_template = '''
__version__ = "%(version)s"
__date__ = "%(date)s"
version = "%(version)s"
date = "%(date)s"
'''

def initialize_options(self):
Expand All @@ -55,12 +30,11 @@ def finalize_options(self):
pass

def run(self):
git = GitProps()
version = self.distribution.get_version()
log.info("version: %s", version)
values = {
'version': version,
'date': git.get_date().strftime("%e %B %Y").strip(),
'date': gitprops.get_date().strftime("%e %B %Y").strip(),
}
with Path("_meta.py").open("wt") as f:
print(self.meta_template % values, file=f)
Expand All @@ -73,10 +47,10 @@ def run(self):


setup(
use_scm_version=True,
version = version,
url = "https://github.com/rdawg-pidinst/white-paper",
python_requires = '>= 3.6',
install_requires = ['setuptools_scm'],
install_requires = ["setuptools", "git-props"],
py_modules = [],
cmdclass = {'meta': meta, 'install': install},
)

0 comments on commit 8b9b8f7

Please sign in to comment.