Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gregory Ashton
PyFstat
Commits
4f7a96d4
Commit
4f7a96d4
authored
Jan 27, 2020
by
David Keitel
Browse files
Merge branch 'add-version-information' into 'master'
Improve the version file information See merge request
!29
parents
bdb897f1
ebb26369
Changes
3
Hide whitespace changes
Inline
Side-by-side
pyfstat/__init__.py
View file @
4f7a96d4
...
...
@@ -26,3 +26,8 @@ from .grid_based_searches import (
SliceGridSearch
,
TransientGridSearch
,
)
from
.helper_functions
import
get_version_information
__version__
=
get_version_information
()
pyfstat/helper_functions.py
View file @
4f7a96d4
...
...
@@ -390,3 +390,14 @@ def match_commandlines(cl1, cl2, be_strict_about_full_executable_path=False):
cl2s
[
0
]
=
os
.
path
.
basename
(
cl2s
[
0
])
unmatched
=
np
.
setxor1d
(
cl1s
,
cl2s
)
return
len
(
unmatched
)
==
0
def
get_version_information
():
version_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)),
"pyfstat/.version"
)
try
:
with
open
(
version_file
,
"r"
)
as
f
:
return
f
.
readline
().
rstrip
()
except
EnvironmentError
:
print
(
"No version information file '.version' found"
)
setup.py
View file @
4f7a96d4
...
...
@@ -3,6 +3,47 @@
from
setuptools
import
setup
,
find_packages
from
os
import
path
import
sys
import
subprocess
def
write_version_file
(
version
):
""" Writes a file with version information to be used at run time
Parameters
----------
version: str
A string containing the current version information
Returns
-------
version_file: str
A path to the version file
"""
try
:
git_log
=
subprocess
.
check_output
(
[
"git"
,
"log"
,
"-1"
,
"--pretty=%h %ai"
]
).
decode
(
"utf-8"
)
git_diff
=
(
subprocess
.
check_output
([
"git"
,
"diff"
,
"."
])
+
subprocess
.
check_output
([
"git"
,
"diff"
,
"--cached"
,
"."
])
).
decode
(
"utf-8"
)
if
git_diff
==
""
:
git_status
=
"(CLEAN) "
+
git_log
else
:
git_status
=
"(UNCLEAN) "
+
git_log
except
Exception
as
e
:
print
(
"Unable to obtain git version information, exception: {}"
.
format
(
e
))
git_status
=
""
version_file
=
".version"
if
path
.
isfile
(
version_file
)
is
False
:
with
open
(
"pyfstat/"
+
version_file
,
"w+"
)
as
f
:
f
.
write
(
"{}: {}"
.
format
(
version
,
git_status
))
print
(
"Done"
,
version_file
,
version
,
git_status
)
return
version_file
# check python version
min_python_version
=
(
3
,
5
,
0
)
# (major,minor,micro)
...
...
@@ -21,9 +62,12 @@ here = path.abspath(path.dirname(__file__))
with
open
(
path
.
join
(
here
,
"README.md"
),
encoding
=
"utf-8"
)
as
f
:
long_description
=
f
.
read
()
VERSION
=
"1.3"
version_file
=
write_version_file
(
VERSION
)
setup
(
name
=
"PyFstat"
,
version
=
"1.3"
,
version
=
VERSION
,
author
=
"Gregory Ashton, David Keitel, Reinhard Prix"
,
author_email
=
"gregory.ashton@ligo.org"
,
license
=
"MIT"
,
...
...
@@ -36,6 +80,7 @@ setup(
"pyfstat"
:
[
"pyCUDAkernels/cudaTransientFstatExpWindow.cu"
,
"pyCUDAkernels/cudaTransientFstatRectWindow.cu"
,
version_file
,
]
},
python_requires
=
">=%s.%s.%s"
%
min_python_version
[:
3
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment