Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fossils
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Boman Romain
fossils
Commits
7f07fe7f
Commit
7f07fe7f
authored
2 years ago
by
Boman Romain
Browse files
Options
Downloads
Patches
Plain Diff
fix path problems
parent
ce4885e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7088
passed
2 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fossils.py
+41
-17
41 additions, 17 deletions
fossils.py
with
41 additions
and
17 deletions
fossils.py
+
41
−
17
View file @
7f07fe7f
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Fossils:
# main script
from
PyQt5.QtCore
import
*
from
PyQt5.QtGui
import
*
...
...
@@ -116,48 +118,66 @@ def view_results():
gmsh
.
fltk
.
run
()
def
rm_folder_from_pypath
(
folder
):
sys
.
path
=
[
p
for
p
in
sys
.
path
if
not
folder
in
p
]
def
add_folder2pypath
(
folder
):
if
os
.
path
.
isdir
(
folder
):
print
(
f
'
{
folder
}
added to pythonpath
'
)
sys
.
path
.
append
(
folder
)
def
rm_folder_from_path
(
folder
):
import
platform
if
'
Windows
'
in
platform
.
uname
():
path
=
[
p
for
p
in
os
.
environ
[
'
PATH
'
].
split
(
'
;
'
)
if
not
folder
in
p
]
os
.
environ
[
'
PATH
'
]
=
'
;
'
.
join
(
path
)
# print(f'{folder} added to PATH')
# print(f"os.environ['PATH']={os.environ['PATH']}")
def
add_folder2path
(
folder
):
if
not
os
.
path
.
isdir
(
folder
):
return
import
platform
if
'
Windows
'
in
platform
.
uname
():
path
=
os
.
environ
[
'
PATH
'
].
split
(
'
;
'
)
path
.
insert
(
0
,
folder
)
# path.insert(0, folder)
path
.
append
(
folder
)
os
.
environ
[
'
PATH
'
]
=
'
;
'
.
join
(
path
)
print
(
f
'
{
folder
}
added to PATH
'
)
# print(f"os.environ['PATH']={os.environ['PATH']}")
def
setup_pythonpath
():
"""
setup PYTHONPATH
"""
# adds script folder to the pythonpath
thisdir
=
os
.
path
.
split
(
os
.
path
.
abspath
(
__file__
))[
0
]
thisdir
=
os
.
path
.
normcase
(
thisdir
)
add_folder2pypath
(
this
dir
)
this
_script_
dir
=
os
.
path
.
split
(
os
.
path
.
abspath
(
__file__
))[
0
]
this
_script_
dir
=
os
.
path
.
normcase
(
this
_script_
dir
)
#
add_folder2pypath(this
_script_dir) # already there as first entry
# add binary dir to PYTHONPATH
pyexe
=
os
.
path
.
basename
(
sys
.
executable
)
print
(
f
'
pyexe =
{
pyexe
}
'
)
add_folder2pypath
(
os
.
path
.
join
(
thisdir
,
'
cxxfem
'
,
add_folder2pypath
(
os
.
path
.
join
(
this
_script_
dir
,
'
cxxfem
'
,
'
build
'
,
'
bin
'
))
# gcc/mingw
add_folder2pypath
(
os
.
path
.
join
(
thisdir
,
'
cxxfem
'
,
add_folder2pypath
(
os
.
path
.
join
(
this
_script_
dir
,
'
cxxfem
'
,
'
build
'
,
'
bin
'
,
'
Release
'
))
# msvc
# allows this script to be run without setting env
add_folder2pypath
(
os
.
path
.
join
(
thisdir
,
'
lib
'
,
# allows this script to be run without setting env
rm_folder_from_path
(
'
gmsh
'
)
rm_folder_from_pypath
(
'
gmsh
'
)
add_folder2pypath
(
os
.
path
.
join
(
this_script_dir
,
'
lib
'
,
'
gmsh-sdk
'
,
'
lib
'
))
# msvc
add_folder2path
(
os
.
path
.
join
(
thisdir
,
'
lib
'
,
'
gmsh-sdk
'
,
'
bin
'
))
# gmsh
add_folder2path
(
os
.
path
.
join
(
this_script_dir
,
'
lib
'
,
'
gmsh-sdk
'
,
'
bin
'
))
# gmsh
# print(f'sys.path={sys.path}')
def
create_workspace
(
workspace
,
testname
):
"""
create workspace and chdir into it
"""
create workspace
folder
and chdir into it
"""
if
workspace
:
# workspace is given:
# => workspace + testname
...
...
@@ -168,14 +188,14 @@ def create_workspace(workspace, testname):
else
:
# workspace is not given:
# => current_folder + 'workspace' + testname
this
dir
=
os
.
path
.
normcase
(
os
.
getcwd
())
current_
dir
=
os
.
path
.
normcase
(
os
.
getcwd
())
# print(f'testname={testname}')
# print(f'
thisdir={this
dir}')
common
=
os
.
path
.
commonprefix
((
testname
,
this
dir
))
# print(f'
current_dir={current_
dir}')
common
=
os
.
path
.
commonprefix
((
testname
,
current_
dir
))
# print(f'common={common}')
resdir
=
testname
[
len
(
common
)
+
1
:].
replace
(
os
.
sep
,
"
_
"
)
resdir
,
ext
=
os
.
path
.
splitext
(
resdir
)
wdir
=
os
.
path
.
join
(
'
workspace
'
,
resdir
)
wdir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
'
workspace
'
,
resdir
)
)
print
(
'
workspace =
'
,
wdir
)
# sys.exit()
if
not
os
.
path
.
isdir
(
wdir
):
...
...
@@ -187,6 +207,10 @@ if __name__ == "__main__":
# add main program folder and binaries dir to the PYTHONPATH
setup_pythonpath
()
# preload some modules (vtk before gmsh)
import
vtk
import
gmsh
# redirect C++ streams to Python
import
cxxfem
redirect
=
cxxfem
.
StdOutErr2Py
()
...
...
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