Skip to content

Commit

Permalink
Merge pull request #3884 from mrrezaie/gepmetry_python_setup
Browse files Browse the repository at this point in the history
Add Geometry folder to the Python package in local installation
  • Loading branch information
nickbianco authored Oct 28, 2024
2 parents 897689f + 261089b commit adba1ce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Bindings/Python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
import os

curFolder = os.path.dirname(os.path.realpath(__file__))
if (sys.platform.startswith('win')):
curFolder = os.path.dirname(os.path.realpath(__file__))
os.add_dll_directory(curFolder)
# When installed locally via "python -m pip install ." in Windows
if os.path.isfile(os.path.join(curFolder, 'opensim-cmd.exe')):
Expand All @@ -26,3 +27,7 @@
from . import report

from .version import __version__

geometry_path = os.path.join(curFolder, 'Geometry')
if os.path.exists(geometry_path):
ModelVisualizer.addDirToGeometrySearchPaths(geometry_path)
23 changes: 17 additions & 6 deletions Bindings/Python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@

# This provides a list of relative paths to all the dependencies in the bin folder.
# Only when installed locally via "python -m pip install ." in Windows
if os.path.isfile('../../bin/opensim-cmd.exe'):
bin_files = [os.path.join('../../bin', i).replace(os.sep,'/') for i in os.listdir('../../bin')]
else:
bin_files = []
bin_path = '../../bin'
bin_files = []
if os.path.isfile(os.path.join(bin_path, 'opensim-cmd.exe')):
for file in os.listdir(bin_path):
bin_files.append(os.path.join(bin_path, file).replace(os.sep,'/'))

# A list of relative paths to the geometry files in the /Geometry folder
geometry_path = '../../Geometry'
geometry_files = []
if os.path.exists(geometry_path):
for file in os.listdir(geometry_path):
geometry_files.append(os.path.join(geometry_path, file).replace(os.sep,'/'))

# This provides the variable `__version__`.
if sys.version_info[0] < 3:
Expand All @@ -25,8 +33,11 @@
url='http://opensim.stanford.edu/',
license='Apache 2.0',
packages=['opensim'],
# Copy the bin_files into the opensim package directory
data_files=[('Lib/site-packages/opensim', bin_files)],
# Copy the bin_files and geometry_files into the opensim package directory
data_files=[
('Lib/site-packages/opensim', bin_files),
('Lib/site-packages/opensim/Geometry', geometry_files)
],
# The last 3 entries are for if OPENSIM_PYTHON_STANDALONE is ON.
# The asterisk after the extension is to handle version numbers on Linux.
package_data={'opensim': ['_*.*', '*.dylib', '*.dll', '*.so*']},
Expand Down

0 comments on commit adba1ce

Please sign in to comment.