Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
better version mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuche committed Jul 27, 2022
1 parent cfaaf3c commit 7e695f0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/docs.sh
Expand Up @@ -3,13 +3,11 @@
mkdir docs-temp/
mv docs/* docs-temp/
cd docs/
export VERSION=$(grep version ../setup.py | cut -f2 -d "'")
export VERSION=$(grep __version__ ../ufjc/__init__.py | cut -f2 -d '"')
sphinx-quickstart --sep -p ufjc -l en -a 'Michael R. Buche, Scott J. Grutzik' -r ${VERSION} -v ${VERSION}
sphinx-apidoc -e -P -o source ../ ../*setup*
mv ../docs-temp/* source/
rm -r ../docs-temp/
echo "release = '${VERSION}'" >> source/conf.py
echo "version = '${VERSION}'" >> source/conf.py
for file in ../ufjc/*.py; do
export file_basename=$(basename ${file%.*})
export rst_file=$(echo "source/*`basename ${file%.*}`.rst")
Expand Down
20 changes: 18 additions & 2 deletions docs/conf.py
@@ -1,8 +1,24 @@
import os
import re
import sys
sys.path.insert(0, os.path.abspath("../../"))
from os.path import join, abspath
sys.path.insert(0, abspath("../../"))


def get_version():
VERSIONFILE = join('..', '..', 'ufjc', '__init__.py')
with open(VERSIONFILE, 'rt') as f:
lines = f.readlines()
vgx = '^__version__ = \"[0-9+.0-9+.0-9+]*[a-zA-Z0-9]*\"'
for line in lines:
mo = re.search(vgx, line, re.M)
if mo:
return mo.group().split('"')[1]
raise RuntimeError('Unable to find version in %s.' % (VERSIONFILE,))


project = 'uFJC'
version = get_version()
release = version
author = 'Michael R. Buche, Scott J. Grutzik'
copyright = '2022 National Technology & Engineering Solutions of Sandia, \
LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, \
Expand Down
16 changes: 15 additions & 1 deletion setup.py
@@ -1,3 +1,5 @@
import re
from os.path import join
from distutils.core import setup
from setuptools import find_packages

Expand All @@ -8,9 +10,21 @@ def read(fname):
return content


def get_version():
VERSIONFILE = join('ufjc', '__init__.py')
with open(VERSIONFILE, 'rt') as f:
lines = f.readlines()
vgx = '^__version__ = \"[0-9+.0-9+.0-9+]*[a-zA-Z0-9]*\"'
for line in lines:
mo = re.search(vgx, line, re.M)
if mo:
return mo.group().split('"')[1]
raise RuntimeError('Unable to find version in %s.' % (VERSIONFILE,))


setup(
name='ufjc',
version='1.3.1',
version=get_version(),
package_dir={'ufjc': 'ufjc'},
packages=find_packages(),
description='The Python package for the uFJC single-chain model.',
Expand Down
2 changes: 2 additions & 0 deletions ufjc/__init__.py
@@ -1,2 +1,4 @@
from .core import *
from .swfjc import *

__version__ = "1.3.1"

0 comments on commit 7e695f0

Please sign in to comment.