Skip to content

Commit fb97854

Browse files
Publish last commit information (#286)
* Trial without conditional run * Missing "with" * Better to unify all pre-commit operations in one place * Bug on configuration key used * Bug - Add echo in command * Select files on where to apply pre-commit * Remove bash -c * Bash script approach * Reverting pre-commit approach... * Commit to your own branch on every push - main branch is protected * Append last commit information to README (and thus to PKG-INFO) * LAST_COMMIT Variable creation * Adapt Makefile * Doc for global variable * Modify output way - via method version_info() * Rename Makefile target from last-commit-info to version-info * Missing field to adapt * Single underscore for _VERSION_INFO * Return __version__ if undefined _VERSION_INFO * Apply suggestions from code review Co-authored-by: Jorge Martínez <[email protected]> * Adding extra line - style check * Minor modification to NB statement * Change location * Remove spaces Co-authored-by: Jorge Martínez <[email protected]>
1 parent f55c4c9 commit fb97854

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ jobs:
181181
- name: Install pyvistaqt requirements
182182
run: make install-pyvistaqt-requirements
183183

184+
- name: Add version information
185+
run: make version-info
186+
184187
- name: Install pyfluent with post requirements
185188
run: make install-post
186189

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ install:
88
@python setup.py bdist_wheel
99
@pip install dist/*.whl
1010

11+
version-info:
12+
@bash -c "date -u +'Build date: %B %d, %Y %H:%M UTC ShaID: <id>' | xargs -I date sed -i 's/_VERSION_INFO = .*/_VERSION_INFO = \"date\"/g' ansys/fluent/core/__init__.py"
13+
@bash -c "git --no-pager log -n 1 --format='%h' | xargs -I hash sed -i 's/<id>/hash/g' ansys/fluent/core/__init__.py"
14+
1115
install-post:
1216
@pip install -r requirements_build.txt
1317
@python setup.py sdist

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ to the Fluent without changing the core behavior or license of the original
9898
software. The use of the interactive Fluent control of ``PyFluent`` requires a
9999
legally licensed local copy of Ansys.
100100

101-
To get a copy of Ansys, please visit `Ansys <https://www.ansys.com/>`_.
101+
To get a copy of Ansys, please visit `Ansys <https://www.ansys.com/>`_.

ansys/fluent/core/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@
1818
except ImportError:
1919
pass
2020

21+
_VERSION_INFO = None
22+
"""Global variable indicating the version of the PyFluent package - Empty by default"""
23+
24+
25+
def version_info():
26+
"""Method returning the version of PyFluent being used.
27+
28+
Returns
29+
-------
30+
str
31+
The PyFluent version being used.
32+
33+
Notes
34+
-------
35+
Only available in packaged versions. Otherwise it will return __version__.
36+
"""
37+
return _VERSION_INFO if _VERSION_INFO is not None else __version__
38+
2139

2240
def set_log_level(level):
2341
"""Set logging level.

0 commit comments

Comments
 (0)