Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TopFarm2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Show more breadcrumbs
TOPFARM
TopFarm2
Commits
641f6121
Commit
641f6121
authored
6 years ago
by
Mikkel Friis-Møller
Browse files
Options
Downloads
Patches
Plain Diff
version is filled when setup.py is run
parent
46ca5177
No related branches found
Branches containing commit
Tags
v2.0.4
Tags containing commit
1 merge request
!91
version is filled when setup.py is run
Pipeline
#6864
passed
6 years ago
Stage: test
Stage: deploy
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
git_utils.py
+97
-0
97 additions, 0 deletions
git_utils.py
setup.py
+5
-1
5 additions, 1 deletion
setup.py
topfarm/__init__.py
+2
-2
2 additions, 2 deletions
topfarm/__init__.py
with
104 additions
and
3 deletions
git_utils.py
0 → 100644
+
97
−
0
View file @
641f6121
'''
Created on 28. jul. 2017
@author: mmpe
'''
import
os
import
subprocess
def
_run_git_cmd
(
cmd
,
git_repo_path
=
None
):
git_repo_path
=
git_repo_path
or
os
.
getcwd
()
if
not
os
.
path
.
isdir
(
os
.
path
.
join
(
git_repo_path
,
"
.git
"
)):
raise
Warning
(
"'
%s
'
does not appear to be a Git repository.
"
%
git_repo_path
)
try
:
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
universal_newlines
=
True
,
cwd
=
os
.
path
.
abspath
(
git_repo_path
))
stdout
,
stderr
=
process
.
communicate
()
if
process
.
returncode
!=
0
:
raise
EnvironmentError
(
"
%s
\n
%s
"
%
(
stdout
,
stderr
))
return
stdout
.
strip
()
except
EnvironmentError
as
e
:
raise
e
raise
Warning
(
"
unable to run git
"
)
def
get_git_version
(
git_repo_path
=
None
):
cmd
=
[
"
git
"
,
"
describe
"
,
"
--tags
"
,
"
--dirty
"
,
"
--always
"
]
return
_run_git_cmd
(
cmd
,
git_repo_path
)
def
get_tag
(
git_repo_path
=
None
,
verbose
=
False
):
tag
=
_run_git_cmd
([
'
git
'
,
'
describe
'
,
'
--tags
'
,
'
--always
'
,
'
--abbrev=0
'
],
git_repo_path
)
if
verbose
:
print
(
tag
)
return
tag
def
set_tag
(
tag
,
push
,
git_repo_path
=
None
):
_run_git_cmd
([
"
git
"
,
"
tag
"
,
tag
],
git_repo_path
)
if
push
:
_run_git_cmd
([
"
git
"
,
"
push
"
],
git_repo_path
)
_run_git_cmd
([
"
git
"
,
"
push
"
,
"
--tags
"
],
git_repo_path
)
def
update_git_version
(
version_module
,
git_repo_path
=
None
):
"""
Update <version_module>.__version__ to git version
"""
version_str
=
get_git_version
(
git_repo_path
)
assert
os
.
path
.
isfile
(
version_module
.
__file__
)
with
open
(
version_module
.
__file__
,
"
w
"
)
as
fid
:
fid
.
write
(
"
__version__ =
'
%s
'"
%
version_str
)
# ensure file is written, closed and ready
with
open
(
version_module
.
__file__
)
as
fid
:
fid
.
read
()
return
version_str
def
write_vers
(
vers_file
=
'
wetb/__init__.py
'
,
repo
=
None
,
skip_chars
=
1
):
if
not
repo
:
repo
=
os
.
getcwd
()
version
=
get_tag
(
repo
)[
skip_chars
:]
print
(
'
Writing version: {} in {}
'
.
format
(
version
,
vers_file
))
with
open
(
vers_file
,
'
r
'
)
as
f
:
lines
=
f
.
readlines
()
for
n
,
l
in
enumerate
(
lines
):
if
l
.
startswith
(
'
__version__
'
):
lines
[
n
]
=
"
__version__ =
'
{}
'
\n
"
.
format
(
version
)
for
n
,
l
in
enumerate
(
lines
):
if
l
.
startswith
(
'
__release__
'
):
lines
[
n
]
=
"
__release__ =
'
{}
'
\n
"
.
format
(
version
)
with
open
(
vers_file
,
'
w
'
)
as
f
:
f
.
write
(
''
.
join
(
lines
))
return
version
def
rename_dist_file
():
for
f
in
os
.
listdir
(
'
dist
'
):
if
f
.
endswith
(
'
whl
'
):
split
=
f
.
split
(
'
linux
'
)
new_name
=
'
manylinux1
'
.
join
(
split
)
old_path
=
os
.
path
.
join
(
'
dist
'
,
f
)
new_path
=
os
.
path
.
join
(
'
dist
'
,
new_name
)
os
.
rename
(
old_path
,
new_path
)
def
main
():
"""
Example of how to run (pytest-friendly)
"""
if
__name__
==
'
__main__
'
:
pass
main
()
This diff is collapsed.
Click to expand it.
setup.py
+
5
−
1
View file @
641f6121
...
@@ -5,13 +5,17 @@ Setup file for Topfarm2
...
@@ -5,13 +5,17 @@ Setup file for Topfarm2
import
os
import
os
from
git_utils
import
write_vers
from
setuptools
import
setup
,
find_packages
from
setuptools
import
setup
,
find_packages
repo
=
os
.
path
.
dirname
(
__file__
)
version
=
write_vers
(
vers_file
=
'
topfarm/__init__.py
'
,
repo
=
repo
,
skip_chars
=
1
)
def
read
(
fname
):
def
read
(
fname
):
return
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
fname
)).
read
()
return
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
fname
)).
read
()
setup
(
name
=
'
topfarm
'
,
setup
(
name
=
'
topfarm
'
,
version
=
'
2.0.3
'
,
version
=
version
,
description
=
'
Topfarm - Wind farm optimization using OpenMDAO
'
,
description
=
'
Topfarm - Wind farm optimization using OpenMDAO
'
,
long_description
=
read
(
'
README
'
),
long_description
=
read
(
'
README
'
),
url
=
'
https://gitlab.windenergy.dtu.dk/TOPFARM/topfarm2
'
,
url
=
'
https://gitlab.windenergy.dtu.dk/TOPFARM/topfarm2
'
,
...
...
This diff is collapsed.
Click to expand it.
topfarm/__init__.py
+
2
−
2
View file @
641f6121
from
._topfarm
import
*
from
._topfarm
import
*
from
.deprectated_topfarm_problems
import
*
from
.deprectated_topfarm_problems
import
*
__version__
=
'
2.0.3
'
__version__
=
'
filled by setup.py
'
__release__
=
'
2.0.3
'
__release__
=
'
filled by setup.py
'
x_key
=
'
x
'
x_key
=
'
x
'
...
...
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