Commit 27a5e8cb authored by eric pellegrini's avatar eric pellegrini
Browse files

Added DFTB converter

Update the setup with automatic documentation build
parent cb9fb041
/.project /.project
/.pydevproject /.pydevproject
/build/
*.pyc
MDANSE/App/GUI/Icons/registry.png

258 KB | W: | H:

MDANSE/App/GUI/Icons/registry.png

12.6 KB | W: | H:

MDANSE/App/GUI/Icons/registry.png
MDANSE/App/GUI/Icons/registry.png
MDANSE/App/GUI/Icons/registry.png
MDANSE/App/GUI/Icons/registry.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -31,6 +31,7 @@ Created on Apr 14, 2015 ...@@ -31,6 +31,7 @@ Created on Apr 14, 2015
''' '''
import collections import collections
import operator
import os import os
import webbrowser import webbrowser
...@@ -98,8 +99,10 @@ class MainFrame(wx.Frame): ...@@ -98,8 +99,10 @@ class MainFrame(wx.Frame):
fileMenu.AppendSeparator() fileMenu.AppendSeparator()
converterMenu = wx.Menu() converterMenu = wx.Menu()
self._converters = {} self._converters = {}
for job in REGISTRY["job"].values():
if issubclass(job, Converter): converters = [job for job in REGISTRY["job"].values() if issubclass(job,Converter)]
converters = sorted(converters, key = operator.attrgetter('label'))
for job in converters:
item = converterMenu.Append(wx.ID_ANY,job.label) item = converterMenu.Append(wx.ID_ANY,job.label)
self._converters[job.label] = job.type self._converters[job.label] = job.type
self.Bind(wx.EVT_MENU, self.on_open_converter, item) self.Bind(wx.EVT_MENU, self.on_open_converter, item)
......
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 2.1 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Jun 4, 2015
:author: Eric C. Pellegrini
'''
from MDANSE.Framework.Jobs.Converters.Forcite import ForciteConverter
class DFTBConverter(ForciteConverter):
"""
Converts a DFTB trajectory to a MMTK trajectory.
"""
type = 'dftb'
label = "DFTB"
\ No newline at end of file
...@@ -231,7 +231,7 @@ class DiscoverConverter(Converter): ...@@ -231,7 +231,7 @@ class DiscoverConverter(Converter):
label = "Discover" label = "Discover"
category = ('Converters',) category = ('Converters','Materials Studio')
ancestor = None ancestor = None
......
...@@ -281,7 +281,7 @@ class ForciteConverter(Converter): ...@@ -281,7 +281,7 @@ class ForciteConverter(Converter):
label = "Forcite" label = "Forcite"
category = ('Converters',) category = ('Converters','Materials Studio')
ancestor = None ancestor = None
......
...@@ -5,15 +5,23 @@ import sys ...@@ -5,15 +5,23 @@ import sys
import numpy import numpy
from Cython.Distutils import build_ext from Cython.Distutils import build_ext as cython_build_ext
from distutils.core import setup, Extension
from distutils.command.build import build from distutils.command.build import build
from distutils.command.build_py import build_py from distutils.core import setup, Extension
from distutils.command.build_scripts import build_scripts
from distutils.sysconfig import get_config_vars from distutils.sysconfig import get_config_vars
from distutils.util import convert_path from distutils.util import convert_path
try:
import sphinx
except ImportError:
sphinx = None
try:
import stdeb
except ImportError:
stdeb = None
################################# #################################
# Modules variables # Modules variables
################################# #################################
...@@ -148,6 +156,7 @@ PACKAGE_DATA = find_package_data(where='MDANSE', package='MDANSE', show_ignored= ...@@ -148,6 +156,7 @@ PACKAGE_DATA = find_package_data(where='MDANSE', package='MDANSE', show_ignored=
################################# #################################
DATA_FILES = [] DATA_FILES = []
DATA_FILES.extend(find_data('Doc',exclude=[],prefix='conf_'))
################################# #################################
# Scripts section # Scripts section
...@@ -155,23 +164,17 @@ DATA_FILES = [] ...@@ -155,23 +164,17 @@ DATA_FILES = []
SCRIPTS = [] SCRIPTS = []
SCRIPTS.append(os.path.join(SCRIPTS_PATH,'mdanse')) SCRIPTS.append(os.path.join(SCRIPTS_PATH,'mdanse'))
SCRIPTS.append(os.path.join(SCRIPTS_PATH,'mdanse_gui'))
################################# #################################
# Documentation # Documentation
################################# #################################
import sphinx.apidoc if sphinx:
import sphinx.setup_command import sphinx.apidoc
import sphinx.setup_command
class BuildDoc(sphinx.setup_command.BuildDoc):
user_options = sphinx.setup_command.BuildDoc.user_options + [('doctype=',None,'specify the type of documentation to build ("api" or "help")'),]
def initialize_options(self):
sphinx.setup_command.BuildDoc.initialize_options(self) class mdanse_build_doc(sphinx.setup_command.BuildDoc):
self.doctype='api'
def run(self): def run(self):
...@@ -179,10 +182,10 @@ class BuildDoc(sphinx.setup_command.BuildDoc): ...@@ -179,10 +182,10 @@ class BuildDoc(sphinx.setup_command.BuildDoc):
buildDir = os.path.abspath(build.build_lib) buildDir = os.path.abspath(build.build_lib)
sphinxDir = os.path.join(build.build_base,'sphinx',self.doctype)
sys.path.insert(0,buildDir) sys.path.insert(0,buildDir)
sphinxDir = os.path.join(build.build_base,'sphinx',self.doctype)
metadata = self.distribution.metadata metadata = self.distribution.metadata
sphinx.apidoc.main(['', sphinx.apidoc.main(['',
...@@ -196,10 +199,12 @@ class BuildDoc(sphinx.setup_command.BuildDoc): ...@@ -196,10 +199,12 @@ class BuildDoc(sphinx.setup_command.BuildDoc):
os.path.join(buildDir,'MDANSE'), os.path.join(buildDir,'MDANSE'),
os.path.join(buildDir,'MDANSE','Externals')]) os.path.join(buildDir,'MDANSE','Externals')])
curDir = os.getcwd()
import shutil import shutil
shutil.copy(os.path.join('Doc','conf_%s.py' % self.doctype),os.path.join(sphinxDir,'conf.py')) shutil.copy(os.path.join(curDir,'Doc','conf_%s.py' % self.doctype),os.path.join(sphinxDir,'conf.py'))
shutil.copy(os.path.join('Doc','mdanse_logo.png'),os.path.join(sphinxDir,'_static')) shutil.copy(os.path.join(curDir,'Doc','mdanse_logo.png'),os.path.join(sphinxDir,'_static'))
shutil.copy(os.path.join('Doc','layout.html'),os.path.join(sphinxDir,'_templates')) shutil.copy(os.path.join(curDir,'Doc','layout.html'),os.path.join(sphinxDir,'_templates'))
# The directory where the rst files are located. # The directory where the rst files are located.
self.source_dir = sphinxDir self.source_dir = sphinxDir
...@@ -211,57 +216,31 @@ class BuildDoc(sphinx.setup_command.BuildDoc): ...@@ -211,57 +216,31 @@ class BuildDoc(sphinx.setup_command.BuildDoc):
self.finalize_options() self.finalize_options()
try:
sphinx.setup_command.BuildDoc.run(self) sphinx.setup_command.BuildDoc.run(self)
except UnicodeDecodeError:
print >>sys.stderr, "ERROR: unable to build documentation because Sphinx do not handle source path with non-ASCII characters. Please try to move the source package to another location (path with *only* ASCII characters)."
sys.path.pop(0) sys.path.pop(0)
class BuildHelp(sphinx.setup_command.BuildDoc): class mdanse_build_help(mdanse_build_doc):
def run(self):
build = self.get_finalized_command('build')
buildDir = os.path.abspath(build.build_lib) doctype = 'help'
HelpDir = os.path.join(build.build_base,'sphinx','Help') class mdanse_build_api(mdanse_build_doc):
sys.path.insert(0,buildDir) doctype = 'api'
metadata = self.distribution.metadata
sphinx.apidoc.main(['', #################################
'-F', # Debian packaging
'--separate', #################################
'-d', '5',
'-H', metadata.name,
'-A', metadata.author,
'-V', metadata.version,
'-R', metadata.version,
'-o', HelpDir,
os.path.join(buildDir,'MDANSE'),
os.path.join(buildDir,'MDANSE','Externals')])
import shutil
shutil.copy(os.path.join('Doc','conf_help.py'),os.path.join(HelpDir,'conf.py'))
shutil.copy(os.path.join('Doc','mdanse_logo.png'),os.path.join(HelpDir,'_static'))
shutil.copy(os.path.join('Doc','layout.html'),os.path.join(HelpDir,'_templates'))
# The directory where the rst files are located. class mdanse_build(build):
self.source_dir = HelpDir
# The directory where the conf.py file is located.
self.config_dir = self.source_dir
# The directory where the documentation will be built
self.build_dir = os.path.join(buildDir,'MDANSE','Doc','Help')
try: def has_sphinx(self):
sphinx.setup_command.BuildDoc.run(self) if sphinx is None:
except UnicodeDecodeError: return False
print >>sys.stderr, "ERROR: unable to build documentation because Sphinx do not handle source path with non-ASCII characters. Please try to move the source package to another location (path with *only* ASCII characters)." setup_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.isdir(os.path.join(setup_dir, 'Doc'))
sys.path.pop(0) sub_commands = build.sub_commands + [('build_api', has_sphinx),('build_help',has_sphinx)]
################################# #################################
# Extensions section # Extensions section
...@@ -296,47 +275,12 @@ EXTENSIONS = [Extension('MDANSE.Extensions.distance_histogram', ...@@ -296,47 +275,12 @@ EXTENSIONS = [Extension('MDANSE.Extensions.distance_histogram',
define_macros = [('qh_QHpointer','1')]) define_macros = [('qh_QHpointer','1')])
] ]
class ModifiedBuildScripts(build_scripts): CMDCLASS = {'build' : mdanse_build,
'build_ext' : cython_build_ext}
def finalize_options (self):
build_scripts.finalize_options(self)
if self.distribution.command_obj['build'].gui:
self.scripts.append(os.path.join(SCRIPTS_PATH,'mdanse_gui'))
class ModifiedBuildPy(build_py):
def finalize_options(self):
build_py.finalize_options(self)
if self.distribution.command_obj['build'].gui:
self.packages.append('MDANSE.App.GUI')
self.packages.extend(find_packages(path=os.path.join("MDANSE","App","GUI"), base="MDANSE.App.GUI").keys())
self.data_files = self.get_data_files()
class ModifiedBuild(build):
user_options = build.user_options + [('gui',None,'Build MDANSE with GUI [default]'),
('no-gui', None, "Build MDANSE without GUI")]
boolean_options = build.boolean_options + ['gui']
negative_opt = {'no-gui' : 'gui'}
def initialize_options(self):
build.initialize_options(self)
self.gui = 1
CMDCLASS = {'build_ext' : build_ext, if sphinx:
'build' : ModifiedBuild, CMDCLASS['build_api'] = mdanse_build_api
'build_py' : ModifiedBuildPy, CMDCLASS['build_help'] = mdanse_build_help
'build_scripts' : ModifiedBuildScripts,
'build_doc' : BuildDoc}
################################# #################################
# The setup section # The setup section
...@@ -367,5 +311,4 @@ subunits can be studied. ...@@ -367,5 +311,4 @@ subunits can be studied.
ext_modules = EXTENSIONS, ext_modules = EXTENSIONS,
scripts = SCRIPTS, scripts = SCRIPTS,
cmdclass = CMDCLASS, cmdclass = CMDCLASS,
command_options = {'build_doc' : {'builder':('setup.py','html')}} install_requires = ['Jinja2'])
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment