Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pip support #175

Merged
merged 22 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions cases/coupled/X-HALE/inputs/EMX-07_camber.txt

This file was deleted.

61 changes: 61 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from setuptools import setup
import re
import os

__version__ = re.findall(
r"""__version__ = ["']+([0-9\.]*)["']+""",
open("sharpy/__init__.py").read(),
)[0]

this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()

setup(
name="sharpy",
version=__version__,
description="""SHARPy is a nonlinear aeroelastic analysis package developed
at the Department of Aeronautics, Imperial College London. It can be used
for the structural, aerodynamic and aeroelastic analysis of flexible
aircraft, flying wings and wind turbines.""",
long_description=long_description,
long_description_content_type="text/markdown",
keywords="nonlinear aeroelastic structural aerodynamic analysis",
author="",
author_email="",
url="https://github.com/ImperialCollegeLondon/sharpy",
license="BSD 3-Clause License",
packages=[
"sharpy",
"sharpy.aero",
"sharpy.aero.models",
"sharpy.aero.utils",
"sharpy.controllers",
"sharpy.generators",
"sharpy.io",
"sharpy.linear",
"sharpy.linear.assembler",
"sharpy.linear.dev",
"sharpy.linear.src",
"sharpy.linear.utils",
"sharpy.postproc",
"sharpy.presharpy",
"sharpy.rom",
"sharpy.rom.utils",
"sharpy.solvers",
"sharpy.structure",
"sharpy.structure.models",
"sharpy.structure.utils",
"sharpy.utils",
],
install_requires=[
],
classifiers=[
"Operating System :: Linux",
"Programming Language :: Python, C++",
],

entry_points = {
'console_scripts': ['sharpy=sharpy.sharpy_main:sharpy_run'],
}
)
1 change: 1 addition & 0 deletions sharpy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.3.0"
7 changes: 6 additions & 1 deletion sharpy/aero/utils/uvlmlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import os
from sharpy.utils.constants import NDIM, vortex_radius_def

UvlmLib = ct_utils.import_ctypes_lib(SharpyDir + '/lib/UVLM/lib/', 'libuvlm')
try:
UvlmLib = ct_utils.import_ctypes_lib(SharpyDir + '/UVLM', 'libuvlm')
except OSError:
UvlmLib = ct_utils.import_ctypes_lib(SharpyDir + '/lib/UVLM/lib', 'libuvlm')




class VMopts(ct.Structure):
Expand Down
Empty file added sharpy/cases/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added sharpy/cases/hangar/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions sharpy/sharpy_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""sharpy_main: Where it all starts

"""
import warnings
import sys
import dill as pickle
import sharpy.utils.cout_utils as cout

Expand Down Expand Up @@ -137,3 +139,11 @@ def main(args=None, sharpy_input_dict=None):
raise e

return data



def sharpy_run():
data = None
with warnings.catch_warnings():
warnings.simplefilter('ignore')
data = main(sys.argv)
25 changes: 12 additions & 13 deletions sharpy/structure/utils/xbeamlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
# from sharpy.utils.datastructures import StructTimeStepInfo
import sharpy.utils.cout_utils as cout

xbeam_lib_path = SharpyDir + '/lib/xbeam/lib/'

try:
xbeamlib = ct_utils.import_ctypes_lib(SharpyDir + '/xbeam', 'libxbeam')
except OSError:
xbeamlib = ct_utils.import_ctypes_lib(SharpyDir + '/lib/xbeam/lib',
'libxbeam')

# ctypes pointer types
doubleP = ct.POINTER(ct.c_double)
intP = ct.POINTER(ct.c_int)
charP = ct.POINTER(ct.c_char_p)


class Xbopts(ct.Structure):
"""Structure skeleton for options input in xbeam
Expand Down Expand Up @@ -61,14 +72,6 @@ def __init__(self):
self.relaxation_factor = ct.c_double(0.3)


xbeamlib = ct_utils.import_ctypes_lib(xbeam_lib_path, 'libxbeam')

# ctypes pointer types
doubleP = ct.POINTER(ct.c_double)
intP = ct.POINTER(ct.c_int)
charP = ct.POINTER(ct.c_char_p)


def cbeam3_solv_nlnstatic(beam, settings, ts):
"""@brief Python wrapper for f_cbeam3_solv_nlnstatic
Alfonso del Carre
Expand Down Expand Up @@ -859,7 +862,6 @@ def cbeam3_asbly_dynamic(beam, tstep, settings):
"""

# library load
xbeamlib = ct_utils.import_ctypes_lib(xbeam_lib_path, 'libxbeam')
f_cbeam3_asbly_dynamic_python = xbeamlib.cbeam3_asbly_dynamic_python
f_cbeam3_asbly_dynamic_python.restype = None

Expand Down Expand Up @@ -963,7 +965,6 @@ def xbeam3_asbly_dynamic(beam, tstep, settings):
"""

# library load
xbeamlib = ct_utils.import_ctypes_lib(xbeam_lib_path, 'libxbeam')
f_xbeam3_asbly_dynamic_python = xbeamlib.xbeam3_asbly_dynamic_python
f_xbeam3_asbly_dynamic_python.restype = None

Expand Down Expand Up @@ -1056,7 +1057,6 @@ def cbeam3_correct_gravity_forces(beam, tstep, settings):
"""

# library load
xbeamlib = ct_utils.import_ctypes_lib(xbeam_lib_path, 'libxbeam')
f_cbeam3_correct_gravity_forces_python = xbeamlib.cbeam3_correct_gravity_forces_python
f_cbeam3_correct_gravity_forces_python.restype = None

Expand Down Expand Up @@ -1110,7 +1110,6 @@ def cbeam3_asbly_static(beam, tstep, settings, iLoadStep):
"""

# library load
xbeamlib = ct_utils.import_ctypes_lib(xbeam_lib_path, 'libxbeam')
f_cbeam3_asbly_static_python = xbeamlib.cbeam3_asbly_static_python
f_cbeam3_asbly_static_python.restype = None

Expand Down
13 changes: 5 additions & 8 deletions sharpy/utils/ctypes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@


def import_ctypes_lib(route, libname):
lib_path = route + libname
# lib_path = route + libname
lib_path = os.path.join(route, libname)
if platform.system() == 'Darwin':
ext = '.dylib'
elif platform.system() == 'Linux':
Expand All @@ -14,11 +15,7 @@ def import_ctypes_lib(route, libname):

lib_path += ext
lib_path = os.path.abspath(lib_path)
try:
library = ct.CDLL(lib_path, mode=ct.RTLD_GLOBAL)
except:
import traceback
import sys
traceback.print_exc(file=sys.stderr)
sys.exit(1)

library = ct.CDLL(lib_path, mode=ct.RTLD_GLOBAL)

return library