Index: installers/MANIFEST.IN
===================================================================
--- installers/MANIFEST.IN	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/MANIFEST.IN	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,4 @@
+graft docs
+graft images
+include README.txt
+include license.txt
Index: installers/README-next-release.txt
===================================================================
--- installers/README-next-release.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/README-next-release.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,10 @@
+   - New in Version 3.?.?
+     --------------------
+
+     - New models were added:
+       - LamellarPolLz
+
+     - Existing models were updated:
+       - LamellarPS and LamellarPSHG have been changed to LamellarCaille and 
+         LamellarCailleHG
+       
Index: installers/README.txt
===================================================================
--- installers/README.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/README.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,590 @@
+Release Notes
+=============
+
+1- Features
+===========
+    - New in Version 4.1.0
+      ------------------
+      This incremental release brings a series of new features and improvements,
+      and a host of bug fixes. Of particular note are:
+      
+      - Correlation Function Analysis (Corfunc)
+      	This performs a correlation function analysis of one-dimensional SAXS/SANS data, 
+	or generates a model-independent volume fraction profile from the SANS from an 
+	adsorbed polymer/surfactant layer.
+
+	A correlation function may be interpreted in terms of an imaginary rod moving 
+	through the structure of the material. Î1D(R) is the probability that a rod of 
+	length R moving through the material has equal electron/neutron scattering 
+	length density at either end. Hence a frequently occurring spacing within a 
+	structure manifests itself as a peak.
+
+	A volume fraction profile \Phi(z) describes how the density of polymer 
+	segments/surfactant molecules varies with distance from an (assumed locally flat)
+	interface.
+
+      - Fitting of SESANS Data
+      	Data from Spin-Echo SANS measurements can now be loaded and fitted. The data will 
+	be plotted against the correct axes and models will automatically perform a Hankel 
+	transform in order to calculate SESANS from a SANS model.
+
+      - Documentation
+      	The documentation has undergone significant checking and updating.
+
+      - Improvements
+        - Correlation function (corfunc) analysis of 1D SAS data added from CCP13
+        - File converter tool for multi-file single column data sets
+        - SESANS data loading and direct fitting using the Hankel transformation
+        - Saving and loading of simultaneous and constrained fits now supported
+        - Save states from SasView v3.x.y now loaded using sasmodel model names
+        - Saving and loading of projects with 2D fits now supported
+        - Loading a project removes all existing data, fits, and plots
+        - Structure factor and form factor can be plotted independently
+        - OpenCL is disabled by default and can be enabled through a fit menu
+        - Data and theory fields are now independently expandable
+      - Bug Fixes
+        - Fixes #667: Models computed multiple times on parameters changes
+        - Fixes #673: Custom models override built in models of same name
+        - Fixes #678: Hard crash when running complex models on GPU
+        - Fixes $774: Old style plugin models unloadable
+        - Fixes #789: stacked disk scale doesn't match cylinder model
+        - Fixes #792: core_shell_fractal uses wrong effective radius
+        - Fixes #800: Plot range reset on plot redraws
+        - Fixes #811 and #825: 2D smearing broken
+        - Fixes #815: Integer model parameter handling
+        - Fixes #824: Cannot apply sector averaging when no detector data present
+        - Fixes #830: Cansas HDF5 reader fully compliant with NXCanSAS v1.0 format
+        - Fixes #835: Fractal model breaks with negative Q values
+        - Fixes #843: Multilayer vesicle does not define effective radius
+        - Fixes #858: Hayter MSA S(Q) returns errors
+        - Numerous grammatical and contexual errors in documention
+
+
+    - New in Version 4.0.1
+      ------------------
+      This release fixes the critical bug #750 in P(Q)*S(Q).  Most damaging
+      it appears that the background term was being added to S(Q) prior to
+      multiplication by P(Q).
+
+
+    - New in Version 4.0
+      ------------------
+      This release fixes the various bugs found during the alpha and beta testing
+      - Improvements
+        - Support for reading data files from Anton Paar Saxess instruments
+        - Adds documentation on how to write custom models in the new framework
+      - Bug Fixes
+        - Fixes bug #604 Pringle model questions
+        - Fixes bug #472 Reparameterize Teubner-Strey
+        - Fixes bug #530 Numerical instabilities in Teubner Strey model
+        - Fixes bug #658 ASCII reader very broken
+
+
+    - New in Version 4.0 beta 1
+      --------------------
+      This beta adds support for the magnetic and multilevel models of 3.1.2
+      and along with a host of bug fixes found in the alpha.
+
+      - Model package changes and improvements
+         - All 3.1.2 models now available in new interface
+         - Old custom models should now still work
+            - '''NOTE:''' These will be deprecated in a future version. Old
+            custom models should be converted to the new model format which
+            is now the same as the built in models and offers much better
+            support.
+         - Custom model editor now creates new style models
+         - Custom model editor supports better error checking
+      - Documentation improvements
+        - Continued general cleanup
+      - Other improvements/additions
+         - Support for new canSAS 2D data files added
+         - Plot axes range can now be set manually as well as by zooming
+         - Plot annotations can now be moved around after being placed on plot.
+         - The active optimizer is now listed on the top of the fit panel.
+         - Linear fits now update qmin and max when the x scale limits are
+         changed.  Also the plot range no longer resets after a fit.
+      - Bug fixes
+         - Fixes bug #511 Errors in linearized fits and clean up of interface
+         including Kratky representation
+         - Fixes bug #186 Data operation Tool now executes when something is
+         entered in the text box and does not wait for the user to hit enter
+         - Fixes bug #459 plot context menu bug
+         - Fixes bug #559 copy to clipboard in graph menu broken
+         - Fixes bug #466 cannot remove a linear fit from graph
+         - Numerous bugs introduced in the alpha
+
+
+
+    - New in Version 4.0.0-alpha
+      --------------------
+      This alpha release brings a major overhaul of the model system. The new model
+      package allows rapid integration of custom models and access to polydispersity
+      without requiring a compiler.
+
+      - Model package changes and improvements
+         - Model interface moved to independent sasmodels package.
+         - Most models converted to new interface.
+         - Allows rapid integration of user-written models.
+         - OpenCL GPU utilization for faster fitting.
+         - Improved numerical integration of Bessel functions.
+      - SESANS integration and implementation
+         - Scripting interface added for analysis of SESANS data.
+         - Hankel transformation now accepts finite acceptance angles.
+         - 2D cosine transformation added for TOF SESANS analysis.
+      - Documentation improvements
+         - The documentation tree was restructured for a better end user experience.
+         - The documentation for each model was revamped and verified by at least
+           two people following the conversion of the model.
+         - Theoretical 1D (and 2D if applicable) scattering curves are auto-generated
+           and added to the model documentation for each model.
+      - Separation of GUI and calculations for future GUI enhancements
+      - Bug fixes
+         - Fixes bug #411 No stop button on simultaneous fit page
+         - Fixes bug #410 Error with raspberry model
+         - Fixes bug #364 Possible inconsistency in Poly_GausCoil model
+         - Fixes bug #439 Hayter Penfold MSA code needs checking
+         - Fixes bug #484 lammellerPC is precision limited
+         - Fixes bug #498 $HOME/.matplotlib conflicts
+         - Fixes bug #348 Control order in which fit parameters appear in the gui
+         - Fixes bug #456 Provide DREAM Results Panel with something to identify
+           data and age of results
+         - Fixes bug #556 Build script improvements for developers
+
+
+
+   - New in Version 3.1.2
+     --------------------
+     This release is a major stability improvement, having fixed a serious bug
+     that came to light since release 3.1.1. All users should upgrade.
+
+     - Fixes bug #468 broken remove constraint buttons in
+       simultaneous/constrained fitting panel
+     - Fixes bug #474 resulting from changes in 3.1.1 that had
+       introduced an error in the high-Q of slit-smeared models.
+     - Fixes bug #478 which would cause wx to run out of IDs and result
+       in SasView crashing even if left alone.
+     - Fixes bug #479 missing help button on simultaneous/constrained fit page
+     - Fixes bug #480 GUI resizing issues on simultaneous fit page
+     - Fixes bug #486 broken Report Results
+     - Fixes bug #488 redraw issues in fit page
+
+
+
+   - New in Version 3.1.1
+     --------------------
+     - Fixes bug #457 that prevented SasView from starting if the user was not
+       connected to the internet, or was behind a proxy server.
+
+   - New in Version 3.1.0
+     --------------------
+     - The documentation/help has had a complete overhaul including:
+       - A completely new presentation interface (Sphinx).
+       - Proof reading!
+       - Updating for latest features.
+       - A Help (or sometimes ?) button has been added to every panel, and some
+         sub panels if appropriate, linking to the appropriate section in the
+         documentation.
+       - The model help has been split so that the Details button now brings up
+         a very short pop-up giving the equation being used while HELP goes to
+         the section in the full documentation describing the model.
+       - Extensive help has also been added for the new optimizer engine (see
+         below) including rules of thumb on how and when to choose a given
+         optimizer and what the parameters do.
+     - The optimizer engine has been completely replaced. The new optimizer
+       still defaults to the standard Levenberg-Marquardt algorithm. However 4
+       other optimizers are now also available. Each starts with a set of default
+       parameters which can be tuned. The DREAM optimizer takes the longest but
+       is the most powerful and yields rich information including full parameter
+       correlation and uncertainty plots. A results panel has been added to
+       accommodate this.
+       - The five new optimizers are:
+         - A Levenberg-Marquardt optimizer
+         - A Quasi-Newton BFGS optimizer
+         - A Nelder-Mead Simplex optimizer
+         - A Differential Evolution optimizer
+         - A Monte Carlo optimizer (DREAM)
+     - New models were added:
+         - MicelleSphCoreModel (currently residing in the Uncategorized category)
+     - Existing models were updated:
+         - LamellarPS (bug in polydispersity integration fixed)
+         - RectangularPrismModel
+         - RectangularHollowPrismModel
+         - RectangularHollowPrismInfThinWallsModel
+     - Infrastructure to allow SESANS data to be fit with models was added. This
+       will become available in a future release but can currently be used from
+       the command line with some caveats.
+     - A number of bugs were fixed including a thread crashing issue and an
+       incorrect slit smearing resolution calculation.
+     - Implemented much more robust error logging to enable much easier
+       debugging in general but particularly the debugging of issues reported by
+       SasView users.
+     - A number of infrastructure tasks under the hood to enhance maintainability
+     - Upgrade from Wx 2.8 to Wx 3.0.2 which allows several new features but
+       required significant additional rework as well.
+     - Fully implemented Sphinx to the build process to produce both better
+       user documentation and developer documentation.
+     - Restructuring of the code base to more unified nomenclature and structure
+       so that the source installation tree more closely matches the installer
+       version tree.
+     - Code cleanup (an ongoing task) .
+     - Migration of the repository to github simplifying contributions from
+       non-project personnel through pull requests.
+
+   - New in Version 3.0.0
+     --------------------
+     - The GUI look and feel has been refactored to be more familiar for
+       Windows users by using MDI frames. Graph windows are also now free-
+       floating.
+     - Five new models have been added: PringlesModel, CoreShellEllipsoidXTModel,
+       RectangularPrismModel, RectangularHollowPrismModel and
+       RectangularHollowPrismInfThinWallsModel.
+     - The data loader now supports ILL DAT data files and reads the full meta
+       information from canSAS file formats.
+     - Redefined convention for specifying angular parameters for anisotropic
+       models.
+     - A number of minor features have been added such as permitting a log
+       distribution of points when using a model to simulate data, and the
+       addition of a Kratky plot option to the linear plots.
+     - A number of bugs have also been fixed.
+     - Save Project and Save Analysis now work more reliably.
+     - BETA: Magnetic contrast supporting full polarization analysis has been
+       implemented for some spherical and cylindrical models.
+     - BETA: Two new tools have been added:
+       - A generic scattering calculator which takes an atomic, magnetic or
+         SLD distribution in space and generates the appropriate 2D
+         scattering pattern. In some cases the orientationally averaged
+         (powder) 1D scattering can also be computed. Supported formats
+         include: SLD or text, PDB, and OMF magnetic moment distribution
+         file.
+       - An image viewer/converter for data in image format; this reads in
+         an image file and will attempt to convert the image pixels to
+         data. Supported formats include: TIFF, TIF, PNG, BMP, JPG.
+
+   - New in Version 2.2.1
+     --------------------
+     - Minor patch to support CanSAS XML v1.1 file format
+     - Added DataInfo for data in the DataExplorer and plots
+     - Added Maximize/Restore button in the title bar of the graphs
+     - Added a hide button in the toolbar of the graph panel
+     - The 'x' button now deletes a graph
+     - Edit SUM Model from the menubar can now generate and save more than one sum model
+     - Reports can now be saved in pdf format on WIN and MAC
+     - Made significant improvements to the batch/grid panel and fixed several bugs
+     - Fixed a number of other minor bugs
+
+   - New in Version 2.2.0
+     --------------------
+     - Application name changed to SasView
+     - New fully customizable Category Manager added for better management of
+       increasing number of models
+     - Improved the Grid Window functionality in the batch fitting mode
+     - Added a simpler Graph/Plot modification interface
+     - Added a new 'Data Operation' tool for addition, subtraction, multiplication,
+       division, of two data sets.
+     - The 'Sum Model' editor was extended and renamed 'Summation and Multiplication'
+       editor
+     - Added more plot symbols options for 1d plots
+     - Added improved trapping of compiling errors to the 'New model editor'
+     - Added some intelligent outputs (e.g., Rg, background, or rod diameter
+       depending on the choice of axis scale of the plot) to the linear fits
+     - Added more models
+
+   - Feature set from previous versions
+     -----------------------------------
+     - Perspectives Available
+       - Invariant calculator: Calculates the invariant, volume fraction, and
+         specific surface area.
+       - P(r) inversion calculator: Indirect Fourier transformation method.
+       - Fitting: the tool used for modeling and fitting 1D and 2D data to
+         analytical model functions
+       - Tools: provides a number of useful supplementary tools such as SLD
+         calculation
+
+     - Fitting
+       - Includes a large number of model functions, both form factors and structure factors.
+       - Support P(Q)*S(Q) for form factors that flag they can be so multiplied.
+       - Supports Gaussian, lognormal, Shulz, rectangular and custom distribution
+         functions for models that need to include polydispersity or for orientational
+         distributions if appropriate.
+       - Anisotropic shapes and magnetic moment modeling in 2D allow for a non-uniform
+         distribution of orientations of a given axis leading to modeling and fitting
+         capabilities of non azimuthaly symmetric data.
+       - User can choose to weight fits or not. If using weights, the user can choose
+         the error bar on each point if provided in the file, the square root
+         of the intensity or the intensity itself.
+       - Instrumental resolution smearing of model or fits is provided with several
+         options: read the resolution/point fromt he file. Input a pinhole resolution
+         or a slit resolution.
+       - Users can define the Qrange (Qmin and Qmax) for both 1D and 2D data for
+         fitting and modeling, but not graphically.  The range can be reset to the
+         defaults (limits of q in data set for a fit) with the reset button.
+       - A mask can be applied to 2D calculation and fitting.
+       - Normalized residual plots are provided with every fit.
+       - Model function help available through detail button or from the fitting panel.
+       - Simultaneous/(advanced)constrained fitting allows for fitting a single
+         data set or several different sets simultaneously with the application
+         of advanced constraints relating fit parameters to functions of other
+         parameters (including from a different set). For example thickness of
+         shell = sin(30) times the length.
+       - Models that are the sum of two other models can be easily generated through the
+         SUM Model menubar item.
+       - New Python models can be added on the fly by creating an appropriate Python
+         file in the model plugin directory. Two tools are provided to help:
+         An easy to use custom model editor allows the quick generation of new Python
+         models by supplying only the parameters and their default value (box 1)
+         and the mathematical function of the model (box 2) and generating the
+         necessary *.py file.  A separate advanced model editor provides a full Python
+         file editor.  Either way once saved the model becomes immediately available
+         to the application.
+       - A batch fitting capability allows for the analysis of a series of data sets to
+         a single model and provides the results in a tabular form suitable for saving
+         or plotting the evolution of the fit parameters with error bars (from within
+         the application).
+
+     - Tools
+       - A scattering length density calculator,including some X-ray information
+         is provided.
+       - A density to vol. fraction converter is provided
+       - In application access to a Python shell/editor (PyCrust) is provided
+       - An instrument resolution calculator, including possible gravitational and
+         TOF effects is provided
+       - A slit size calculator optimized for Anton Paar Saxess is provided.
+       - A kiessig fringe thickness calculator is provided
+
+     - Plots and plot management
+       - A 3D graphing option (for 2d data/results) is provided with the view
+         controlled by the mouse
+       - 2D plots are shown with an intensity color bar. 2D Color map can be user
+         adjusted.
+       - Supports output of plot to a variety of graphic formats. Supported formats
+         include: png, eps, emf, jpg/jpeg, pdf, ps, tif/tiff, rawRGBbitmap(raw, rgba),
+         and scalable vector graphic (svg/svgz)
+       - Supports ouput of data in plot (1 or 2D) to limited data formats
+       - Multiple data sets can be loaded into a single graph for viewing (but a fit
+         plot can currently only have a single plot).
+       - Extensive context sensitive plot/fitting/manipulation options are available
+         through a right mouse click pop-up menu on plots.
+
+     - Data management
+       - Supports 2 + column 1D ASCII data, NIST 1D and 2D data, and canSAS data
+         via plug-in mechanism which can easily allow other readers as appropriate.
+       - 2D data is expected in Q space but for historical reasons accepts the
+         NIST 2D raw pixel format and will do conversion internally.
+       - The full data and metadata available to SasView is viewable in ASCII via
+         right clicking on a data set and choosing Data Info in the DataExplorer
+         or on the plots
+       - Supports loading a single file, multiple files, or a whole folder
+       - An optional Data Explorer is provided (default) which simplifies managing,
+         plotting, deleting, or setup for computation. Most functions however do
+         not require access to the explorer/manager and can be accessed through
+         right click menus and the toolbar.  The data explorer can be re-started
+         from the menu bar.
+
+     - Data manipulation
+       - Support various 2D averaging methods : Circular, sectors, annular,
+         boxsum, boxQx and boxQy.
+       - A 2D data maks editor is provided
+       - 2D mask can be applied to the circular averaging.
+
+     - Miscellaneous features
+       - limited reports can be generated in pdf format
+       - Provides multiprocessor support(Windows only)
+       - Limited startup customization currently includes default startup
+         data folder and choice of default starting with data manager
+       - Limited support for saving(opening) a SasView project or a SasView analysis
+         (subproject) is provided.
+       - SasView can be launched and loaded with a file of interesty by double-clicking
+         on that file (recognized extension)
+       - A data file or data folder can be passed to SasView when launched from
+         the command line.
+       - Limited bookmarking capability to later recall the results of a fit calculation
+         is provided.
+       - Extensive help is provided through context sensitive mouse roll-over,
+         information bar (at the bottom of the panel), the console menu, and
+         access to the help files in several different ways.
+
+
+2- Downloading and Installing
+=============================
+
+   *** Note 1:  Much more information is available at www.sasview.org under links.
+	            Look in the 'For Developers' section and particularly the wiki at
+                www.sasview.org/trac/wiki.
+   *** Note 2:  If you have EXE or ZIP SasView installer, you won't need any of
+                the following.  However it is highly recommended that any
+                previous versions be un-installed prior to installing the
+                new version.
+
+   2.1- System Requirements
+        - Python version >= 2.5 and < 3.0 should be running on the system
+        - We currently use Python 2.7
+
+   2.2- Installing from source
+        - Get the source code
+          - to follow the current development version from source control use
+              git clone https://github.com/SasView/sasview.git
+              git clone https://github.com/bumps/bumps.git
+	  - to install a specific version
+
+        - Build, install and run a specific release
+          - make sure the requirements below are already installed
+          - retrieve the source from https://github.com/SasView/sasview/releases
+          - open a command line window in the 'sasview-x.x.x' directory
+          - run 'python setup.py install'
+          - run 'python sasview.py' under the 'sasview' folder.
+
+        - Build, install and run the current development version
+          - clone the source from git; also clone bumps, which is developed in parallel
+              git clone https://github.com/SasView/sasview.git
+              git clone https://github.com/bumps/bumps.git
+          - open a command line window in the 'sasview' directory
+          - run 'python setup.py build'
+          - run 'python run.py'; this runs from the source directories, so you
+            don't have to rebuild every time you make a change, unless you are
+            changing the C++ model files
+
+        - The following modules are required (version numbers are what are used
+          in the windows release build):
+
+          - Common Packages
+            - reportlab 3.1.44
+            - lxml 3.4.4.0 (MAC 3.4.2.0)
+            - PIL 1.1.7
+            - xhtml2pdf 3.0.33 (MAC = not installed on build server)
+            - unittest-xml-reporting 1.12.0 (MAC 1.10.0)
+            - matplotlib Version Installed: 1.4.3 (MAC 1.1.1)
+            - bumps Version Installed: 0.7.5.9
+            - scipy Version Installed: 0.16.0b2 (MAC 0.11.0)
+            - periodictable Version Installed: 1.4.1
+            - setuptools Version Installed: 7.0 (MAC 12.0.5)
+            - sphinx Version Installed: 1.3.1 (MAC 1.3b2)
+            - pyparsing Version Installed: 2.0.3
+            - numpy Version Installed: 1.9.2 (MAC 1.6.2)
+            - html5lib Version Installed: 0.99999
+            - wx Version Installed: 3.0.2.0
+
+          - Windows Specific Packages
+            - pywin 219
+            - py2exe 0.6.9
+            - comtypes 1.1.1
+            - MinGW w/ gcc version 4.6.1 (WIN)
+            - vcredist_x86.exe (version 9.0.21022.8  -microsoft visual C 2008
+              re-distributable)
+            - Innosetup (WIN - isetup 5.4.2-unicode) - used to create distributable
+
+            *** Note: Windows build dependencies can be set up using anaconda. Instructions
+                can be found at http://trac.sasview.org/wiki/AnacondaSetup
+
+          - MAC Specifc Packages
+            - py2app 0.7.1
+
+
+3- Known Issues
+===============
+
+
+   4.1- All systems:
+      The conversion to sasmodels infrastructure is ongoing and should be
+      completed in the next release. In the meantime this leads to a few known
+      issues:
+        - The way that orientation is defined is being refactored to address
+        long standing issues and comments.  In release 4.1 however only models
+        with symmetry (e.g. a=b) have been converted to the new definitions.
+        The rest (a <> b <> c - e.g. parellelepiped) maintain the same
+        definition as before and will be converted in 4.2.  Note that
+        orientational distribution also makes much more sense in the new
+        framework.  The documentation should indicate which definition is being
+        used for a given model.
+        - The infrastructure currently handles internal conversion of old style
+        models so that user created models in previous versions should continue
+        to work for now. At some point in the future such support will go away.
+        Everyone is encouraged to convert to the new structure which should be
+        relatively straight forward and provides a number of benefits. 
+        - In that vein, the distributed models and those generated by the new
+        plugin model editor are in the new format, however those generated by
+        sum|multiply models are the old style sum|multiply models. This should
+        also disappear in the near future 
+        - The on the fly discovery of plugin models and changes thereto behave
+        inconsistently.  If a change to a plugin model does not seem to
+        register, the Load Plugin Models (under fitting -> Plugin Model
+        Operations) can be used.  However, after calling Load Plugin Models, the
+        active plugin will no longer be loaded (even though the GUI looks like
+        it is) unless it is a sum|multiply model which works properly.  All
+        others will need to be recalled from the model dropdown menu to reload
+        the model into the calculation engine.  While it might be annoying it
+        does not appear to prevent SasView from working..
+        - The model code and documentation review is ongoing. At this time the
+        core shell parellelepiped is known to have the C shell effectively fixed
+        at 0 (noted in documentation) while the triaxial ellipsoid does not seem
+        to reproduce the limit of the oblate or prolate ellipsoid. If errors are
+        found and corrected, corrected versions will be uploaded to the
+        marketplace. 
+   
+   3.1- All systems:
+        - The documentation window may take a few seconds to load the first time
+          it is called. Also, an internet connection is required before
+          equations will render properly. Until then they will show in their
+          original TeX format.
+        - If the documentation window remains stubbornly blank, try installing a
+          different browser and set that as your default browser. Issues have
+          been noted with Internet Explorer 11.
+        - Check for Updates may fail (with the status bar message ' Cannot
+          connect to the application server') if your internet connection uses
+          a proxy server. Tested resolutions for this are described on the
+          website FAQ.
+        - The copy and paste functions (^C, ^V) in the batch mode results grid
+          require two clicks: one to select the cell and a second to select the
+          contents of the cell.
+        - The tutorial has not yet been updated and is somewhat out of date
+        - Very old computers may struggle to run the 3.x and later releases
+        - Polydispersity on multiple parameters included in a simultaneous/
+          constrained fit will likely not be correct
+        - Constrained/simultaneous fit page does not have a stop button
+        - Constrained/simultaneous fit do not accept min/max limits
+        - Save project does not store the state of all the windows
+        - Loading projects can be very slow
+        - Save Project only works once a data set has been associated with
+          a model.  Error is reported on status bar.
+        - There is a numerical precision problem with the multishell model when
+          the iner radius gets large enough (ticket #288)
+        - The angular distribution angles are not clearly defined and may in
+          some cases lead to incorrect calculations(ticket #332)
+
+   3.2- Windows:
+        - If installed to same directory as old version without first removing
+          the old version, the old desktop icon will remain but point to the
+          new exe version. Likewise all the start menu folders and items will
+          have the old name even though pointing to the new version.  Usually
+          safest to uninstall old version prior to installing new version anyway.
+
+   3.3- MAC:
+        - Application normally starts up hidden. Click icon in Dock to view/use
+          application.
+        - Multiprocessing does not currently work on MAC OS
+
+   3.4- Linux:
+        - Not well tested
+
+
+4- SasView website
+==================
+
+   - www.sasview.org.  This main project site is the gateway to all
+     information about the sasview project.  It includes information
+     about the project, a FAQ page and links to all developer and user
+     information, tools and resources.
+
+
+5- Frequently Asked Questions
+=============================
+
+   - www.sasview.org/faq.html
+
+
+6- Installer download website
+=============================
+
+   - Latest release Version
+     - https://github.com/SasView/sasview/releases
+   - Latest developer builds
+     - https://jenkins.esss.dk/sasview/view/Master-Builds/
Index: installers/installer_generator.py
===================================================================
--- installers/installer_generator.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/installer_generator.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,376 @@
+"""
+This module generates .iss file according to the local config of
+the current application. Please make sure a file named "local_config.py"
+exists in the current directory. Edit local_config.py according to your needs.
+"""
+from __future__ import print_function
+
+import local_config
+import os
+import string
+
+root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(0, os.path.join(root, 'sasview-install', 'Lib', 'site-packages'))
+from sas.sasview import local_config
+
+REG_PROGRAM = """{app}\MYPROG.EXE"" ""%1"""
+APPLICATION = str(local_config.__appname__ )+ '.exe'
+AppName = str(local_config.__appname__ )
+AppVerName = str(local_config.__appname__ )+'-'+ str(local_config.__version__)
+Dev = ''
+if AppVerName.lower().count('dev') > 0:
+    Dev = '-Dev'
+AppPublisher = local_config._copyright
+AppPublisherURL = local_config._homepage
+AppSupportURL = local_config._homepage
+AppUpdatesURL = local_config._homepage
+ChangesEnvironment = 'true'
+DefaultDirName = os.path.join("{pf}" , AppName+Dev)
+DefaultGroupName = os.path.join(local_config.DefaultGroupName, AppVerName)
+
+OutputBaseFilename = local_config.OutputBaseFilename
+SetupIconFile = "images\\ball.ico"
+LicenseFile = 'license.txt'
+DisableProgramGroupPage = 'yes'
+Compression = 'lzma'
+SolidCompression = 'yes'
+PrivilegesRequired = 'none'
+INSTALLER_FILE = 'installer'
+
+icon_path =  local_config.icon_path
+media_path = local_config.media_path
+test_path = local_config.test_path
+
+def find_extension():
+    """
+    Describe the extensions that can be read by the current application
+    """
+    list_data = []
+    list_app =[]
+    try:
+
+        #(ext, type, name, flags)
+        from sas.sascalc.dataloader.loader import Loader
+        wild_cards = Loader().get_wildcards()
+        for item in wild_cards:
+            #['All (*.*)|*.*']
+            file_type, ext = string.split(item, "|*", 1)
+            if ext.strip() not in ['.*', ''] and ext.strip() not in list_data:
+                list_data.append((ext, 'string', file_type))
+    except:
+        pass
+    try:
+        file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*", 1)
+        if ext.strip() not in ['.', ''] and ext.strip() not in list_app:
+            list_app.append((ext, 'string', file_type))
+    except:
+        pass
+    try:
+        for item in local_config.PLUGINS_WLIST:
+            file_type, ext = string.split(item, "|*", 1)
+            if ext.strip() not in ['.', ''] and ext.strip() not in list_app:
+                list_app.append((ext, 'string', file_type))
+    except:
+        pass
+    return list_data, list_app
+DATA_EXTENSION, APP_EXTENSION = find_extension()
+
+def write_registry(data_extension=None, app_extension=None):
+    """
+    create file association for windows.
+    Allow open file on double click
+    """
+    msg = ""
+    if data_extension is not None and data_extension:
+        openwithlist = "OpenWithList\%s" % str(APPLICATION)
+        msg = "\n\n[Registry]\n"
+        for (ext, type, _) in data_extension:
+            list = os.path.join(ext, openwithlist)
+            msg +=  """Root: HKCR;\tSubkey: "%s";\t""" % str(list)
+            msg += """ Flags: %s""" % str('uninsdeletekey noerror')
+            msg += "\n"
+        #list the file on right-click
+        msg += """Root: HKCR; Subkey: "applications\%s\shell\open\command";\t"""\
+                              %  str(APPLICATION)
+        msg += """ValueType: %s; """ % str('string')
+        msg += """ValueName: "%s";\t""" %str('')
+        msg += """ValueData: \"""{app}\%s""  ""%s1\"""; \t"""% (str(APPLICATION),
+                                                          str('%'))
+        msg += """ Flags: %s""" % str('uninsdeletevalue noerror')
+        msg += "\n"
+        user_list = "Software\Classes"
+        for (ext, type, _) in data_extension:
+            list = os.path.join(user_list, ext, openwithlist)
+            msg +=  """Root: HKCU;\tSubkey: "%s";\t""" % str(list)
+            msg += """ Flags: %s""" % str('uninsdeletekey noerror')
+            msg += "\n"
+        #list the file on right-click
+        user_list = os.path.join("Software", "Classes", "applications")
+        msg += """Root: HKCU; Subkey: "%s\%s\shell\open\command";\t"""\
+                              %  (str(user_list), str(APPLICATION))
+        msg += """ValueType: %s; """ % str('string')
+        msg += """ValueName: "%s";\t""" %str('')
+        msg += """ValueData: \"""{app}\%s""  ""%s1\"""; \t"""% (str(APPLICATION),
+                                                          str('%'))
+        msg += """ Flags: %s""" % str('uninsdeletevalue noerror')
+        msg += "\n"
+    if app_extension is not None and app_extension:
+        for (ext, type, _) in app_extension:
+            msg +=  """Root: HKCR;\tSubkey: "%s";\t""" % str(ext)
+            msg += """ValueType: %s;\t""" % str(type)
+            #file type empty set the current application as the default
+            #reader for this file. change the value of file_type to another
+            #string modify the default reader
+            file_type = ''
+            msg += """ValueName: "%s";\t""" % str('')
+            msg += """ValueData: "{app}\%s";\t""" % str(APPLICATION)
+            msg += """ Flags: %s""" % str('uninsdeletevalue  noerror')
+            msg += "\n"
+    msg += """Root: HKCR; Subkey: "{app}\%s";\t""" % str(APPLICATION)
+    msg += """ValueType: %s; """ % str('string')
+    msg += """ValueName: "%s";\t""" % str('')
+    msg += """ValueData: "{app}\%s";\t""" % str("SasView File")
+    msg += """ Flags: %s \t""" % str("uninsdeletekey  noerror")
+    msg += "\n"
+
+    #execute the file on double-click
+    msg += """Root: HKCR; Subkey: "{app}\%s\shell\open\command";\t"""  %  str(APPLICATION)
+    msg += """ValueType: %s; """ % str('string')
+    msg += """ValueName: "%s";\t""" %str('')
+    msg += """ValueData: \"""{app}\%s""  ""%s1\""";\t"""% (str(APPLICATION),
+                                                          str('%'))
+    msg += """ Flags: %s \t""" % str("uninsdeletevalue noerror")
+    msg += "\n"
+    #create default icon
+    msg += """Root: HKCR; Subkey: "{app}\%s";\t""" % str(SetupIconFile)
+    msg += """ValueType: %s; """ % str('string')
+    msg += """ValueName: "%s";\t""" % str('')
+    msg += """ValueData: "{app}\%s,0";\t""" % str(APPLICATION)
+    msg += """ Flags: %s \t""" % str("uninsdeletevalue noerror")
+    msg += "\n"
+
+
+    #SASVIEWPATH
+    msg += """Root: HKLM; Subkey: "%s";\t"""  %  str('SYSTEM\CurrentControlSet\Control\Session Manager\Environment')
+    msg += """ValueType: %s; """ % str('expandsz')
+    msg += """ValueName: "%s";\t""" % str('SASVIEWPATH')
+    msg += """ValueData: "{app}";\t"""
+    msg += """ Flags: %s""" % str('uninsdeletevalue noerror')
+    msg += "\n"
+
+    #PATH
+    msg += """; Write to PATH (below) is disabled; need more tests\n"""
+    msg += """;Root: HKCU; Subkey: "%s";\t"""  %  str('Environment')
+    msg += """ValueType: %s; """ % str('expandsz')
+    msg += """ValueName: "%s";\t""" % str('PATH')
+    msg += """ValueData: "%s;{olddata}";\t""" % str('%SASVIEWPATH%')
+    msg += """ Check: %s""" % str('NeedsAddPath()')
+    msg += "\n"
+
+    return msg
+
+def write_language(language=['english'], msfile="compiler:Default.isl"):
+    """
+    define the language of the application
+    """
+    msg = ''
+    if language:
+        msg = "\n\n[Languages]\n"
+        for lang in language:
+            msg += """Name: "%s";\tMessagesFile: "%s"\n""" % (str(lang),
+                                                           str(msfile))
+    return msg
+
+def write_tasks():
+    """
+    create desktop icon
+    """
+    msg = """\n\n[Tasks]\n"""
+    msg += """Name: "desktopicon";\tDescription: "{cm:CreateDesktopIcon}";\t"""
+    msg += """GroupDescription: "{cm:AdditionalIcons}";\tFlags: unchecked\n"""
+    msg += """Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}";\t"""
+    msg += """GroupDescription: "{cm:AdditionalIcons}";\n"""
+    return msg
+
+dist_path = "dist"
+def write_file():
+    """
+    copy some data files
+    """
+    msg = "\n\n[Files]\n"
+    msg += """Source: "%s\%s";\t""" % (dist_path, str(APPLICATION))
+    msg += """DestDir: "{app}";\tFlags: ignoreversion\n"""
+    msg += """Source: "dist\*";\tDestDir: "{app}";\t"""
+    msg += """Flags: ignoreversion recursesubdirs createallsubdirs\n"""
+    msg += """Source: "dist\plugin_models\*";\tDestDir: "{userdesktop}\..\.sasview\plugin_models";\t"""
+    msg += """Flags: recursesubdirs createallsubdirs\n"""
+    msg += """Source: "dist\compiled_models\*";\tDestDir: "{userdesktop}\..\.sasmodels\compiled_models";\t"""
+    msg += """Flags: recursesubdirs createallsubdirs\n"""
+    msg += """Source: "dist\config\custom_config.py";\tDestDir: "{userdesktop}\..\.sasview\config";\t"""
+    msg += """Flags: recursesubdirs createallsubdirs\n"""
+    #msg += """Source: "dist\default_categories.json";    DestDir: "{userdesktop}\..\.sasview";\t"""
+    #msg += """DestName: "categories.json";\n"""
+    msg += """;\tNOTE: Don't use "Flags: ignoreversion" on any shared system files"""
+    return msg
+
+def write_icon():
+    """
+    Create application icon
+    """
+    msg = """\n\n[Icons]\n"""
+    msg += """Name: "{group}\%s";\t""" % str(AppName)
+    msg += """Filename: "{app}\%s";\t"""  % str(APPLICATION)
+    msg += """WorkingDir: "{app}"; IconFilename: "{app}\images\\ball.ico" \n"""
+    msg += """Name: "{group}\{cm:UninstallProgram, %s}";\t""" % str(AppName)
+    msg += """ Filename: "{uninstallexe}" \n"""
+    msg += """Name: "{commondesktop}\%s";\t""" % str(AppVerName)
+    msg += """Filename: "{app}\%s";\t""" % str(APPLICATION)
+    msg += """Tasks: desktopicon; WorkingDir: "{app}" ; IconFilename: "{app}\images\\ball.ico" \n"""
+    msg += """Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\%s";\t""" % str(AppVerName)
+    msg += """Filename: "{app}\%s";\t""" % str(APPLICATION)
+    msg += """Tasks: quicklaunchicon; WorkingDir: "{app}"; IconFilename: "{app}\images\\ball.ico" \n"""
+    return msg
+
+def write_run():
+    """
+    execute some file
+    """
+    msg = """\n\n[Run]\n"""
+    msg += """Filename: "{app}\%s";\t""" % str(APPLICATION)
+    msg += """Description: "{cm:LaunchProgram, %s}";\t""" %str(AppName)
+    msg += """Flags: nowait postinstall skipifsilent\n"""
+    msg += """; Install the Microsoft C++ DLL redistributable package if it is """
+    msg += """provided and the DLLs are not present on the target system.\n"""
+    msg += """; Note that the redistributable package is included if the app was """
+    msg += """built using Python 2.6 or 2.7, but not with 2.5.\n"""
+    msg += """; Parameter options:\n"""
+    msg += """; - for silent install use: "/q"\n"""
+    msg += """; - for silent install with progress bar use: "/qb"\n"""
+    msg += """; - for silent install with progress bar but disallow """
+    msg += """cancellation of operation use: "/qb!"\n"""
+    msg += """; Note that we do not use the postinstall flag as this would """
+    msg += """display a checkbox and thus require the user to decide what to do.\n"""
+    msg += """;Filename: "{app}\\vcredist_x86.exe"; Parameters: "/qb!"; """
+    msg += """WorkingDir: "{tmp}"; StatusMsg: "Installing Microsoft Visual """
+    msg += """C++ 2008 Redistributable Package ..."; Check: InstallVC90CRT(); """
+    msg += """Flags: skipifdoesntexist waituntilterminated\n"""
+    return msg
+
+def write_dirs():
+    """
+    Define Dir permission
+    """
+    msg = """\n\n[Dirs]\n"""
+    msg += """Name: "{app}\%s";\t""" % str('')
+    msg += """Permissions: everyone-modify\t"""
+    msg += """\n"""
+    return msg
+
+def write_code():
+    """
+    Code that checks the existing path and snaviewpath
+    in the environmental viriables/PATH
+    """
+    msg = """\n\n[Code]\n"""
+    msg += """function InstallVC90CRT(): Boolean;\n"""
+    msg += """begin\n"""
+    msg += """    Result := not DirExists('C:\WINDOWS\WinSxS\\x86_Microsoft.VC90."""
+    msg += """CRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_d08d0375');\n"""
+    msg += """end;\n\n"""
+    msg += """function NeedsAddPath(): boolean;\n"""
+    msg += """var\n"""
+    msg += """  oldpath: string;\n"""
+    msg += """  newpath: string;\n"""
+    msg += """  pathArr:    TArrayOfString;\n"""
+    msg += """  i:        Integer;\n"""
+    msg += """begin\n"""
+    msg += """  RegQueryStringValue(HKEY_CURRENT_USER,'Environment',"""
+    msg += """'PATH', oldpath)\n"""
+    msg += """  oldpath := oldpath + ';';\n"""
+    msg += """  newpath := '%SASVIEWPATH%';\n"""
+    msg += """  i := 0;\n"""
+    msg += """  while (Pos(';', oldpath) > 0) do begin\n"""
+    msg += """    SetArrayLength(pathArr, i+1);\n"""
+    msg += """    pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1);\n"""
+    msg += """    oldpath := Copy(oldpath, Pos(';', oldpath)+1,"""
+    msg += """ Length(oldpath));\n"""
+    msg += """    i := i + 1;\n"""
+    msg += """    // Check if current directory matches app dir\n"""
+    msg += """    if newpath = pathArr[i-1] \n"""
+    msg += """    then begin\n"""
+    msg += """      Result := False;\n"""
+    msg += """      exit;\n"""
+    msg += """    end;\n"""
+    msg += """  end;\n"""
+    msg += """  Result := True;\n"""
+    msg += """end;\n"""
+    msg += """\n"""
+    return msg
+
+def write_uninstalldelete():
+    """
+    Define uninstalldelete
+    """
+    msg = """\n[UninstallDelete]\n"""
+    msg += """; Delete directories and files that are dynamically created by """
+    msg += """the application (i.e. at runtime).\n"""
+    msg += """Type: filesandordirs; Name: "{app}\.matplotlib"\n"""
+    msg += """Type: files; Name: "{app}\*.*"\n"""
+    msg += """; The following is a workaround for the case where the """
+    msg += """application is installed and uninstalled but the\n"""
+    msg += """;{app} directory is not deleted because it has user files.  """
+    msg += """Then the application is installed into the\n"""
+    msg += """; existing directory, user files are deleted, and the """
+    msg += """application is un-installed again.  Without the\n"""
+    msg += """; directive below, {app} will not be deleted because Inno Setup """
+    msg += """did not create it during the previous\n"""
+    msg += """; installation.\n"""
+    msg += """Type: dirifempty; Name: "{app}"\n"""
+    msg += """\n"""
+    return msg
+
+def generate_installer():
+    """
+    """
+    TEMPLATE = "\n; Script generated by the Inno Setup Script Wizard\n"
+    TEMPLATE += "\n; and local_config.py located in this directory.\n "
+    TEMPLATE += "; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!"
+    TEMPLATE += "\n[Setup]\n\n"
+    TEMPLATE += "ChangesAssociations=%s\n" %str('yes')
+    TEMPLATE += "AppName=%s\n" % str(AppName)
+    TEMPLATE += "AppVerName=%s\n" % str(AppVerName)
+    TEMPLATE += "AppPublisher=%s\n" % str(AppPublisher)
+    TEMPLATE += "AppPublisherURL=%s\n" % str(AppPublisherURL)
+    TEMPLATE += "AppSupportURL=%s\n" % str(AppSupportURL)
+    TEMPLATE += "AppUpdatesURL=%s \n" % str(AppUpdatesURL)
+    TEMPLATE += "ChangesEnvironment=%s \n" % str(ChangesEnvironment)
+    TEMPLATE += "DefaultDirName=%s\n" % str(DefaultDirName)
+    TEMPLATE += "DefaultGroupName=%s\n" % str(DefaultGroupName)
+    TEMPLATE += "DisableProgramGroupPage=%s\n" % str(DisableProgramGroupPage)
+    TEMPLATE += "LicenseFile=%s\n" % str(LicenseFile)
+    TEMPLATE += "OutputBaseFilename=%s\n" % str(OutputBaseFilename)
+    TEMPLATE += "SetupIconFile=%s\n" % str(SetupIconFile)
+    TEMPLATE += "Compression=%s\n" % str(Compression)
+    TEMPLATE += "SolidCompression=%s\n" % str(SolidCompression)
+    TEMPLATE += "PrivilegesRequired=%s\n" % str(PrivilegesRequired)
+    TEMPLATE += "UsePreviousAppDir=no\n"
+
+    TEMPLATE += write_registry(data_extension=DATA_EXTENSION,
+                                app_extension=APP_EXTENSION)
+    TEMPLATE += write_language()
+    TEMPLATE += write_tasks()
+    TEMPLATE += write_file()
+    TEMPLATE += write_icon()
+    TEMPLATE += write_run()
+    TEMPLATE += write_dirs()
+    TEMPLATE += write_code()
+    TEMPLATE += write_uninstalldelete()
+    path = '%s.iss' % str(INSTALLER_FILE)
+    f = open(path,'w')
+    f.write(TEMPLATE)
+    f.close()
+    print("Generate Inno setup installer script complete")
+    print("A new file %s.iss should be created.Please refresh your directory" % str(INSTALLER_FILE))
+
+if __name__ == "__main__":
+    generate_installer()
Index: installers/license.txt
===================================================================
--- installers/license.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/license.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,21 @@
+This software was originally developed by the University of Tennessee 
+as part of the Distributed Data Analysis of Neutron Scattering 
+Experiments (DANSE) project funded by the US National Science Foundation
+and is currently being developed as an open source project hosted on GitHub
+and managed by a consortium of scattering facilities.
+
+Participating facilities include: the University of Tennessee, the University 
+of Maryland, the European Spallation Source, the National Institute of 
+Standards & Technology Center for Neutron Research, the Oak Ridge National 
+Laboratory Neutron Sciences Directorate, the ISIS Neutron & Muon Source, the 
+Institut Laue Langevin, the Diamond Light Source, and Delft University of 
+Technology.
+
+If you use this application to do scientific research that leads to publication, 
+we kindly ask that you acknowledge the use of the software with the following 
+sentence:
+
+*"This work benefited from the use of the SasView application, originally 
+developed under NSF award DMR-0520547."*
+
+(C) 2009-2015 UTK, UMD, ESS, NIST, ORNL, ISIS, ILL, DLS, DUT
Index: installers/macholib_patch.py
===================================================================
--- installers/macholib_patch.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/macholib_patch.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,27 @@
+"""
+MachOlib fix
+============
+
+Monkey-patch macholib to get around error in v1.7 and earlier, which
+gives:: 
+
+    TypeError: dyld_find() got an unexpected keyword argument 'loader'
+
+Add the following to the top of your setup_py2app to work around this::
+
+    import macholib_patch
+"""
+
+import macholib
+#print("~"*60 + "macholib verion: "+macholib.__version__)
+if macholib.__version__ <= "1.7":
+    print("Applying macholib patch...")
+    import macholib.dyld
+    import macholib.MachOGraph
+    dyld_find_1_7 = macholib.dyld.dyld_find
+    def dyld_find(name, loader=None, **kwargs):
+        #print("~"*60 + "calling alternate dyld_find")
+        if loader is not None:
+            kwargs['loader_path'] = loader
+        return dyld_find_1_7(name, **kwargs)
+    macholib.MachOGraph.dyld_find = dyld_find
Index: installers/sasview.spec
===================================================================
--- installers/sasview.spec	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/sasview.spec	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,182 @@
+# -*- mode: python -*-
+# Modifiable location
+import sys
+import os
+import platform
+
+import warnings
+from distutils.filelist import findall
+
+PYTHON_LOC = sys.exec_prefix
+# Portability settings
+if os.name == 'posix':
+    LIBPREFIX='lib'
+    LIBSUFFIX='so'
+    LIBLOC = os.path.join(PYTHON_LOC,'lib')
+    # Darwin needs UPX=False, Linux actually builds with both...
+    if platform.system() == 'Darwin':
+        UPX=False
+    else:
+        UPX=True
+else:
+    LIBPREFIX=''
+    LIBSUFFIX='dll'
+    LIBLOC = os.path.join(PYTHON_LOC,'Library','bin')
+    UPX=True
+
+SCRIPT_TO_SOURCE = 'sasview.py'
+
+# Warning! pyinstaller/py2exe etc. don't have the __file__ attribute
+# WORK_DIR = os.path.dirname(os.path.realpath(__file__))
+WORK_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
+
+#### LOCAL METHODS
+def add_data(data):
+    for component in data:
+        target = component[0]
+        for filename in component[1]:
+           datas.append((filename, target))
+
+def add_binary(binary):
+    return (os.path.join(LIBLOC,binary),'.')
+
+# ADDITIONAL DATA ############################################################
+datas = [('images', 'images')]
+
+datas.append(('media','media'))
+datas.append(('test','test'))
+datas.append(('custom_config.py','.'))
+datas.append(('local_config.py','.'))
+datas.append(('wxcruft.py','.'))
+datas.append(('welcome_panel.py','.'))
+
+# TODO
+# NEED BETTER WAY TO DEAL WITH THESE RELATIVE PATHS
+datas.append((os.path.join('..','..','sasmodels','sasmodels'),'sasmodels'))
+datas.append((os.path.join('..','src','sas','sasgui','perspectives','fitting','plugin_models'),'plugin_models'))
+
+# precompile sas models into the sasview build path; doesn't matter too much
+# where it is so long as it is a place that will get cleaned up afterwards.
+import sasmodels.core
+dll_path = 'compiled_models'
+if not (os.path.exists(dll_path)):
+    os.mkdir(dll_path)
+dll_path2 = os.path.join(dll_path, dll_path)
+if not (os.path.exists(dll_path2)):
+    os.mkdir(dll_path2)
+
+compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double')
+
+# include the compiled models as data; coordinate the target path for the
+# data with installer_generator.py
+datas.append((os.path.join('compiled_models','compiled_models'),'compiled_models'))
+
+# These depend on whether we have MKL or Atlas numpy
+if os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'mkl_core.' + LIBSUFFIX)):
+    datas.append(add_binary(LIBPREFIX + 'mkl_avx2.' + LIBSUFFIX))
+    datas.append(add_binary(LIBPREFIX + 'mkl_def.' + LIBSUFFIX))
+elif os.path.exists(os.path.join(LIBLOC, LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX)):
+    datas.append(add_binary(LIBPREFIX + 'numpy-atlas.' + LIBSUFFIX))
+else:
+    raise Exception("No numerical library for numpy found.")
+
+import sas.sascalc.dataloader.readers
+f = os.path.join(sas.sascalc.dataloader.readers.get_data_path(), 'defaults.json')
+datas.append((f, '.'))
+
+# Add a custom pyopencl hook, as described in
+# https://github.com/pyinstaller/pyinstaller/issues/2130
+from PyInstaller.utils.hooks import copy_metadata
+datas.append(copy_metadata('pyopencl')[0])
+
+import sasmodels
+add_data(sasmodels.data_files())
+
+try:
+    import tinycc
+    add_data(tinycc.data_files())
+except ImportError:
+    warnings.warn("TinyCC package is not available and will not be included")
+
+import periodictable
+add_data(periodictable.data_files())
+
+import matplotlib
+matplotlibdatadir = matplotlib.get_data_path()
+matplotlibdata = findall(matplotlibdatadir)
+for f in matplotlibdata:
+    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
+    datas.append((f, os.path.split(dirname)[0]))
+
+binaries = []
+
+# EXCLUDED FILES ############################################################
+# Spelled out to enable easier editing
+excludes = []
+excludes.append('libzmq')
+excludes.append('IPython')
+excludes.append('PyQt4')
+excludes.append('PySide')
+excludes.append('Qt4')
+excludes.append('Tkinter')
+excludes.append('tk')
+excludes.append('tcl')
+# Seems we cannot build on Linux without bundling sip
+if not platform.system() == 'Linux':
+    excludes.append('sip')
+excludes.append('sympy')
+excludes.append('pytz')
+excludes.append('sklearn')
+excludes.append('zmq')
+
+# Need to explicitly exclude sasmodels here!!
+excludes.append('sasmodels')
+
+# HIDDEN MODULES ############################################################
+hiddenimports = [
+ 'periodictable.core',
+ 'sasmodels.core',
+ 'pyopencl',
+ 'tinycc'
+]
+
+a = Analysis([SCRIPT_TO_SOURCE],
+             pathex=[WORK_DIR],
+             binaries=binaries,
+             datas=datas,
+             hiddenimports=hiddenimports,
+             hookspath=[],
+             runtime_hooks=[],
+             excludes=excludes,
+             win_no_prefer_redirects=False,
+             win_private_assemblies=False,
+             cipher=None)
+
+pyz = PYZ(a.pure, a.zipped_data,
+             cipher=None)
+
+exe = EXE(pyz,
+          a.scripts,
+          exclude_binaries=True,
+          name='sasview',
+          debug=False,
+          upx=UPX,
+          icon=os.path.join("images","ball.ico"),
+          version="version.txt",
+          console=False )
+
+# COLLECT creates a directory instead of a single file.
+coll = COLLECT(exe,
+               a.binaries,
+               a.zipfiles,
+               a.datas,
+               strip=False,
+               upx=UPX,
+               name='sasview')
+
+if platform.system() == 'Darwin':
+    app = BUNDLE(exe,
+        name='SasView.app',
+        icon='images/ball.ico',
+        bundle_identifier=None)
+
Index: installers/sasview_console.py
===================================================================
--- installers/sasview_console.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/sasview_console.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,2 @@
+from sas.sasview.sasview import run_cli
+run_cli()
Index: installers/sasview_gui.py
===================================================================
--- installers/sasview_gui.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/sasview_gui.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,2 @@
+from sas.sasview.sasview import run_gui
+run_gui()
Index: installers/setup.cfg
===================================================================
--- installers/setup.cfg	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/setup.cfg	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,2 @@
+[py2app]
+argv-emulation=1
Index: installers/setup_exe.py
===================================================================
--- installers/setup_exe.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/setup_exe.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,403 @@
+#!/usr/bin/env python
+
+#
+# The setup to create a Windows executable.
+# Inno Setup can then be used with the installer.iss file
+# in the top source directory to create an installer.
+#
+# Setuptools clashes with py2exe 0.6.8 (and probably later too).
+# For that reason, most of the code needs to have direct imports
+# that are not going through pkg_resources.
+#
+# Attention should be paid to dynamic imports. Data files can
+# be added to the distribution directory for that purpose.
+# See for example the 'images' directory below.
+from __future__ import print_function
+
+import os
+import sys
+import warnings
+from glob import glob
+import shutil
+
+from distutils.util import get_platform
+from distutils.core import setup
+from distutils.filelist import findall
+from distutils.sysconfig import get_python_lib
+import py2exe
+
+#from idlelib.PyShell import warning_stream
+
+# put the build directory at the front of the path
+if os.path.abspath(os.path.dirname(__file__)) != os.path.abspath(os.getcwd()):
+    raise RuntimeError("Must run setup_exe from the sasview directory")
+root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+platform = '%s-%s'%(get_platform(), sys.version[:3])
+doc_path = os.path.join(root, 'build', 'lib.'+platform, 'doc')
+build_path = os.path.join(root, 'sasview-install', 'Lib', 'site-packages')
+sys.path.insert(0, build_path)
+
+from sas.sasview import local_config
+from installer_generator import generate_installer
+
+import matplotlib
+try:
+    import tinycc
+except ImportError:
+    warnings.warn("TinyCC package is not available and will not be included")
+    tinycc = None
+
+if len(sys.argv) == 1:
+    sys.argv.append('py2exe')
+
+# When using the SasView build script, we need to be able to pass
+# an extra path to be added to the python path. The extra arguments
+# should be removed from the list so that the setup processing doesn't
+# fail.
+try:
+    if sys.argv.count('--extrapath'):
+        path_flag_idx = sys.argv.index('--extrapath')
+        extra_path = sys.argv[path_flag_idx+1]
+        sys.path.insert(0, extra_path)
+        del sys.argv[path_flag_idx+1]
+        sys.argv.remove('--extrapath')
+except:
+    print("Error processing extra python path needed to build SasView\n  %s" %
+          sys.exc_value)
+
+
+# Solution taken from here: http://www.py2exe.org/index.cgi/win32com.shell
+# ModuleFinder can't handle runtime changes to __path__, but win32com uses them
+win32_folder = "win32comext"
+try:
+    # py2exe 0.6.4 introduced a replacement modulefinder.
+    # This means we have to add package paths there, not to the built-in
+    # one.  If this new modulefinder gets integrated into Python, then
+    # we might be able to revert this some day.
+    # if this doesn't work, try import modulefinder
+    try:
+        import py2exe.mf as modulefinder
+    except ImportError:
+        import modulefinder
+    import win32com
+    for p in win32com.__path__[1:]:
+        modulefinder.AddPackagePath(win32_folder, p)
+    for extra in ["win32com.shell", "win32com.adsi", "win32com.axcontrol",
+                  "win32com.axscript", "win32com.bits", "win32com.ifilter",
+                  "win32com.internet", "win32com.mapi", "win32com.propsys",
+                  "win32com.taskscheduler"]:
+        __import__(extra)
+        m = sys.modules[extra]
+        for p in m.__path__[1:]:
+            modulefinder.AddPackagePath(extra, p)
+
+except ImportError:
+    # no build path setup, no worries.
+    pass
+
+# Remove the build folder
+shutil.rmtree("build", ignore_errors=True)
+# do the same for dist folder
+shutil.rmtree("dist", ignore_errors=True)
+
+is_64bits = sys.maxsize > 2**32
+arch = "amd64" if is_64bits else "x86"
+manifest = """
+    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+      <assemblyIdentity
+        version="5.0.0.0"
+        processorArchitecture="%(arch)s"
+        name="SasView"
+        type="win32">
+      </assemblyIdentity>
+      <description>SasView</description>
+      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+        <security>
+          <requestedPrivileges>
+            <requestedExecutionLevel
+              level="asInvoker"
+              uiAccess="false">
+            </requestedExecutionLevel>
+          </requestedPrivileges>
+        </security>
+      </trustInfo>
+      <dependency>
+        <dependentAssembly>
+          <assemblyIdentity
+            type="win32"
+            name="Microsoft.VC90.CRT"
+            version="9.0.21022.8"
+            processorArchitecture="%(arch)s"
+            publicKeyToken="1fc8b3b9a1e18e3b">
+          </assemblyIdentity>
+        </dependentAssembly>
+      </dependency>
+      <dependency>
+        <dependentAssembly>
+          <assemblyIdentity
+            type="win32"
+            name="Microsoft.Windows.Common-Controls"
+            version="6.0.0.0"
+            processorArchitecture="%(arch)s"
+            publicKeyToken="6595b64144ccf1df"
+            language="*">
+          </assemblyIdentity>
+        </dependentAssembly>
+      </dependency>
+    </assembly>
+    """%{'arch': arch}
+
+if is_64bits:
+    msvcrtdll = glob(r"C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
+else:
+    msvcrtdll = glob(r"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*")
+if msvcrtdll:
+    msvcrtdll_data_files = ("Microsoft.VC90.CRT", msvcrtdll)
+else:
+    msvcrtdll_data_files = None
+
+
+class Target:
+    def __init__(self, **kw):
+        self.__dict__.update(kw)
+        # for the versioninfo resources
+        self.version = local_config.__version__
+        self.company_name = "SasView.org"
+        self.copyright = "copyright 2009 - 2016"
+        self.name = "SasView"
+
+#
+# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
+# to use the MatPlotLib.
+#
+path = os.getcwd()
+
+matplotlibdatadir = matplotlib.get_data_path()
+matplotlibdata = findall(matplotlibdatadir)
+
+DATA_FILES = []
+
+if tinycc:
+    DATA_FILES += tinycc.data_files()
+
+# Copying SLD data
+import periodictable
+DATA_FILES += periodictable.data_files()
+
+from sas.sasgui.perspectives import fitting
+DATA_FILES += fitting.data_files()
+
+from sas.sasgui.perspectives import calculator
+DATA_FILES += calculator.data_files()
+
+from sas.sasgui.perspectives import invariant
+DATA_FILES += invariant.data_files()
+
+from sas.sasgui import guiframe
+DATA_FILES += guiframe.data_files()
+
+# precompile sas models into the sasview build path; doesn't matter too much
+# where it is so long as it is a place that will get cleaned up afterwards.
+import sasmodels.core
+dll_path = os.path.join(build_path, 'compiled_models')
+compiled_dlls = sasmodels.core.precompile_dlls(dll_path, dtype='double')
+
+# include the compiled models as data; coordinate the target path for the
+# data with installer_generator.py
+DATA_FILES.append(('compiled_models', compiled_dlls))
+
+import sasmodels
+DATA_FILES += sasmodels.data_files()
+
+for f in matplotlibdata:
+    dirname = os.path.join('mpl-data', f[len(matplotlibdatadir)+1:])
+    DATA_FILES.append((os.path.split(dirname)[0], [f]))
+
+# Copy the settings file for the sas.dataloader file extension associations
+from sas.sascalc.dataloader import readers
+reader_config = os.path.join(readers.get_data_path(), 'defaults.json')
+if os.path.isfile(reader_config):
+    DATA_FILES.append(('.', [reader_config]))
+
+# Copy the config files
+sasview_path = os.path.join('..','src','sas','sasview')
+config_files = [
+    'custom_config.py',
+    'local_config.py',
+    'logging.init',
+    #'default_categories.json',
+    ]
+DATA_FILES.append(('.', [os.path.join(sasview_path, v) for v in config_files]))
+DATA_FILES.append(('config', [os.path.join(sasview_path, 'custom_config.py')]))
+
+# default_categories.json is beside the config files
+category_config = os.path.join(os.path.dirname(local_config_file),
+                               'default_categories.json')
+if os.path.isfile(category_config):
+    DATA_FILES.append(('.', [category_config]))
+
+if os.path.isfile("BUILD_NUMBER"):
+    DATA_FILES.append(('.', ["BUILD_NUMBER"]))
+
+images_dir = local_config.icon_path
+media_dir = local_config.media_path
+test_dir = local_config.test_path
+test_1d_dir = os.path.join(test_dir, "1d_data")
+test_2d_dir = os.path.join(test_dir, "2d_data")
+test_save_dir = os.path.join(test_dir, "save_states")
+test_upcoming_dir = os.path.join(test_dir, "upcoming_formats")
+
+# Copying the images directory to the distribution directory.
+for f in findall(images_dir):
+    DATA_FILES.append(("images", [f]))
+
+# Copying the HTML help docs
+for f in findall(media_dir):
+    DATA_FILES.append(("media", [f]))
+
+# Copying the sample data user data
+for f in findall(test_1d_dir):
+    DATA_FILES.append((os.path.join("test","1d_data"), [f]))
+
+# Copying the sample data user data
+for f in findall(test_2d_dir):
+    DATA_FILES.append((os.path.join("test","2d_data"), [f]))
+
+# Copying the sample data user data
+for f in findall(test_save_dir):
+    DATA_FILES.append((os.path.join("test","save_states"), [f]))
+
+# Copying the sample data user data
+for f in findall(test_upcoming_dir):
+    DATA_FILES.append((os.path.join("test","upcoming_formats"), [f]))
+
+# Copying opencl include files
+site_loc = get_python_lib()
+opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl")
+for f in findall(opencl_include_dir):
+    DATA_FILES.append((os.path.join("includes","pyopencl"), [f]))
+
+# Numerical libraries
+python_root = os.path.dirname(os.path.abspath(sys.executable))
+def dll_check(dll_path, dlls):
+    dll_includes = [os.path.join(dll_path, dll+'.dll') for dll in dlls]
+    return [dll for dll in dll_includes if os.path.exists(dll)]
+
+# Check for ATLAS
+numpy_path = os.path.join(python_root, 'lib', 'site-packages', 'numpy', 'core')
+atlas_dlls = dll_check(numpy_path, ['numpy-atlas'])
+
+# Check for MKL
+mkl_path = os.path.join(python_root, 'Library', 'bin')
+mkl_dlls = dll_check(mkl_path, ['mkl_core', 'mkl_def', 'libiomp5md'])
+
+if atlas_dlls:
+    DATA_FILES.append(('.', atlas_dlls))
+elif mkl_dlls:
+    DATA_FILES.append(('.', mkl_dlls))
+
+# See if the documentation has been built, and if so include it.
+if os.path.exists(doc_path):
+    for dirpath, dirnames, filenames in os.walk(doc_path):
+        for filename in filenames:
+            sub_dir = os.path.join("doc", os.path.relpath(dirpath, doc_path))
+            DATA_FILES.append((sub_dir, [os.path.join(dirpath, filename)]))
+else:
+    raise Exception("You must first build the documentation before creating an installer.")
+
+if msvcrtdll_data_files is not None:
+    # install the MSVC 9 runtime dll's into the application folder
+    DATA_FILES.append(msvcrtdll_data_files)
+
+# NOTE:
+#  need an empty __init__.py in site-packages/numpy/distutils/tests and site-packages/mpl_toolkits
+
+# packages
+#
+packages = [
+    'matplotlib', 'scipy', 'encodings', 'comtypes', 'h5py',
+    'win32com', 'xhtml2pdf', 'bumps','sasmodels', 'sas',
+    ]
+packages.extend([
+    'reportlab',
+    'reportlab.graphics.charts',
+    'reportlab.graphics.samples',
+    'reportlab.graphics.widgets',
+    'reportlab.graphics.barcode',
+    'reportlab.graphics',
+    'reportlab.lib',
+    'reportlab.pdfbase',
+    'reportlab.pdfgen',
+    'reportlab.platypus',
+    ])
+packages.append('periodictable.core') # not found automatically
+
+# For an interactive interpreter, SasViewCom
+packages.extend(['IPython','pyreadline','pyreadline.unicode_helper'])
+
+# individual models
+includes = ['site', 'lxml._elementpath', 'lxml.etree']
+
+if tinycc:
+    packages.append('tinycc')
+
+# Exclude packages that are not needed but are often found on build systems
+excludes = ['Tkinter', 'PyQt4', '_tkagg', 'sip', 'pytz', 'sympy']
+
+
+    # Various matplotlib backends we are not using
+    'libgdk_pixbuf-2.0-0.dll', 'libgobject-2.0-0.dll', 'libgdk-win32-2.0-0.dll',
+    'tcl84.dll', 'tk84.dll', 'QtGui4.dll', 'QtCore4.dll',
+    # numpy 1.8 openmp bindings (still seems to use all the cores without them)
+    # ... but we seem to need them when building from anaconda, so don't exclude ...
+    #'libiomp5md.dll', 'libifcoremd.dll', 'libmmd.dll', 'svml_dispmd.dll','libifportMD.dll',
+    'numpy-atlas.dll',
+    # microsoft C runtime (not allowed to ship with the app; need to ship vcredist
+    'msvcp90.dll',
+    # 32-bit windows console piping
+    'w9xpopen.exe',
+    # accidental links to msys/cygwin binaries; shouldn't be needed
+    'cygwin1.dll',
+    # no need to distribute OpenCL.dll - users should have their own copy
+    'OpenCL.dll'
+    ]
+
+target_wx_client = Target(
+    description = 'SasView',
+    script = 'sasview_gui.py',
+    icon_resources = [(1, local_config.SetupIconFile_win)],
+    other_resources = [(24, 1, manifest)],
+    dest_base = "SasView"
+)
+
+target_console_client = Target(
+    description = 'SasView console',
+    script = 'sasview_console.py',
+    icon_resources = [(1, local_config.SetupIconFile_win)],
+    other_resources = [(24, 1, manifest)],
+    dest_base = "SasViewCom"
+)
+
+bundle_option = 3 if is_64bits else 2
+generate_installer()
+#initialize category stuff
+#from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller
+#CategoryInstaller.check_install(s)
+
+setup(
+    windows=[target_wx_client],
+    console=[target_console_client],
+    options={
+        'py2exe': {
+            'dll_excludes': dll_excludes,
+            'packages': packages,
+            'includes': includes,
+            'excludes': excludes,
+            "compressed": 1,
+            "optimize": 0,
+            "bundle_files": bundle_option,
+            },
+    },
+    data_files=DATA_FILES,
+)
Index: installers/setup_mac.py
===================================================================
--- installers/setup_mac.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/setup_mac.py	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,216 @@
+"""
+This is a setup.py script partly generated by py2applet
+
+Usage:
+    python setup.py py2app
+
+
+NOTES:
+   12/01/2011: When seeing an error related to pytz.zoneinfo not being found, change the following line in py2app/recipes/matplotlib.py
+               mf.import_hook('pytz.tzinfo', m, ['UTC'])
+   12/05/2011: Needs macholib >= 1.4.3 and py2app >= 0.6.4 to create a 64-bit app
+"""
+from __future__ import print_function
+
+import os
+import string
+import sys
+
+from distutils.util import get_platform
+from distutils.filelist import findall
+from distutils.sysconfig import get_python_lib
+
+from setuptools import setup
+
+import macholib_patch
+
+root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+platform = '%s-%s'%(get_platform(), sys.version[:3])
+doc_path = os.path.join(root, 'build', 'lib.'+platform, 'doc')
+env = os.path.join(root, 'sasview-install', 'lib', 'python2.7', 'site-packages')
+#sys.path.insert(0, env)
+
+#Extending recursion limit
+sys.setrecursionlimit(10000)
+
+print("BUILDING PATH INSIDE", env)
+
+from sas.sasview import local_config
+
+ICON = local_config.SetupIconFile_mac
+RESOURCES_FILES = []
+DATA_FILES = []
+
+#Periodictable data file
+import periodictable
+DATA_FILES += periodictable.data_files()
+#invariant and calculator help doc
+from sas.sasgui.perspectives import fitting
+DATA_FILES += fitting.data_files()
+from sas.sasgui.perspectives import calculator
+DATA_FILES += calculator.data_files()
+from sas.sasgui.perspectives import invariant
+DATA_FILES += invariant.data_files()
+import sasmodels
+DATA_FILES += sasmodels.data_files()
+from sas.sasgui import guiframe
+DATA_FILES += guiframe.data_files()
+
+#CANSAxml reader data files
+from sas.sascalc.dataloader import readers
+RESOURCES_FILES.append(os.path.join(readers.get_data_path(),'defaults.json'))
+
+# Copy the config files
+sasview_path = os.path.join('..','src','sas','sasview')
+custom_config_file = os.path.join(sasview_path, 'custom_config.py')
+local_config_file = os.path.join(sasview_path, 'local_config.py')
+logging_ini = os.path.join(sasview_path, 'logging.ini')
+DATA_FILES.append(('.', [custom_config_file]))
+DATA_FILES.append(('config', [custom_config_file]))
+DATA_FILES.append(('.', [local_config_file]))
+DATA_FILES.append(('.', [logging_ini]))
+
+# default_categories.json is beside the config files
+category_config = os.path.join(sasview_path, 'default_categories.json')
+if os.path.isfile(category_config):
+    DATA_FILES.append(('.', [category_config]))
+
+if os.path.isfile("BUILD_NUMBER"):
+    DATA_FILES.append(('.', ["BUILD_NUMBER"]))
+
+images_dir = local_config.icon_path
+media_dir = local_config.media_path
+test_dir = local_config.test_path
+test_1d_dir = os.path.join(test_dir, "1d_data")
+test_2d_dir = os.path.join(test_dir, "2d_data")
+test_save_dir = os.path.join(test_dir, "save_states")
+test_upcoming_dir = os.path.join(test_dir, "upcoming_formats")
+
+# Copying the images directory to the distribution directory.
+for f in findall(images_dir):
+    DATA_FILES.append(("images", [f]))
+
+# Copying the HTML help docs
+for f in findall(media_dir):
+    DATA_FILES.append(("media", [f]))
+
+# Copying the sample data user data
+for f in findall(test_1d_dir):
+    DATA_FILES.append((os.path.join("test","1d_data"), [f]))
+
+# Copying the sample data user data
+for f in findall(test_2d_dir):
+    DATA_FILES.append((os.path.join("test","2d_data"), [f]))
+
+# Copying the sample data user data
+for f in findall(test_save_dir):
+    DATA_FILES.append((os.path.join("test","save_states"), [f]))
+
+# Copying the sample data user data
+for f in findall(test_upcoming_dir):
+    DATA_FILES.append((os.path.join("test","upcoming_formats"), [f]))
+
+# Copying opencl include files
+site_loc = get_python_lib()
+opencl_include_dir = os.path.join(site_loc, "pyopencl", "cl")
+for f in findall(opencl_include_dir):
+    DATA_FILES.append((os.path.join("includes","pyopencl"), [f]))
+
+# See if the documentation has been built, and if so include it.
+print(doc_path)
+if os.path.exists(doc_path):
+    for dirpath, dirnames, filenames in os.walk(doc_path):
+        for filename in filenames:
+            sub_dir = os.path.join("doc", os.path.relpath(dirpath, doc_path))
+            DATA_FILES.append((sub_dir, [os.path.join(dirpath, filename)]))
+else:
+    raise Exception("You must first build the documentation before creating an installer.")
+
+# locate file extensions
+def find_extension():
+    """
+    Describe the extensions that can be read by the current application
+    """
+    try:
+        list = []
+        EXCEPTION_LIST = ['*', '.', '']
+        from sas.sascalc.dataloader.loader import Loader
+        wild_cards = Loader().get_wildcards()
+        for item in wild_cards:
+            #['All (*.*)|*.*']
+            file_type, ext = string.split(item, "|*.", 1)
+            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list:
+                list.append(ext)
+    except:
+        pass
+    try:
+        file_type, ext = string.split(local_config.APPLICATION_WLIST, "|*.", 1)
+        if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list:
+            list.append(ext)
+    except:
+        pass
+    try:
+        for item in local_config.PLUGINS_WLIST:
+            file_type, ext = string.split(item, "|*.", 1)
+            if ext.strip() not in EXCEPTION_LIST and ext.strip() not in list:
+                list.append(ext)
+    except:
+        pass
+
+    return list
+
+EXTENSIONS_LIST = find_extension()
+
+
+plist = dict(CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=EXTENSIONS_LIST,
+                                         CFBundleTypeIconFile=ICON,
+                                   CFBundleTypeName="sasview file",
+                                   CFBundleTypeRole="Shell" )],)
+
+# Locate libxml2 library
+lib_locs = ['/usr/local/lib', '/usr/lib']
+libxml_path = None
+for item in lib_locs:
+    libxml_path_test = '%s/libxml2.2.dylib' % item
+    if os.path.isfile(libxml_path_test):
+        libxml_path = libxml_path_test
+if libxml_path == None:
+    raise RuntimeError, "Could not find libxml2 on the system"
+
+#Get version - NB nasty hack. Need to find correct way to give path to installed sasview (AJJ)
+#h5py has been added to packages. It requires hdf5 to be installed separetly
+#
+
+from sas.sasview import __version__ as VERSION
+APPNAME = "SasView "+VERSION
+DMGNAME = "SasView-"+VERSION+"-MacOSX"
+APP = ['sasview_gui.py']
+
+EXCLUDES = ['PyQt4', 'sip', 'QtGui']
+
+OPTIONS = {'argv_emulation': True,
+           'packages': ['lxml', 'numpy', 'scipy', 'pytz', 'encodings',
+                        'encodings', 'matplotlib', 'periodictable',
+                        'reportlab', 'sasmodels', 'pyopencl', 'h5py',
+                       ],
+           'iconfile': ICON,
+           'frameworks': [libxml_path],
+           'resources': RESOURCES_FILES,
+           'plist': plist,
+           'excludes' : EXCLUDES,
+          }
+setup(
+    name=APPNAME,
+    app=APP,
+    data_files=DATA_FILES,
+    include_package_data=True,
+    options={'py2app': OPTIONS},
+    setup_requires=['py2app'],
+)
+
+#Build dmg
+DMG = "dist/%s.dmg"%DMGNAME
+if os.path.exists(DMG):
+    os.unlink(DMG)
+os.system('cd dist && ../../build_tools/dmgpack.sh "%s" "%s.app"'%(DMGNAME, APPNAME))
+os.system('chmod a+r "%s"'%DMG)
Index: installers/version.txt
===================================================================
--- installers/version.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
+++ installers/version.txt	(revision 2f6d340b9cd179b18c2a4efe77d149f45c7e98de)
@@ -0,0 +1,44 @@
+# UTF-8
+#
+# For more details about fixed file info 'ffi' see:
+# http://msdn.microsoft.com/en-us/library/ms646997.aspx
+VSVersionInfo(
+  ffi=FixedFileInfo(
+    # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
+    # Set not needed items to zero 0.
+    filevers=(0, 0, 0, 0),
+    prodvers=(4, 1, 0, 0),
+    # Contains a bitmask that specifies the valid bits 'flags'
+    mask=0x3f,
+    # Contains a bitmask that specifies the Boolean attributes of the file.
+    flags=0x0,
+    # The operating system for which this file was designed.
+    # 0x4 - NT and there is no need to change it.
+    OS=0x4,
+    # The general type of file.
+    # 0x1 - the file is an application.
+    fileType=0x1,
+    # The function of the file.
+    # 0x0 - the function is not defined for this fileType
+    subtype=0x0,
+    # Creation date and time stamp.
+    date=(0, 0)
+    ),
+  kids=[
+    StringFileInfo(
+      [
+      StringTable(
+        u'040904b0',
+        [StringStruct(u'CompanyName', u'SAS Community Project'),
+        StringStruct(u'ProductName', u'SasView'),
+        StringStruct(u'ProductVersion', u'4, 0, 0, 0'),
+        StringStruct(u'InternalName', u'SasView'),
+        StringStruct(u'OriginalFilename', u'sasview.exe'),
+        StringStruct(u'FileVersion', u'96, 12, 19, 1'),
+        StringStruct(u'FileDescription', u'SasView'),
+        StringStruct(u'LegalCopyright', u'Free'),])
+      ]),
+    VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
+  ]
+)
+
