Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joseph Weston
kwant
Commits
0c85ed62
Commit
0c85ed62
authored
9 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
setup.py: get rid of duplication of get_version_from_git
parent
aa7fcf46
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kwant/_common.py
+0
-1
0 additions, 1 deletion
kwant/_common.py
setup.py
+8
-46
8 additions, 46 deletions
setup.py
with
8 additions
and
47 deletions
kwant/_common.py
+
0
−
1
View file @
0c85ed62
...
...
@@ -13,7 +13,6 @@ __all__ = ['version', 'KwantDeprecationWarning']
distr_root
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)))
# When changing this function, remember to also change its twin in ../setup.py.
def
get_version_from_git
():
try
:
p
=
subprocess
.
Popen
([
'
git
'
,
'
rev-parse
'
,
'
--show-toplevel
'
],
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
8
−
46
View file @
0c85ed62
...
...
@@ -14,6 +14,7 @@ import sys
import
re
import
os
import
glob
import
imp
import
subprocess
import
ConfigParser
from
distutils.core
import
setup
,
Extension
,
Command
...
...
@@ -25,6 +26,11 @@ from distutils.command.sdist import sdist as distutils_sdist
import
numpy
_dont_write_bytecode_saved
=
sys
.
dont_write_bytecode
sys
.
dont_write_bytecode
=
True
kwant_common
=
imp
.
load_source
(
'
kwant_common
'
,
'
kwant/_common.py
'
)
sys
.
dont_write_bytecode
=
_dont_write_bytecode_saved
CONFIG_FILE
=
'
build.conf
'
README_FILE
=
'
README.rst
'
README_END_BEFORE
=
'
See also in this directory:
'
...
...
@@ -226,53 +232,9 @@ with a comment). It may well be incomplete.""",
banner
(),
sep
=
'
\n
'
,
file
=
sys
.
stderr
)
# Other than the "if not use_git" clause in the beginning, this is an exact copy
# of the function from kwant/_common.py. We can't import it here (because Kwant
# is not yet built when this scipt is run), so we just include a copy.
def
get_version_from_git
():
if
not
use_git
:
return
try
:
p
=
subprocess
.
Popen
([
'
git
'
,
'
rev-parse
'
,
'
--show-toplevel
'
],
cwd
=
distr_root
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
except
OSError
:
return
if
p
.
wait
()
!=
0
:
return
# TODO: use os.path.samefile once we depend on Python >= 3.3.
if
os
.
path
.
normpath
(
p
.
communicate
()[
0
].
rstrip
(
'
\n
'
))
!=
distr_root
:
# The top-level directory of the current Git repository is not the same
# as the root directory of the Kwant distribution: do not extract the
# version from Git.
return
# git describe --first-parent does not take into account tags from branches
# that were merged-in.
for
opts
in
[[
'
--first-parent
'
],
[]]:
try
:
p
=
subprocess
.
Popen
([
'
git
'
,
'
describe
'
]
+
opts
,
cwd
=
distr_root
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
except
OSError
:
return
if
p
.
wait
()
==
0
:
break
else
:
return
version
=
p
.
communicate
()[
0
].
rstrip
(
'
\n
'
)
if
version
[
0
]
==
'
v
'
:
version
=
version
[
1
:]
try
:
p
=
subprocess
.
Popen
([
'
git
'
,
'
diff
'
,
'
--quiet
'
],
cwd
=
distr_root
)
except
OSError
:
version
+=
'
-confused
'
# This should never happen.
else
:
if
p
.
wait
()
==
1
:
version
+=
'
-dirty
'
return
version
if
use_git
:
return
kwant_common
.
get_version_from_git
()
def
read_static_version
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment