Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
tomoscan
Commits
f821d720
Commit
f821d720
authored
Sep 03, 2020
by
payno
Browse files
Merge branch 'add_back_hook' into 'master'
add black hook See merge request
!21
parents
89fb2905
da03b949
Pipeline
#32715
passed with stages
in 3 minutes and 33 seconds
Changes
24
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
f821d720
stages
:
-
style
-
build
-
test_library
-
test_notbooks
...
...
@@ -10,6 +11,19 @@ variables:
no_proxy
:
.esrf.fr,localhost
ORANGE_WEB_LOG
:
'
False'
# style
check_style
:
stage
:
style
image
:
docker-registry.esrf.fr/dau/tomwer:python3.8_buster_pyqt5_sphinx
before_script
:
-
pip install black
script
:
-
pip install -r requirements.txt
# run black
-
LC_ALL=C.UTF-8 black --check --safe .
# build
doc
:
stage
:
build
...
...
.pre-commit-config.yaml
0 → 100644
View file @
f821d720
repos
:
-
repo
:
https://github.com/psf/black
rev
:
18.6b4
hooks
:
-
id
:
black
language_version
:
python3
doc/conf.py
View file @
f821d720
...
...
@@ -21,7 +21,7 @@ import os
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
project
=
u
'
tomoscan
'
project
=
u
"
tomoscan
"
# If extensions (or modules to document with autodoc) are in another directory,
...
...
@@ -32,42 +32,42 @@ project = u'tomoscan'
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
#
needs_sphinx = '1.0'
# Add any Sphinx extension modules names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions
=
[
'
sphinx.ext.autodoc
'
,
'
nbsphinx
'
,
"
sphinx.ext.autodoc
"
,
"
nbsphinx
"
,
]
# Add any paths that contain templates here, relative to this directory.
templates_path
=
[
'
templates
'
]
templates_path
=
[
"
templates
"
]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix
=
[
'
.rst
'
,
'
.md
'
]
source_suffix
=
[
"
.rst
"
,
"
.md
"
]
# The encoding of source files.
#source_encoding = 'utf-8-sig'
#
source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc
=
'
index
'
master_doc
=
"
index
"
# General information about the project.
project
=
'
tomoscan
'
copyright
=
'
2016-2020, ESRF
'
author
=
'
ESRF
'
project
=
"
tomoscan
"
copyright
=
"
2016-2020, ESRF
"
author
=
"
ESRF
"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version
=
'
0.4
'
version
=
"
0.4
"
# The full version, including alpha/beta/rc tags.
release
=
'
0.4
'
release
=
"
0.4
"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
...
...
@@ -78,37 +78,37 @@ language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
#
today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
#
today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns
=
[
'
build
'
,
'
**.ipynb_checkpoints
'
]
exclude_patterns
=
[
"
build
"
,
"
**.ipynb_checkpoints
"
]
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
#
default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
#
add_function_parentheses = True
# If true, the current modules name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
#
add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
#
show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style
=
'
sphinx
'
pygments_style
=
"
sphinx
"
# A list of ignored prefixes for modules index sorting.
#modindex_common_prefix = []
#
modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
#
keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos
=
False
...
...
@@ -118,22 +118,22 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme
=
'
nature
'
html_theme
=
"
nature
"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
#
html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
#
html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
#
html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
#
html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
...
...
@@ -142,7 +142,7 @@ html_logo = "img/tomoscan.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
#
html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
...
...
@@ -152,80 +152,77 @@ html_logo = "img/tomoscan.png"
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
#
html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
#
html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
#
html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
#
html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
#
html_additional_pages = {}
# If false, no modules index is generated.
#html_domain_indices = True
#
html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
#
html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
#
html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
#
html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
#
html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
#
html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
#
html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
#
html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
#html_search_language = 'en'
#
html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
#html_search_options = {'type': 'default'}
#
html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js'
#
html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename
=
'
tomoscan
'
htmlhelp_basename
=
"
tomoscan
"
# -- Options for LaTeX output ---------------------------------------------
latex_elements
=
{
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
...
...
@@ -238,41 +235,35 @@ latex_elements = {
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
#
latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
#
latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
#
latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
#
latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
#
latex_appendices = []
# If false, no modules index is generated.
#latex_domain_indices = True
#
latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages
=
[
(
master_doc
,
'tomoscan'
,
'tomoscan documentation'
,
[
author
],
1
)
]
man_pages
=
[(
master_doc
,
"tomoscan"
,
"tomoscan documentation"
,
[
author
],
1
)]
htmlhelp_pages
=
[
(
master_doc
,
'tomoscan'
,
'tomoscan documentation'
,
[
author
],
1
)
]
htmlhelp_pages
=
[(
master_doc
,
"tomoscan"
,
"tomoscan documentation"
,
[
author
],
1
)]
# If true, show URL addresses after external links.
#man_show_urls = False
#
man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
...
...
@@ -281,21 +272,27 @@ htmlhelp_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents
=
[
(
master_doc
,
'tomoscan'
,
'tomoscan Documentation'
,
author
,
'tomoscan'
,
'utils for getting core information from scan'
,
'Miscellaneous'
),
(
master_doc
,
"tomoscan"
,
"tomoscan Documentation"
,
author
,
"tomoscan"
,
"utils for getting core information from scan"
,
"Miscellaneous"
,
),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
#
texinfo_appendices = []
# If false, no modules index is generated.
#texinfo_domain_indices = True
#
texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
#
texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
#
texinfo_no_detailmenu = False
nbsphinx_timeout
=
60
pre-commit.sh
0 → 100755
View file @
f821d720
#!/bin/bash
# This script installs a pre-commit hook on the local repository
# It allows black to run before any git commit.
# Install pre-commit, with a local install fallback
pip
install
--quiet
--upgrade
pre-commit 2>/dev/null
\
||
pip
install
--quiet
--user
--upgrade
pre-commit
# Install the pre-commit hook on the local repository
pre-commit
install
setup.py
View file @
f821d720
...
...
@@ -41,10 +41,12 @@ logger = logging.getLogger("tomoscan.setup")
from
distutils.command.build
import
build
as
_build
try
:
from
setuptools
import
Command
from
setuptools.command.build_ext
import
build_ext
from
setuptools.command.sdist
import
sdist
logger
.
info
(
"Use setuptools"
)
except
ImportError
:
try
:
...
...
@@ -53,11 +55,13 @@ except ImportError:
from
distutils.core
import
Command
from
distutils.command.build_ext
import
build_ext
from
distutils.command.sdist
import
sdist
logger
.
info
(
"Use distutils"
)
try
:
import
sphinx
import
sphinx.util.console
sphinx
.
util
.
console
.
color_terminal
=
lambda
:
False
from
sphinx.setup_command
import
BuildDoc
except
ImportError
:
...
...
@@ -67,11 +71,13 @@ except ImportError:
PROJECT
=
"tomoscan"
if
"LANG"
not
in
os
.
environ
and
sys
.
platform
==
"darwin"
and
sys
.
version_info
[
0
]
>
2
:
print
(
"""WARNING: the LANG environment variable is not defined,
print
(
"""WARNING: the LANG environment variable is not defined,
an utf-8 LANG is mandatory to use setup.py, you may face unexpected UnicodeError.
export LANG=en_US.utf-8
export LC_ALL=en_US.utf-8
"""
)
"""
)
def
get_version
():
...
...
@@ -79,6 +85,7 @@ def get_version():
dirname
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
sys
.
path
.
insert
(
0
,
dirname
)
import
tomoscan.version
sys
.
path
=
sys
.
path
[
1
:]
return
tomoscan
.
version
.
strictversion
...
...
@@ -92,32 +99,35 @@ def get_readme():
return
long_description
classifiers
=
[
"Development Status :: 4 - Beta"
,
"Environment :: Console"
,
"Environment :: MacOS X"
,
"Environment :: Win32 (MS Windows)"
,
"Intended Audience :: Education"
,
"Intended Audience :: Science/Research"
,
"License :: OSI Approved :: MIT License"
,
"Natural Language :: English"
,
"Operating System :: MacOS"
,
"Operating System :: Microsoft :: Windows"
,
"Operating System :: POSIX"
,
"Programming Language :: Cython"
,
"Programming Language :: Python :: 3.5"
,
"Programming Language :: Python :: 3.6"
,
"Programming Language :: Python :: 3.7"
,
"Programming Language :: Python :: Implementation :: CPython"
,
"Topic :: Scientific/Engineering :: Physics"
,
"Topic :: Software Development :: Libraries :: Python Modules"
,
]
classifiers
=
[
"Development Status :: 4 - Beta"
,
"Environment :: Console"
,
"Environment :: MacOS X"
,
"Environment :: Win32 (MS Windows)"
,
"Intended Audience :: Education"
,
"Intended Audience :: Science/Research"
,
"License :: OSI Approved :: MIT License"
,
"Natural Language :: English"
,
"Operating System :: MacOS"
,
"Operating System :: Microsoft :: Windows"
,
"Operating System :: POSIX"
,
"Programming Language :: Cython"
,
"Programming Language :: Python :: 3.5"
,
"Programming Language :: Python :: 3.6"
,
"Programming Language :: Python :: 3.7"
,
"Programming Language :: Python :: Implementation :: CPython"
,
"Topic :: Scientific/Engineering :: Physics"
,
"Topic :: Software Development :: Libraries :: Python Modules"
,
]
########
# Test #
########
class
PyTest
(
Command
):
"""Command to start tests running the script: run_tests.py"""
user_options
=
[]
description
=
"Execute the unittests"
...
...
@@ -130,7 +140,8 @@ class PyTest(Command):
def
run
(
self
):
import
subprocess
errno
=
subprocess
.
call
([
sys
.
executable
,
'run_tests.py'
])
errno
=
subprocess
.
call
([
sys
.
executable
,
"run_tests.py"
])
if
errno
!=
0
:
raise
SystemExit
(
errno
)
...
...
@@ -140,8 +151,10 @@ class PyTest(Command):
# ################### #
if
sphinx
is
None
:
class
SphinxExpectedCommand
(
Command
):
"""Command to inform that sphinx is missing"""
user_options
=
[]
def
initialize_options
(
self
):
...
...
@@ -152,11 +165,13 @@ if sphinx is None:
def
run
(
self
):
raise
RuntimeError
(
'Sphinx is required to build or test the documentation.
\n
'
'Please install Sphinx (http://www.sphinx-doc.org).'
)
"Sphinx is required to build or test the documentation.
\n
"
"Please install Sphinx (http://www.sphinx-doc.org)."
)
if
sphinx
is
not
None
:
class
BuildDocCommand
(
BuildDoc
):
"""Command to build documentation using sphinx.
...
...
@@ -168,17 +183,18 @@ if sphinx is not None:
# code so that the documentation is built on this and not a
# previously installed version
build
=
self
.
get_finalized_command
(
'
build
'
)
build
=
self
.
get_finalized_command
(
"
build
"
)
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
build
.
build_lib
))
# Build the Users Guide in HTML and TeX format
for
builder
in
[
'
html
'
,
'
latex
'
]:
for
builder
in
[
"
html
"
,
"
latex
"
]:
self
.
builder
=
builder
self
.
builder_target_dir
=
os
.
path
.
join
(
self
.
build_dir
,
builder
)
self
.
mkpath
(
self
.
builder_target_dir
)
BuildDoc
.
run
(
self
)
sys
.
path
.
pop
(
0
)
else
:
BuildDocCommand
=
SphinxExpectedCommand
...
...
@@ -187,7 +203,8 @@ else:
# numpy.distutils Configuration #
# ############################# #
def
configuration
(
parent_package
=
''
,
top_path
=
None
):
def
configuration
(
parent_package
=
""
,
top_path
=
None
):
"""Recursive construction of package info to be used in setup().
See http://docs.scipy.org/doc/numpy/reference/distutils.html#numpy.distutils.misc_util.Configuration
...
...
@@ -197,16 +214,19 @@ def configuration(parent_package='', top_path=None):
except
ImportError
:
raise
ImportError
(
"To install this package, you must install numpy first
\n
"
"(See https://pypi.python.org/pypi/numpy)"
)
"(See https://pypi.python.org/pypi/numpy)"
)
config
=
Configuration
(
None
,
parent_package
,
top_path
)
config
.
set_options
(
ignore_setup_xxx_py
=
True
,
assume_default_configuration
=
True
,
delegate_options_to_subpackages
=
True
,
quiet
=
True
)
quiet
=
True
,
)
config
.
add_subpackage
(
PROJECT
)
return
config
# ############## #
# Compiler flags #
# ############## #
...
...
@@ -229,6 +249,7 @@ class Build(_build):
logger
.
warning
(
msg
,
key
,
content
)
return
None
################################################################################
# Debian source tree
################################################################################
...
...
@@ -249,6 +270,7 @@ class sdist_debian(sdist):
@
staticmethod
def
get_debian_name
():
import
tomoscan.version
name
=
"%s_%s"
%
(
PROJECT
,
tomoscan
.
version
.
debianversion
)
return
name
...
...
@@ -263,7 +285,7 @@ class sdist_debian(sdist):
for
root
,
_
,
files
in
os
.
walk
(
search_root
):
for
afile
in
files
:
if
os
.
path
.
splitext
(
afile
)[
1
].
lower
()
==
".pyx"
:
base_file
=
os
.
path
.
join
(
root
,
afile
)[
len
(
search_root
)
+
1
:
-
4
]
base_file
=
os
.
path
.
join
(
root
,
afile
)[
len
(
search_root
)
+
1
:
-
4
]
self
.
filelist
.
exclude_pattern
(
pattern
=
base_file
+
".c"
)
self
.
filelist
.
exclude_pattern
(
pattern
=
base_file
+
".cpp"
)
self
.
filelist
.
exclude_pattern
(
pattern
=
base_file
+
".html"
)
...
...
@@ -293,6 +315,7 @@ class sdist_debian(sdist):
# setup #
# ##### #
def
get_project_configuration
(
dry_run
):
"""Returns project arguments for setup"""
install_requires
=
[
...
...
@@ -302,28 +325,24 @@ def get_project_configuration(dry_run):
"lxml"
,
]
setup_requires
=
[
"setuptools"
,]
setup_requires
=
[
"setuptools"
,
]
# extras requirements: target 'full' to install all dependencies at once
full_requires
=
[
]
full_requires
=
[]
extras_require
=
{
'
full
'
:
full_requires
,
"
full
"
:
full_requires
,
}
package_data
=
{
}
package_data
=
{}
entry_points
=
{
}
entry_points
=
{}
cmdclass
=
dict
(
build
=
Build
,
test
=
PyTest
,
build_doc
=
BuildDocCommand
,
debian_src
=
sdist_debian
)
build
=
Build
,
test
=
PyTest
,
build_doc
=
BuildDocCommand
,
debian_src
=
sdist_debian
)
if
dry_run
:
# DRY_RUN implies actions which do not require NumPy
...
...
@@ -336,23 +355,23 @@ def get_project_configuration(dry_run):
config
=
configuration
()
setup_kwargs
=
config
.
todict
()
setup_kwargs
.
update
(
name
=
PROJECT
,
version
=
get_version
(),