Skip to content

Commit e198159

Browse files
committed
CAD submodule, optional test, update config
1 parent 185c905 commit e198159

File tree

12 files changed

+231
-103
lines changed

12 files changed

+231
-103
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
.DS_Store
33

44
# compiled python codes
5-
*.pyc
5+
*.pyc
6+
7+
build/
8+
dist/
9+
pygem.egg-info/

pygem/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
# 'igeshandler', 'utils', 'gui', 'khandler', 'idw'
88
# ]
99

10+
def get_current_year():
11+
from datetime import datetime
12+
return datetime.now().year
13+
14+
__title__ = "pygem"
15+
__author__ = "Marco Tezzele, Nicola Demo"
16+
__copyright__ = "Copyright 2017-{}, PyGeM contributors".format(get_current_year())
17+
__license__ = "MIT"
18+
__version__ = "2.0.0"
19+
20+
__maintainer__ = __author__
21+
__status__ = "Stable"
22+
1023
from .affine import *
1124
from .freeform import FFD
1225
from .radial import RBF
@@ -16,9 +29,6 @@
1629
from .stlhandler import StlHandler
1730
from .unvhandler import UnvHandler
1831
from .vtkhandler import VtkHandler
19-
from .nurbshandler import NurbsHandler
20-
from .stephandler import StepHandler
21-
from .igeshandler import IgesHandler
2232
from .khandler import KHandler
2333
from .mdpahandler import MdpaHandler
2434
from .params import *

pygem/cad/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
try:
3+
from .nurbshandler import NurbsHandler
4+
from .stephandler import StepHandler
5+
from .igeshandler import IgesHandler
6+
except ModuleNotFoundError as e:
7+
print('\nOCC not found, but required to deal with CAD files')
8+
print('Install it using:')
9+
print('\tconda install -c conda-forge pythonocc-core=7.4.0')
10+
print('or visit https://github.com/tpaviot/pythonocc-core for more info\n')
11+
raise e
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from OCC.Core.IGESControl import (IGESControl_Reader, IGESControl_Writer,
55
IGESControl_Controller_Init)
66
from OCC.Core.IFSelect import IFSelect_RetDone
7-
from pygem.nurbshandler import NurbsHandler
7+
from pygem.cad import NurbsHandler
88

99

1010
class IgesHandler(NurbsHandler):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from OCC.Core.Interface import Interface_Static_SetCVal
66
from OCC.Core.STEPControl import STEPControl_Writer, STEPControl_Reader
77
from OCC.Core.STEPControl import STEPControl_AsIs
8-
from pygem.nurbshandler import NurbsHandler
8+
from pygem.cad import NurbsHandler
99

1010

1111
class StepHandler(NurbsHandler):

setup.py

Lines changed: 91 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,104 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import setup, find_packages, Command
2+
import os
3+
import sys
4+
import pygem
25

6+
# Package meta-data.
7+
NAME = pygem.__title__
8+
DESCRIPTION = 'Python Geometrical Morphing.'
9+
URL = 'https://github.com/mathLab/PyGeM'
10+
MAIL = pygem.__mail__
11+
AUTHOR = pygem.__author__
12+
VERSION = pygem.__version__
13+
KEYWORDS='dimension_reduction mathematics ffd morphing iges stl vtk openfoam'
314

4-
def readme():
5-
"""
6-
This function just return the content of README.md
7-
"""
8-
with open('README.md') as f:
9-
return f.read()
15+
REQUIRED = [
16+
'future', 'numpy', 'scipy', 'matplotlib',
17+
]
1018

