Skip to content

Commit 6c84983

Browse files
committed
added git hash to binaries
1 parent de6647e commit 6c84983

12 files changed

+45
-19
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. image:: http://img.shields.io/badge/REBOUNDx-v2.15.0-green.svg?style=flat
1+
.. image:: http://img.shields.io/badge/REBOUNDx-v2.15.1-green.svg?style=flat
22
:target: http://reboundx.readthedocs.org
33
.. image:: https://badge.fury.io/py/reboundx.svg
44
:target: https://badge.fury.io/py/reboundx

doc/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def cleanline(line):
205205
# The short X.Y version.
206206
version = '2.15'
207207
# The full version, including alpha/beta/rc tags.
208-
release = '2.15.0'
208+
release = '2.15.1'
209209

210210
# The language for content autogenerated by Sphinx. Refer to documentation
211211
# for a list of supported languages.

doc/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
Welcome to REBOUNDx (2.15.0)
6+
Welcome to REBOUNDx (2.15.1)
77
============================
88

99
.. image:: images/hlTau.png

reboundx/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
__build__ = c_char_p.in_dll(clibreboundx, "rebx_build_str").value.decode('ascii')
2020
# Check for version
2121

22+
# Githash
23+
__githash__ = c_char_p.in_dll(clibrebound, "reb_githash_str").value.decode('ascii')
24+
2225
try:
2326
moduleversion = pkg_resources.require("reboundx")[0].version
2427
libreboundxversion = __version__
@@ -40,4 +43,4 @@ def params(self):
4043
from .extras import Extras, Param, Effect
4144
from .tools import coordinates, install_test
4245
from .params import Params
43-
__all__ = ["Extras", "Param", "Effect", "Params", "coordinates", "install_test"]
46+
__all__ = ["__version__", "__build__", "__githash__", "Extras", "Param", "Effect", "Params", "coordinates", "install_test"]

setup.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
if suffix is None:
1616
suffix = ".so"
1717

18+
# Try to get git hash
19+
try:
20+
import subprocess
21+
ghash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii")
22+
ghash_arg = "-DREBXGITHASH="+ghash
23+
except:
24+
ghash_arg = "-DREBXGITHASH=de6647e2b083fc91472d636355512ada02b9f3f6" #GITHASHAUTOUPDATE
25+
1826
class build_ext(_build_ext):
1927
def finalize_options(self):
2028
_build_ext.finalize_options(self)
@@ -53,7 +61,7 @@ def finalize_options(self):
5361
runtime_library_dirs = ["."],
5462
libraries=['rebound'+suffix[:-3]], #take off .so from the suffix
5563
define_macros=[ ('LIBREBOUNDX', None) ],
56-
extra_compile_args=['-fstrict-aliasing', '-O3','-std=c99','-march=native', '-fPIC', '-Wpointer-arith'],
64+
extra_compile_args=['-fstrict-aliasing', '-O3','-std=c99','-march=native', ghash_arg, '-fPIC', '-Wpointer-arith'],
5765
extra_link_args=extra_link_args,
5866
)
5967

@@ -62,7 +70,7 @@ def finalize_options(self):
6270
long_description = f.read()
6371

