Skip to content

Commit

Permalink
put version.h in hpy/devel, and generate also a corresponding version.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antocuni committed Sep 8, 2020
1 parent 8a43ccd commit 46f151a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
hpy/tools/autogen/autogen_pypy.txt

# generated by setup.py:get_scm_config()
hpy/universal/src/version.h
hpy/devel/include/common/version.h
hpy/devel/version.py

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion hpy/universal/src/hpymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "api.h"
#include "handles.h"
#include "version.h"
#include "common/version.h"

typedef HPy (*InitFuncPtr)(HPyContext ctx);

Expand Down
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ def get_scm_config():
gitrev = subprocess.check_output('git describe --abbrev=7 --dirty '
'--always --tags --long'.split(), encoding='utf-8')
gitrev = gitrev.strip()
version_h = pathlib.Path('.').joinpath('hpy', 'universal', 'src', 'version.h')
version_h = pathlib.Path('.').joinpath('hpy', 'devel', 'include', 'common', 'version.h')
version_h.write_text(textwrap.dedent(f"""
// automatically generated by setup.py:get_scm_config()
#define HPY_VERSION "{version}"
#define HPY_GIT_REVISION "{gitrev}"
"""))

version_py = pathlib.Path('.').joinpath('hpy', 'devel', 'version.py')
version_py.write_text(textwrap.dedent(f"""
# automatically generated by setup.py:get_scm_config()
__version__ = "{version}"
__git_revision__ = "{gitrev}"
"""))

return {} # use the default config

setup(
Expand Down

0 comments on commit 46f151a

Please sign in to comment.