pax_global_header00006660000000000000000000000064140753170140014514gustar00rootroot0000000000000052 comment=ffdd96e51c114849b14669ed0ea5f85e837ce635 freesas-0.9.0/000077500000000000000000000000001407531701400131525ustar00rootroot00000000000000freesas-0.9.0/.github/000077500000000000000000000000001407531701400145125ustar00rootroot00000000000000freesas-0.9.0/.github/workflows/000077500000000000000000000000001407531701400165475ustar00rootroot00000000000000freesas-0.9.0/.github/workflows/python-package-mac.yml000066400000000000000000000032621407531701400227450ustar00rootroot00000000000000# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Python package Mac on: push: pull_request: jobs: build: runs-on: macos-latest strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9] xcode-version: [latest-stable, 11] steps: - uses: actions/checkout@v2 - name: Configure xcode ${{ matrix.xcode-version }} uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: ${{ matrix.xcode-version }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Build and install with pip run: | pip install . - name: Test of run_tests.py run: | python setup.py build test - name: Run end to end tests with e2etest.py run: | mkdir empty cd empty pip install -r ../e2etest/requirements_e2e.txt python ../e2etest/e2etest.py freesas-0.9.0/.github/workflows/python-package-ubuntu.yml000066400000000000000000000034021407531701400235230ustar00rootroot00000000000000# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Python package Ubuntu on: push: pull_request: jobs: build: defaults: run: working-directory: . runs-on: ubuntu-latest strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Set up Perl version for package build uses: shogo82148/actions-setup-perl@v1 with: perl-version: '5.32' - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Build and install with pip run: | pip install . - name: Test of run_tests.py run: | python setup.py build test - name: Run end to end tests with e2etest.py run: | mkdir empty cd empty pip install -r ../e2etest/requirements_e2e.txt python ../e2etest/e2etest.py freesas-0.9.0/.gitignore000066400000000000000000000014241407531701400151430ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # C extensions *.so *.c # Distribution / packaging .Python env/ venv/ build/ develop-eggs/ dist/ downloads/ eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .mypy_cache/ .coverage .cache nosetests.xml coverage.xml coverage.rst # Translations *.mo *.pot # Django stuff: *.log # Sphinx documentation docs/_build/ # PyBuilder target/ #IDEs workspace.code-workspace # OS files .DS_Store .vscode/settings.json freesas-0.9.0/.readthedocs.yml000066400000000000000000000011051407531701400162350ustar00rootroot00000000000000# .readthedocs.yml # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Build documentation in the docs/ directory with Sphinx sphinx: configuration: doc/source/conf.py # Optionally build your docs in additional formats such as PDF #formats: # - pdf # Optionally set the version of Python and requirements required to build your docs python: version: 3.7 install: - requirements: requirements.txt - requirements: ci/requirements_rtd.txt - method: setuptools path: . freesas-0.9.0/.travis.yml000066400000000000000000000043741407531701400152730ustar00rootroot00000000000000 language: python jobs: include: - name: "Python 3.6.0 on Xenial Linux" python: 3.6 # this works for Linux but is ignored on macOS or Windows - name: "Python 3.7.0 on Xenial Linux" python: 3.7 # this works for Linux but is ignored on macOS or Windows - name: "Python 3.8.0 on Xenial Linux" python: 3.8 # this works for Linux but is ignored on macOS or Windows - name: "Python 3.9.0 on Xenial Linux" python: 3.9 # this works for Linux but is ignored on macOS or Windows - name: "xcode 10.2 on macOS" os: osx osx_image: xcode10.2 language: shell # 'language: python' is an error on Travis CI macOS - name: "xcode 9.4 on macOS" os: osx osx_image: xcode9.4 language: shell # 'language: python' is an error on Travis CI macOS - name: "xcode 11.2 on macOS" os: osx osx_image: xcode11.2 language: shell # 'language: python' is an error on Travis CI macOS cache: apt: true directories: - $HOME/.cache/pip addons: apt: packages: - libhdf5-dev before_install: # activate env for mac - if [[ "$OSTYPE" == "darwin"* ]]; then python3 -m venv env && source env/bin/activate; fi install: # Upgrade distribution modules - "pip3 install --upgrade setuptools" - "pip3 install --upgrade pip" # Install build dependencies - "pip3 install wheel" - "pip3 install --trusted-host www.silx.org --trusted-host www.edna-site.org -r ci/requirement_travis.txt --upgrade --find-links http://www.silx.org/pub/wheelhouse" # Print Python info - "python3 ci/info_platform.py" - "pip3 freeze" # Build - "python3 setup.py build" - "python3 setup.py bdist_wheel" - "ls dist" # Install generated wheel - "pip3 install --pre --find-links dist/ --trusted-host www.silx.org --trusted-host www.edna-site.org --find-links http://www.silx.org/pub/wheelhouse freesas" script: # Print Python info - "python3 ci/info_platform.py" - "pip3 freeze" - "python3 --version" - "gcc --version" # Run the tests - "python3 setup.py build test" - "python3 run_tests.py" #Run end to end tests - "mkdir empty" - "cd empty" - "python3 ../e2etest/e2etest.py" freesas-0.9.0/CHANGELOG.txt000066400000000000000000000000341407531701400151770ustar00rootroot00000000000000see doc/source/changelog.rstfreesas-0.9.0/LICENSE000066400000000000000000000020721407531701400141600ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014 Jerome Kieffer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. freesas-0.9.0/MANIFEST.in000066400000000000000000000010171407531701400147070ustar00rootroot00000000000000include README.md include CHANGELOG.rst include copyright include LICENSE recursive-include freesas *.pxd *.h *.pyx *.pxi include MANIFEST.in include run_tests.py recursive-include testdata *.pdb *.dat include run_tests.py include version.py include stdeb.cfg include build-deb.sh include requirements.txt include requirements-dev.txt recursive-include doc/source *.py *.rst *.png *.ico *.ipynb global-exclude .ipynb_checkpoints/* recursive-include examples * recursive-include package * recursive-include freesas/resources * freesas-0.9.0/README.md000066400000000000000000000027251407531701400144370ustar00rootroot00000000000000[![Build Status](https://travis-ci.org/kif/freesas.svg)](https://travis-ci.org/kif/freesas) [![Build status](https://ci.appveyor.com/api/projects/status/uq4xtv5tvx4k6kox?svg=true)](https://ci.appveyor.com/project/kif/freesas) [![Documentation Status](https://readthedocs.org/projects/freesas/badge/?version=latest)](https://freesas.readthedocs.io/en/latest/?badge=latest) FreeSAS ======= Small angle scattering tools ... but unlike most others, free and written in Python (3.6+) The FreeSAS tool suite is licensed under the MIT license. Available tools ---------------- * supycomb: a re-implementation of supcomb as described in [J. Appl. Cryst. (2001). 34, 33-41](http://dx.doi.org/10.1107/S0021889800014126) * autorg: automatic guess of the Guinier region in a SAXS curve, based on [BioXTAS-RAW](https://doi.org/10.1107/S1600576717011438) * auto_guinier automatic guess of the Guinier region in a SAXS curve, based on [J. Appl. Cryst. (2007). 40, s223-s228](http://scripts.iucr.org/cgi-bin/paper?S0021889807002853) * auto_gpa: automatic Guinier peak analysis, based on [J Appl Cryst. (2016). 49, 1412–1419.](https://dx.doi.org/10.1107%2FS1600576716010906) * bift: an Bayesian inverse Fourier transform, based on [J. Appl. Cryst. (2006). 39, 797-804 & BioXtas-RAW](https://scripts.iucr.org/cgi-bin/paper?wf5022) * cormap: a tool to assess the similarity of saxs curves, based on [Nature Methods volume 12, pages 419–422 (2015)](https://www.nature.com/articles/nmeth.3358) freesas-0.9.0/bootstrap.py000077500000000000000000000215141407531701400155470ustar00rootroot00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Bootstrap helps you to test scripts without installing them by patching your PYTHONPATH on the fly example: ./bootstrap.py ipython """ __authors__ = ["Frédéric-Emmanuel Picca", "Jérôme Kieffer"] __contact__ = "jerome.kieffer@esrf.eu" __license__ = "MIT" __date__ = "09/07/2020" import sys import os import distutils.util import subprocess import logging import collections from argparse import ArgumentParser logging.basicConfig() logger = logging.getLogger("bootstrap") def is_debug_python(): """Returns true if the Python interpreter is in debug mode.""" try: import sysconfig except ImportError: # pragma nocover # Python < 2.7 import distutils.sysconfig as sysconfig if sysconfig.get_config_var("Py_DEBUG"): return True return hasattr(sys, "gettotalrefcount") def _distutils_dir_name(dname="lib"): """ Returns the name of a distutils build directory """ platform = distutils.util.get_platform() architecture = "%s.%s-%i.%i" % (dname, platform, sys.version_info[0], sys.version_info[1]) if is_debug_python(): architecture += "-pydebug" return architecture def _distutils_scripts_name(): """Return the name of the distrutils scripts sirectory""" f = "scripts-{version[0]}.{version[1]}" return f.format(version=sys.version_info) def _get_available_scripts(path): res = [] try: res = " ".join([s.rstrip('.py') for s in os.listdir(path)]) except OSError: res = ["no script available, did you ran " "'python setup.py build' before bootstrapping ?"] return res if sys.version_info[0] >= 3: # Python3 def execfile(fullpath, globals=None, locals=None): "Python3 implementation for execfile" with open(fullpath) as f: try: data = f.read() except UnicodeDecodeError: raise SyntaxError("Not a Python script") code = compile(data, fullpath, 'exec') exec(code, globals, locals) def run_file(filename, argv): """ Execute a script trying first to use execfile, then a subprocess :param str filename: Script to execute :param list[str] argv: Arguments passed to the filename """ full_args = [filename] full_args.extend(argv) try: logger.info("Execute target using exec") # execfile is considered as a local call. # Providing globals() as locals will force to feed the file into # globals() (for examples imports). # Without this any function call from the executed file loses imports try: old_argv = sys.argv sys.argv = full_args logger.info("Patch the sys.argv: %s", sys.argv) logger.info("Executing %s.main()", filename) print("########### EXECFILE ###########") module_globals = globals().copy() module_globals['__file__'] = filename execfile(filename, module_globals, module_globals) finally: sys.argv = old_argv except SyntaxError as error: logger.error(error) logger.info("Execute target using subprocess") env = os.environ.copy() env.update({"PYTHONPATH": LIBPATH + os.pathsep + os.environ.get("PYTHONPATH", ""), "PATH": os.environ.get("PATH", "")}) print("########### SUBPROCESS ###########") run = subprocess.Popen(full_args, shell=False, env=env) run.wait() def run_entry_point(entry_point, argv): """ Execute an entry_point using the current python context (http://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation) :param str entry_point: A string identifying a function from a module (NAME = PACKAGE.MODULE:FUNCTION [EXTRA]) """ import importlib elements = entry_point.split("=") target_name = elements[0].strip() elements = elements[1].split(":") module_name = elements[0].strip() # Take care of entry_point optional "extra" requirements declaration function_name = elements[1].split()[0].strip() logger.info("Execute target %s (function %s from module %s) using importlib", target_name, function_name, module_name) full_args = [target_name] full_args.extend(argv) try: old_argv = sys.argv sys.argv = full_args print("########### IMPORTLIB ###########") module = importlib.import_module(module_name) if hasattr(module, function_name): func = getattr(module, function_name) func() else: logger.info("Function %s not found", function_name) finally: sys.argv = old_argv def find_executable(target): """Find a filename from a script name. - Check the script name as file path, - Then checks if the name is a target of the setup.py - Then search the script from the PATH environment variable. :param str target: Name of the script :returns: Returns a tuple: kind, name. """ if os.path.isfile(target): return ("path", os.path.abspath(target)) # search the file from setup.py import setup config = setup.get_project_configuration(dry_run=True) # scripts from project configuration if "scripts" in config: for script_name in config["scripts"]: if os.path.basename(script_name) == target: return ("path", os.path.abspath(script_name)) # entry-points from project configuration if "entry_points" in config: for kind in config["entry_points"]: for entry_point in config["entry_points"][kind]: elements = entry_point.split("=") name = elements[0].strip() if name == target: return ("entry_point", entry_point) # search the file from env PATH for dirname in os.environ.get("PATH", "").split(os.pathsep): path = os.path.join(dirname, target) if os.path.isfile(path): return ("path", path) return None, None def main(argv): parser = ArgumentParser(prog="bootstrap", usage="./bootstrap.py