6472
setup(name='reboundx',
65-
version='2.15.0',
73+
version='2.15.1',
6674
description='A library for including additional forces in REBOUND',
6775
long_description=long_description,
6876
url='http://github.com/dtamayo/reboundx',

src/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ endif
1717
include $(REB_DIR)/src/Makefile.defs
1818
OPT+= -fPIC -DLIBREBOUNDX
1919

20+
ifndef REBXGITHASH
21+
REBXGITHASH = $(shell git rev-parse HEAD || echo '0000000000gitnotfound0000000000000000000')
22+
PREDEF+= -DREBXGITHASH=$(REBXGITHASH)
23+
endif
24+
2025
SOURCES=central_force.c core.c gr.c gr_full.c gr_potential.c input.c modify_mass.c modify_orbits_direct.c modify_orbits_forces.c output.c radiation_forces.c rebxtools.c tides_precession.c track_min_distance.c
2126
OBJECTS=$(SOURCES:.c=.o)
2227
HEADERS=rebxtools.h reboundx.h

src/core.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@
3232
#include <limits.h>
3333
#include "core.h"
3434
#include "rebound.h"
35+
#define STRINGIFY(s) str(s)
36+
#define str(s) #s
3537

3638
const char* rebx_build_str = __DATE__ " " __TIME__; // Date and time build string.
37-
const char* rebx_version_str = "2.15.0"; // **VERSIONLINE** This line gets updated automatically. Do not edit manually.
39+
const char* rebx_version_str = "2.15.1"; // **VERSIONLINE** This line gets updated automatically. Do not edit manually.
40+
const char* rebx_githash_str = STRINGIFY(GITHASH); // This line gets updated automatically. Do not edit manually.
3841

3942
/*****************************
4043
Initialization routines.

src/input.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,14 @@ void rebx_create_extras_from_binary_with_messages(struct rebx_extras* rebx, cons
196196
long objects = 0;
197197
// Input header.
198198
const char str[] = "REBOUNDx Binary File. Version: ";
199+
const char zero = '\0';
199200
char readbuf[65], curvbuf[65];
200201
sprintf(curvbuf,"%s%s",str,rebx_version_str);
201-
for(size_t j=strlen(curvbuf);j<63;j++){
202-
curvbuf[j] = ' ';
203-
}
204-
curvbuf[63] = '\0';
202+
memcpy(curvbuf+strlen(curvbuf)+1,rebx_githash_str,sizeof(char)*(62-strlen(curvbuf)));
203+
curvbuf[63] = zero;
204+
205205
objects += fread(readbuf,sizeof(*str),64,inf);
206+
// Note: following compares version, but ignores githash.
206207
if(strcmp(readbuf,curvbuf)!=0){
207208
*warnings |= REBX_INPUT_BINARY_WARNING_VERSION;
208209
}

src/output.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,13 @@ void rebx_output_binary(struct rebx_extras* rebx, char* filename){
131131

132132
// Output header.
133133
const char str[] = "REBOUNDx Binary File. Version: ";
134+
char zero = '\0';
134135
size_t lenheader = strlen(str)+strlen(rebx_version_str);
135136
fwrite(str,sizeof(char),strlen(str),of);
136137
fwrite(rebx_version_str,sizeof(char), strlen(rebx_version_str),of);
137-
while (lenheader<64){ //padding
138-
char space = ' ';
139-
if (lenheader==63) space = '\0';
140-
fwrite(&space,sizeof(char),1,of);
141-
lenheader += 1;
142-
}
138+
fwrite(&zero,sizeof(char),1,of);
139+
fwrite(rebx_githash_str,sizeof(char),62-lenheader,of);
140+
fwrite(&zero,sizeof(char),1,of);
143141

144142
int neffects=0;
145143
struct rebx_effect* current = rebx->effects;
@@ -164,4 +162,4 @@ void rebx_output_binary(struct rebx_extras* rebx, char* filename){
164162
// Write end marker for binary
165163
REBX_WRITE_FIELD(END, NULL, 0, 0);
166164
fclose(of);
167-
}
165+
}

src/reboundx.h

+4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
#include <limits.h>
3535
#include "rebound.h"
3636
#include "rebxtools.h"
37+
#ifndef REBXGITHASH
38+
#define REBXGITHASH notavailable0000000000000000000000000001
39+
#endif // REBXGITHASH
3740

3841
extern const char* rebx_build_str; ///< Date and time build string.
3942
extern const char* rebx_version_str; ///<Version string.
43+
extern const char* rebx_githash_str; ///< Current git hash.
4044

4145
/******************************************
4246
REBOUNDx Enums

update_version.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/python
22
# This script automatically creates a list of examples by reading the header in all problem.c files.
33
import glob
4+
import subprocess
5+
ghash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip()
46

57
with open("version.txt") as f:
68
reboundxversion = f.readlines()[0].strip()
@@ -43,6 +45,8 @@
4345
for i,l in enumerate(setuplines):
4446
if "version='" in l:
4547
setuplines[i] = " version='"+reboundxversion+"',\n"
48+
if "GITHASHAUTOUPDATE" in l:
49+
setuplines[i] = " ghash_arg = \"-DREBXGITHASH="+ghash+"\" #GITHASHAUTOUPDATE\n"
4650

4751
with open("setup.py", "w") as f:
4852
f.writelines(setuplines)

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.15.0
1+
2.15.1

0 commit comments

Comments
 (0)