Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
navipy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olivier Bertrand
navipy
Commits
ab9b659c
Commit
ab9b659c
authored
7 years ago
by
Olivier Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Update blendnavipy to support non virtualenvironment
parent
2d40f7c5
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
navipy/sensors/blendnavipy.py
+38
-11
38 additions, 11 deletions
navipy/sensors/blendnavipy.py
setup.py
+3
-2
3 additions, 2 deletions
setup.py
with
41 additions
and
13 deletions
navipy/sensors/blendnavipy.py
+
38
−
11
View file @
ab9b659c
...
...
@@ -16,11 +16,18 @@ def activate_virtualenv(venv_path):
tell blender to use our virtualenv where the navigation toolbox
\
is installed.
"""
if
venv_path
is
None
:
raise
NameError
(
'
Python is not running within a virtualenv
'
)
filepath
=
os
.
path
.
join
(
venv_path
,
'
bin
'
,
'
activate_this.py
'
)
with
open
(
filepath
,
'
r
'
)
as
f
:
exec
(
f
.
read
(),
dict
(
__file__
=
filepath
))
with
open
(
venv_path
,
'
r
'
)
as
f
:
exec
(
f
.
read
(),
dict
(
__file__
=
venv_path
))
def
append_path
(
path_navipy
):
"""
insert path
Blender comes with its own python installation. Thus, we need to
\
tell blender where to look for navipy
"""
for
cpath
in
path_navipy
:
sys
.
path
.
insert
(
0
,
cpath
)
def
blender_version
(
pyversion
):
...
...
@@ -74,6 +81,14 @@ def main():
# Find the name of the virtualenv, so that we can activate
# it in blender
venv_path
=
sys
.
base_prefix
venv_path
=
os
.
path
.
join
(
venv_path
,
'
bin
'
,
'
activate_this.py
'
)
if
os
.
path
.
exists
(
venv_path
):
# Runnin in virtualenv
syspath
=
None
else
:
# Find path packages
syspath
=
sys
.
path
venv_path
=
None
# Find python version to be checked agains blender python version
pyver
=
sys
.
version_info
[:
3
]
...
...
@@ -94,16 +109,28 @@ def main():
tfile
.
write
(
header
.
encode
(
encoding
))
tfile
.
write
(
'
# check blender version
\n
'
.
encode
(
encoding
))
tfile
.
write
(
'
import sys
\n
'
.
encode
(
encoding
))
tfile
.
write
(
'
import os
\n
'
.
encode
(
encoding
))
for
line
in
inspect
.
getsourcelines
(
blender_version
)[
0
]:
tfile
.
write
(
line
.
encode
(
encoding
))
line
=
'
blender_version({})
\n
'
.
format
(
pyver
)
tfile
.
write
(
line
.
encode
(
encoding
))
tfile
.
write
(
'
# activate virtualenv within blender
\n
'
.
encode
(
encoding
))
tfile
.
write
(
'
import os
\n
'
.
encode
(
encoding
))
for
line
in
inspect
.
getsourcelines
(
activate_virtualenv
)[
0
]:
tfile
.
write
(
line
.
encode
(
encoding
))
line
=
'
activate_virtualenv(
\"
{}
\"
)
\n
'
.
format
(
venv_path
)
tfile
.
write
(
line
.
encode
(
encoding
))
if
venv_path
is
not
None
:
tfile
.
write
(
'
# activate virtualenv within blender
\n
'
.
encode
(
encoding
))
for
line
in
inspect
.
getsourcelines
(
activate_virtualenv
)[
0
]:
tfile
.
write
(
line
.
encode
(
encoding
))
line
=
'
activate_virtualenv(
\"
{}
\"
)
\n
'
.
format
(
venv_path
)
tfile
.
write
(
line
.
encode
(
encoding
))
elif
syspath
is
not
None
:
tfile
.
write
(
'
# add navipy path within blender
\n
'
.
encode
(
encoding
))
for
line
in
inspect
.
getsourcelines
(
append_path
)[
0
]:
tfile
.
write
(
line
.
encode
(
encoding
))
line
=
'
activate_virtualenv({})
\n
'
.
format
(
str
(
syspath
))
tfile
.
write
(
line
.
encode
(
encoding
))
else
:
raise
NameError
(
'
The path to navipy could not be found
'
)
tfile
.
write
(
'
# run simulation
\n
'
.
encode
(
encoding
))
with
open
(
python_script
)
as
infile
:
for
line
in
infile
:
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
3
−
2
View file @
ab9b659c
...
...
@@ -43,7 +43,8 @@ setup_dict = {'name': 'navipy',
'
package_data
'
:
{
'
navipy
'
:
[
'
resources/database.db
'
,
'
resources/forest_world.blend
'
]},
'
include_package_data
'
:
True
,
'
console_scripts
'
:
[
'
blendnavipy = navipy.sensors.blendnavipy:main_func
'
],
}
'
entry_points
'
:
{
'
console_scripts
'
:
[
'
blendnavipy=navipy.sensors.blendnavipy:main
'
]},
}
setup
(
**
setup_dict
)
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