Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
adaptive
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
Container Registry
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Quantum Tinkerer
adaptive
Commits
3a69cd99
Commit
3a69cd99
authored
6 years ago
by
Bas Nijholt
Browse files
Options
Downloads
Patches
Plain Diff
update to the latest miniver
parent
91ff6476
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!125
update to the latest miniver
Pipeline
#12769
passed
6 years ago
Stage: test
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
adaptive/__init__.py
+2
-3
2 additions, 3 deletions
adaptive/__init__.py
adaptive/_static_version.py
+4
-2
4 additions, 2 deletions
adaptive/_static_version.py
adaptive/_version.py
+53
-26
53 additions, 26 deletions
adaptive/_version.py
setup.py
+3
-3
3 additions, 3 deletions
setup.py
with
62 additions
and
34 deletions
adaptive/__init__.py
+
2
−
3
View file @
3a69cd99
...
...
@@ -17,9 +17,8 @@ with suppress(ImportError):
from
.learner
import
SKOptLearner
from
.runner
import
Runner
,
BlockingRunner
from
.
import
version
__version__
=
version
.
version
from
._version
import
__version__
del
_version
del
notebook_integration
# to avoid confusion with `notebook_extension`
del
version
This diff is collapsed.
Click to expand it.
adaptive/_static_version.py
+
4
−
2
View file @
3a69cd99
# This file is part of 'miniver': https://github.com/jbweston/miniver
#
# This file will be overwritten by setup.py when a source or binary
# distribution is made. The magic value "__use_git__" is interpreted by
# version.py.
#
_
version.py.
version
=
"
__use_git__
"
# These values are only set if the distribution was created with 'git archive'
refnames
=
"
$Format:%D$
"
refnames
=
"
$Format:%D$
"
git_hash
=
"
$Format:%h$
"
This diff is collapsed.
Click to expand it.
adaptive/version.py
→
adaptive/
_
version.py
+
53
−
26
View file @
3a69cd99
# -*- coding: utf-8 -*-
# This file is part of 'miniver': https://github.com/jbweston/miniver
#
from
collections
import
namedtuple
import
os
import
subprocess
import
sys
from
distutils.command.build
import
build
as
build_orig
from
distutils.command.build
_py
import
build
_py
as
build_
py_
orig
from
setuptools.command.sdist
import
sdist
as
sdist_orig
Version
=
namedtuple
(
'
Version
'
,
(
'
release
'
,
'
dev
'
,
'
labels
'
))
...
...
@@ -19,31 +21,39 @@ STATIC_VERSION_FILE = '_static_version.py'
def
get_version
(
version_file
=
STATIC_VERSION_FILE
):
version_info
=
{}
with
open
(
os
.
path
.
join
(
package_root
,
version_file
),
'
rb
'
)
as
f
:
exec
(
f
.
read
(),
{},
version_info
)
version_info
=
get_static_version_info
(
version_file
)
version
=
version_info
[
'
version
'
]
version_is_from_git
=
(
version
==
"
__use_git__
"
)
if
version_is_from_git
:
if
version
==
"
__use_git__
"
:
version
=
get_version_from_git
()
if
not
version
:
version
=
get_version_from_git_archive
(
version_info
)
if
not
version
:
version
=
Version
(
"
unknown
"
,
None
,
None
)
return
semver
_format
(
version
)
return
pep440
_format
(
version
)
else
:
return
version
def
semver_format
(
version_info
):
def
get_static_version_info
(
version_file
=
STATIC_VERSION_FILE
):
version_info
=
{}
with
open
(
os
.
path
.
join
(
package_root
,
version_file
),
'
rb
'
)
as
f
:
exec
(
f
.
read
(),
{},
version_info
)
return
version_info
def
version_is_from_git
(
version_file
=
STATIC_VERSION_FILE
):
return
get_static_version_info
(
version_file
)[
'
version
'
]
==
'
__use_git__
'
def
pep440_format
(
version_info
):
release
,
dev
,
labels
=
version_info
version_parts
=
[
release
]
if
dev
:
if
release
.
endswith
(
'
-dev
'
):
if
release
.
endswith
(
'
-dev
'
)
or
release
.
endswith
(
'
.dev
'
)
:
version_parts
.
append
(
dev
)
else
:
version_parts
.
append
(
'
-
dev{}
'
.
format
(
dev
))
else
:
# prefer PEP440 over strict adhesion to semver
version_parts
.
append
(
'
.
dev{}
'
.
format
(
dev
))
if
labels
:
version_parts
.
append
(
'
+
'
)
...
...
@@ -64,26 +74,42 @@ def get_version_from_git():
if
not
os
.
path
.
samefile
(
p
.
communicate
()[
0
].
decode
().
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
# as the root directory of the 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.
# that were merged-in. The '--long' flag gets us the 'dev' version and
# git hash, '--always' returns the git hash even if there are no tags.
for
opts
in
[[
'
--first-parent
'
],
[]]:
try
:
p
=
subprocess
.
Popen
([
'
git
'
,
'
describe
'
,
'
--long
'
]
+
opts
,
cwd
=
distr_root
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
p
=
subprocess
.
Popen
(
[
'
git
'
,
'
describe
'
,
'
--long
'
,
'
--always
'
]
+
opts
,
cwd
=
distr_root
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
except
OSError
:
return
if
p
.
wait
()
==
0
:
break
else
:
return
description
=
p
.
communicate
()[
0
].
decode
().
strip
(
'
v
'
).
rstrip
(
'
\n
'
)
release
,
dev
,
git
=
description
.
rsplit
(
'
-
'
,
2
)
description
=
(
p
.
communicate
()[
0
]
.
decode
()
.
strip
(
'
v
'
)
# Tags can have a leading 'v', but the version should not
.
rstrip
(
'
\n
'
)
.
rsplit
(
'
-
'
,
2
)
# Split the latest tag, commits since tag, and hash
)
try
:
release
,
dev
,
git
=
description
except
ValueError
:
# No tags, only the git hash
# prepend 'g' to match with format returned by 'git describe'
git
=
'
g{}
'
.
format
(
*
description
)
release
=
'
unknown
'
dev
=
None
labels
=
[]
if
dev
==
"
0
"
:
dev
=
None
...
...
@@ -93,7 +119,7 @@ def get_version_from_git():
try
:
p
=
subprocess
.
Popen
([
'
git
'
,
'
diff
'
,
'
--quiet
'
],
cwd
=
distr_root
)
except
OSError
:
labels
.
append
(
'
confused
'
)
# This should never happen.
labels
.
append
(
'
confused
'
)
# This should never happen.
else
:
if
p
.
wait
()
==
1
:
labels
.
append
(
'
dirty
'
)
...
...
@@ -126,14 +152,15 @@ def get_version_from_git_archive(version_info):
release
,
*
_
=
sorted
(
version_tags
)
# prefer e.g. "2.0" over "2.0rc1"
return
Version
(
release
,
dev
=
None
,
labels
=
None
)
else
:
return
Version
(
'
unknown
'
,
dev
=
None
,
labels
=
[
f
'
g
{
git_hash
}
'
])
return
Version
(
'
unknown
'
,
dev
=
None
,
labels
=
[
'
g{}
'
.
format
(
git_hash
)])
__version__
=
get_version
()
version
=
get_version
()
# The following section defines a module global 'cmdclass',
# which can be used from setup.py. The 'package_name' and
# 'version' module globals are used (but not modified).
# '
__
version
__
' module globals are used (but not modified).
def
_write_version
(
fname
):
# This could be a hard link, so try to delete it first. Is there any way
...
...
@@ -144,10 +171,10 @@ def _write_version(fname):
pass
with
open
(
fname
,
'
w
'
)
as
f
:
f
.
write
(
"
# This file has been created by setup.py.
\n
"
"
version =
'
{}
'
\n
"
.
format
(
version
))
"
version =
'
{}
'
\n
"
.
format
(
__
version
__
))
class
_build
(
build_orig
):
class
_build
_py
(
build_
py_
orig
):
def
run
(
self
):
super
().
run
()
_write_version
(
os
.
path
.
join
(
self
.
build_lib
,
package_name
,
...
...
@@ -161,4 +188,4 @@ class _sdist(sdist_orig):
STATIC_VERSION_FILE
))
cmdclass
=
dict
(
sdist
=
_sdist
,
build
=
_build
)
cmdclass
=
dict
(
sdist
=
_sdist
,
build
_py
=
_build
_py
)
This diff is collapsed.
Click to expand it.
setup.py
+
3
−
3
View file @
3a69cd99
...
...
@@ -10,15 +10,15 @@ if sys.version_info < (3, 6):
sys
.
exit
(
1
)
# Loads version.py module without importing the whole package.
# Loads
_
version.py module without importing the whole package.
def
get_version_and_cmdclass
(
package_name
):
import
os
from
importlib.util
import
module_from_spec
,
spec_from_file_location
spec
=
spec_from_file_location
(
'
version
'
,
os
.
path
.
join
(
package_name
,
'
version.py
'
))
os
.
path
.
join
(
package_name
,
'
_
version.py
'
))
module
=
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
return
module
.
version
,
module
.
cmdclass
return
module
.
__
version
__
,
module
.
cmdclass
version
,
cmdclass
=
get_version_and_cmdclass
(
'
adaptive
'
)
...
...
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