19+
EXTRAS = {
20+
'docs': ['Sphinx==1.4', 'sphinx_rtd_theme'],
21+
}
22+
23+
LDESCRIPTION = (
24+
"PyGeM is a python package using Free Form Deformation, Radial Basis "
25+
"Functions and Inverse Distance Weighting to parametrize and morph complex "
26+
"geometries. It is ideally suited for actual industrial problems, since it "
27+
"allows to handle:\n"
28+
"1) Computer Aided Design files (in .iges, .step, and .stl formats) Mesh "
29+
"files (in .unv and OpenFOAM formats)\n"
30+
"2) Output files (in .vtk format)\n"
31+
"3) LS-Dyna Keyword files (.k format).\n"
32+
"\n"
33+
"By now, it has been used with meshes with up to 14 milions of cells. Try "
34+
"with more and more complicated input files! See the Examples section "
35+
"below and the Tutorials to have an idea of the potential of this package."
36+
)
37+
38+
here = os.path.abspath(os.path.dirname(__file__))
39+
class UploadCommand(Command):
40+
"""Support setup.py upload."""
41+
42+
description = 'Build and publish the package.'
43+
user_options = []
44+
45+
@staticmethod
46+
def status(s):
47+
"""Prints things in bold."""
48+
print('\033[1m{0}\033[0m'.format(s))
49+
50+
def initialize_options(self):
51+
pass
52+
53+
def finalize_options(self):
54+
pass
55+
56+
def run(self):
57+
try:
58+
self.status('Removing previous builds...')
59+
rmtree(os.path.join(here, 'dist'))
60+
except OSError:
61+
pass
62+
63+
self.status('Building Source and Wheel (universal) distribution...')
64+
os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
65+
66+
self.status('Uploading the package to PyPI via Twine...')
67+
os.system('twine upload dist/*')
68+
69+
self.status('Pushing git tags...')
70+
os.system('git tag v{0}'.format(VERSION))
71+
os.system('git push --tags')
72+
73+
sys.exit()
1174

1275
setup(
13-
name='pygem',
14-
version='1.1',
15-
description='Tools for gemetrical morphing.',
16-
long_description=readme(),
17-
classifiers=[
76+
name=NAME,
77+
version=VERSION,
78+
description=DESCRIPTION,
79+
long_description=LDESCRIPTION,
80+
author=AUTHOR,
81+
author_email=MAIL,
82+
classifiers=[
1883
'Development Status :: 5 - Production/Stable',
1984
'License :: OSI Approved :: MIT License',
20-
'Programming Language :: Python :: 2.7',
85+
'Programming Language :: Python :: 3',
86+
'Programming Language :: Python :: 3.7',
2187
'Intended Audience :: Science/Research',
2288
'Topic :: Scientific/Engineering :: Mathematics'
23-
],
24-
keywords='dimension_reduction mathematics ffd morphing iges stl vtk openfoam',
25-
url='https://github.com/mathLab/PyGeM',
26-
author='Marco Tezzele, Nicola Demo',
27-
89+
],
90+
keywords=KEYWORDS,
91+
url=URL,
2892
license='MIT',
29-
packages=find_packages(),
30-
install_requires=[
31-
'numpy', 'numpy-stl', 'enum34', 'scipy', 'matplotlib', 'vtk',
32-
'Sphinx==1.4', 'sphinx_rtd_theme'
33-
],
93+
packages=[NAME],
94+
install_requires=REQUIRED,
95+
extras_require=EXTRAS,
3496
test_suite='nose.collector',
3597
tests_require=['nose'],
3698
include_package_data=True,
37-
zip_safe=False)
99+
zip_safe=False,
100+
101+
# $ setup.py publish support.
102+
cmdclass={
103+
'upload': UploadCommand,
104+
},)

test.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
1-
21
import matplotlib
2+
matplotlib.use('agg')
3+
34
import nose
45

5-
matplotlib.use('agg')
6+
test_defaults = [
7+
'tests/test_freeform.py',
8+
'tests/test_idwparams.py',
9+
'tests/test_affine.py',
10+
'tests/test_idw.py',
11+
'tests/test_khandler.py',
12+
'tests/test_mdpahandler.py',
13+
'tests/test_openfhandler.py',
14+
'tests/test_package.py',
15+
'tests/test_radial.py',
16+
'tests/test_rbfparams.py',
17+
'tests/test_stlhandler.py',
18+
'tests/test_unvhandler.py',
19+
'tests/test_vtkhandler.py',
20+
]
21+
22+
23+
test_cad = [
24+
'tests/test_igeshandler.py',
25+
'tests/test_nurbshandler.py',
26+
'tests/test_stephandler.py',
27+
]
28+
29+
default_argv = ['--tests'] + test_defaults
30+
cad_argv = ['--tests'] + test_cad
31+
32+
try:
33+
import pygem.cad
34+
nose.run(argv=cad_argv)
35+
except:
36+
print('module OCC not found, skip tests for CAD')
37+
38+
nose.run(argv=default_argv)
39+
40+
41+
42+
643

7-
nose.main()

0 commit comments

Comments
 (0)