Skip to content

Commit 6ad3821

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 08be2c3 + bd7e46c commit 6ad3821

29 files changed

Lines changed: 737 additions & 43 deletions

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ Desktop.ini
7070
.eslintignore
7171

7272
.pylintrc
73+
.pycodestyle
74+
.pydocstyle
75+
setup.py
7376

7477
.travis.yml
7578
circle.yml

docs/development.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ While not required to run stdlib, the following dependencies __may__ be required
2727
* [Julia][julia]: language for technical computing (version `>= 0.4`)
2828
* [R][r]: language for statistical computing (version `>= 3.0.0`)
2929
* [Python][python]: general purpose language (version `>= 2.7`)
30+
* [SciPy][scipy]: Python library containing numerical routines (version `>=0.17.0`)
31+
* [NumPy][numpy]: general purpose array-processing library for Python (version `>=1.8.2`)
32+
* [Pylint][pylint]: Python source code analyzer (version `>= 1.7.1`)
33+
* [pycodestyle][pycodestyle]: Python style guide checker against PEP 8 (version `>= 2.3.1`)
34+
* [pydocstyle][pydocstyle]: Python docstring checker against PEP 257 (version `>= 2.3.1`)
3035
* [gcc & g++][gcc] or [Clang][clang]: C/C++ compilation and linking (g++ version `>= 4.8`; clang version `>= 3.5`, Xcode version `>=4.4` on OS X)
3136
* [gfortran][gfortran]: Fortran compilation and linking (version `>= 4.8`)
3237
* [CMake][cmake]: cross-platform build environment (version `>= 3.4.3`)
@@ -276,6 +281,11 @@ For contribution guidelines, see the [contributing guide][stdlib-contributing].
276281
[julia]: http://julialang.org/
277282
[r]: https://www.r-project.org/
278283
[python]: https://www.python.org/
284+
[scipy]: https://www.scipy.org/index.html
285+
[numpy]: http://www.numpy.org/
286+
[pylint]: https://github.com/PyCQA/pylint
287+
[pycodestyle]: https://github.com/PyCQA/pycodestyle
288+
[pydocstyle]: https://github.com/PyCQA/pydocstyle
279289
[gcc]: http://gcc.gnu.org/
280290
[clang]: http://clang.llvm.org/
281291
[gfortran]: https://gcc.gnu.org/fortran/

etc/.makie.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ plugins[ 'benchmark' ] = path.join( prefix, 'makie-benchmark' );
2828
plugins[ 'benchmark-lang' ] = path.join( prefix, 'makie-benchmark-lang' );
2929
plugins[ 'lint-javascript' ] = path.join( prefix, 'makie-lint-javascript' );
3030
plugins[ 'lint-markdown' ] = path.join( prefix, 'makie-lint-markdown' );
31+
plugins[ 'lint-python' ] = path.join( prefix, 'makie-lint-python' );
3132
plugins[ 'complexity' ] = path.join( prefix, 'makie-complexity' );
3233
plugins[ 'view-complexity' ] = path.join( prefix, 'makie-view-complexity' );
3334
plugins[ 'list-pkgs' ] = path.join( prefix, 'makie-list-pkgs' );

tools/git/hooks/pre-commit

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,23 @@ run_lint() {
142142
fi
143143
fi
144144

145+
# Lint Python files...
146+
files=$(echo "${changed_files}" | grep '\.py$' | tr '\n' ' ')
147+
if [[ -n "${files}" ]]; then
148+
make check-python-linters > /dev/null >&2
149+
if [[ "$?" -ne 0 ]]; then
150+
echo '' >&2
151+
echo 'Unable to lint Python files. Ensure that linters are installed.' >&2
152+
else
153+
make PYTHON_FILES="${files}" lint-python-files > /dev/null >&2
154+
if [[ "$?" -ne 0 ]]; then
155+
echo '' >&2
156+
echo 'Python lint errors.' >&2
157+
return 1
158+
fi
159+
fi
160+
fi
161+
145162
# TODO: if datapackage.json, validate via schema
146163

147164
return 0

tools/make/lib/lint/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ lint-examples: lint-javascript-examples
5151
#
5252
# This target lints only benchmark files.
5353

54-
lint-benchmarks: lint-javascript-benchmarks
54+
lint-benchmarks: lint-javascript-benchmarks lint-python-benchmarks
5555

5656
.PHONY: lint-benchmarks
5757

tools/make/lib/lint/pycodestyle.mk

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,29 @@ PYCODESTYLE_FLAGS ?= \
2020

2121
# TARGETS #
2222

23+
# Check for pycodestyle.
24+
#
25+
# This target checks if pycodestyle is installed.
26+
27+
check-pycodestyle:
28+
ifeq (, $(shell command -v $(PYCODESTYLE) 2>/dev/null))
29+
$(QUIET) echo ''
30+
$(QUIET) echo 'pycodestyle is not installed. Please install pycodestyle and try again.'
31+
$(QUIET) echo 'For install instructions, see https://github.com/PyCQA/pycodestyle.'
32+
$(QUIET) echo ''
33+
$(QUIET) exit 1
34+
else
35+
$(QUIET) echo 'pycodestyle is installed.'
36+
$(QUIET) exit 0
37+
endif
38+
39+
.PHONY: check-pycodestyle
40+
2341
# Check source code style.
2442
#
2543
# This target lints only Python source files.
2644

27-
pycodestyle-src:
45+
pycodestyle-src: check-pycodestyle
2846
$(QUIET) $(FIND_PYTHON_SOURCES_CMD) | grep '^\/' | while read -r file; do \
2947
echo ''; \
3048
echo "Linting file: $$file"; \
@@ -38,7 +56,7 @@ pycodestyle-src:
3856
#
3957
# This target lints only Python test fixture files.
4058

41-
pycodestyle-tests-fixtures:
59+
pycodestyle-tests-fixtures: check-pycodestyle
4260
$(QUIET) $(FIND_PYTHON_TESTS_FIXTURES_CMD) | grep '^\/' | while read -r file; do \
4361
echo ''; \
4462
echo "Linting file: $$file"; \
@@ -52,7 +70,7 @@ pycodestyle-tests-fixtures:
5270
#
5371
# This target lints only Python example files.
5472

55-
pycodestyle-examples:
73+
pycodestyle-examples: check-pycodestyle
5674
$(QUIET) $(FIND_PYTHON_EXAMPLES_CMD) | grep '^\/' | while read -r file; do \
5775
echo ''; \
5876
echo "Linting file: $$file"; \
@@ -66,7 +84,7 @@ pycodestyle-examples:
6684
#
6785
# This target lints only Python benchmark files.
6886

69-
pycodestyle-benchmarks:
87+
pycodestyle-benchmarks: check-pycodestyle
7088
$(QUIET) $(FIND_PYTHON_BENCHMARKS_CMD) | grep '^\/' | while read -r file; do \
7189
echo ''; \
7290
echo "Linting file: $$file"; \
@@ -78,10 +96,10 @@ pycodestyle-benchmarks:
7896

7997
# Check Python code style.
8098
#
81-
# This target lints Python files. Note that we expect `$FILES` to be a Python file list.
99+
# This target lints Python files. Note that we expect `$PYTHON_FILES` to be a Python file list.
82100

83-
pycodestyle-files:
84-
$(QUIET) for file in $(FILES); do \
101+
pycodestyle-files: check-pycodestyle
102+
$(QUIET) for file in $(PYTHON_FILES); do \
85103
echo ''; \
86104
echo "Linting file: $$file"; \
87105
$(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $$file || exit 1; \

tools/make/lib/lint/pydocstyle.mk

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,29 @@ PYDOCSTYLE_FLAGS ?= \
2020

2121
# TARGETS #
2222

23+
# Check for pydocstyle.
24+
#
25+
# This target checks if pydocstyle is installed.
26+
27+
check-pydocstyle:
28+
ifeq (, $(shell command -v $(PYDOCSTYLE) 2>/dev/null))
29+
$(QUIET) echo ''
30+
$(QUIET) echo 'pydocstyle is not installed. Please install pydocstyle and try again.'
31+
$(QUIET) echo 'For install instructions, see https://github.com/PyCQA/pydocstyle.'
32+
$(QUIET) echo ''
33+
$(QUIET) exit 1
34+
else
35+
$(QUIET) echo 'pydocstyle is installed.'
36+
$(QUIET) exit 0
37+
endif
38+
39+
.PHONY: check-pydocstyle
40+
2341
# Check source docstring style.
2442
#
2543
# This target lints only Python source files.
2644

27-
pydocstyle-src:
45+
pydocstyle-src: check-pydocstyle
2846
$(QUIET) $(FIND_PYTHON_SOURCES_CMD) | grep '^\/' | while read -r file; do \
2947
echo ''; \
3048
echo "Linting file: $$file"; \
@@ -38,7 +56,7 @@ pydocstyle-src:
3856
#
3957
# This target lints only Python test fixture files.
4058

41-
pydocstyle-tests-fixtures:
59+
pydocstyle-tests-fixtures: check-pydocstyle
4260
$(QUIET) $(FIND_PYTHON_TESTS_FIXTURES_CMD) | grep '^\/' | while read -r file; do \
4361
echo ''; \
4462
echo "Linting file: $$file"; \
@@ -52,7 +70,7 @@ pydocstyle-tests-fixtures:
5270
#
5371
# This target lints only Python example files.
5472

55-
pydocstyle-examples:
73+
pydocstyle-examples: check-pydocstyle
5674
$(QUIET) $(FIND_PYTHON_EXAMPLES_CMD) | grep '^\/' | while read -r file; do \
5775
echo ''; \
5876
echo "Linting file: $$file"; \
@@ -66,7 +84,7 @@ pydocstyle-examples:
6684
#
6785
# This target lints only Python benchmark files.
6886

69-
pydocstyle-benchmarks:
87+
pydocstyle-benchmarks: check-pydocstyle
7088
$(QUIET) $(FIND_PYTHON_BENCHMARKS_CMD) | grep '^\/' | while read -r file; do \
7189
echo ''; \
7290
echo "Linting file: $$file"; \
@@ -78,10 +96,10 @@ pydocstyle-benchmarks:
7896

7997
# Check Python docstring style.
8098
#
81-
# This target lints Python files. Note that we expect `$FILES` to be a Python file list.
99+
# This target lints Python files. Note that we expect `$PYTHON_FILES` to be a Python file list.
82100

83-
pydocstyle-files:
84-
$(QUIET) for file in $(FILES); do \
101+
pydocstyle-files: check-pydocstyle
102+
$(QUIET) for file in $(PYTHON_FILES); do \
85103
echo ''; \
86104
echo "Linting file: $$file"; \
87105
$(PYDOCSTYLE) $(PYDOCSTYLE_FLAGS) $$file || exit 1; \

tools/make/lib/lint/pylint.mk

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,29 @@ PYLINT_FLAGS ?= \
2222

2323
# TARGETS #
2424

25+
# Check for Pylint.
26+
#
27+
# This target checks if Pylint is installed.
28+
29+
check-pylint:
30+
ifeq (, $(shell command -v $(PYLINT) 2>/dev/null))
31+
$(QUIET) echo ''
32+
$(QUIET) echo 'Pylint is not installed. Please install Pylint and try again.'
33+
$(QUIET) echo 'For install instructions, see https://github.com/PyCQA/pylint.'
34+
$(QUIET) echo ''
35+
$(QUIET) exit 1
36+
else
37+
$(QUIET) echo 'Pylint is installed.'
38+
$(QUIET) exit 0
39+
endif
40+
41+
.PHONY: check-pylint
42+
2543
# Check source code quality.
2644
#
2745
# This target lints only Python source files.
2846

29-
pylint-src:
47+
pylint-src: check-pylint
3048
$(QUIET) $(FIND_PYTHON_SOURCES_CMD) | grep '^\/' | while read -r file; do \
3149
echo ''; \
3250
echo "Linting file: $$file"; \
@@ -40,7 +58,7 @@ pylint-src:
4058
#
4159
# This target lints only Python test fixture files.
4260

43-
pylint-tests-fixtures:
61+
pylint-tests-fixtures: check-pylint
4462
$(QUIET) $(FIND_PYTHON_TESTS_FIXTURES_CMD) | grep '^\/' | while read -r file; do \
4563
echo ''; \
4664
echo "Linting file: $$file"; \
@@ -54,7 +72,7 @@ pylint-tests-fixtures:
5472
#
5573
# This target lints only Python example files.
5674

57-
pylint-examples:
75+
pylint-examples: check-pylint
5876
$(QUIET) $(FIND_PYTHON_EXAMPLES_CMD) | grep '^\/' | while read -r file; do \
5977
echo ''; \
6078
echo "Linting file: $$file"; \
@@ -68,7 +86,7 @@ pylint-examples:
6886
#
6987
# This target lints only Python benchmark files.
7088

71-
pylint-benchmarks:
89+
pylint-benchmarks: check-pylint
7290
$(QUIET) $(FIND_PYTHON_BENCHMARKS_CMD) | grep '^\/' | while read -r file; do \
7391
echo ''; \
7492
echo "Linting file: $$file"; \
@@ -80,10 +98,10 @@ pylint-benchmarks:
8098

8199
# Check Python code quality.
82100
#
83-
# This target lints Python files. Note that we expect `$FILES` to be a Python file list.
101+
# This target lints Python files. Note that we expect `$PYTHON_FILES` to be a Python file list.
84102

85-
pylint-files:
86-
$(QUIET) for file in $(FILES); do \
103+
pylint-files: check-pylint
104+
$(QUIET) for file in $(PYTHON_FILES); do \
87105
echo ''; \
88106
echo "Linting file: $$file"; \
89107
$(PYLINT) $(PYLINT_FLAGS) $$file || exit 1; \

tools/make/lib/lint/python.mk

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ include $(TOOLS_MAKE_LIB_DIR)/lint/pylint.mk
88

99
# TARGETS #
1010

11+
# Check for linters.
12+
#
13+
# This target checks that Python linters exist.
14+
15+
check-python-linters: check-pylint check-pycodestyle check-pydocstyle
16+
17+
.PHONY: check-python-linters
18+
19+
1120
# Check code quality.
1221
#
1322
# This target lints all Python code.
@@ -55,7 +64,7 @@ lint-python-benchmarks: pylint-benchmarks pycodestyle-benchmarks pydocstyle-benc
5564

5665
# Check code quality.
5766
#
58-
# This target lints Python files. Note that we expect `$FILES` to be a Python file list.
67+
# This target lints Python files. Note that we expect `$PYTHON_FILES` to be a Python file list.
5968

6069
lint-python-files: pylint-files pycodestyle-files pydocstyle-files
6170

tools/make/lib/ls/Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,55 @@ R_EXAMPLES_PATTERN ?= *.R
9494
EXAMPLES_FILTER ?= .*/.*
9595

9696

97+
# Define a filename pattern for C files:
98+
C_PATTERN ?= *.c
99+
100+
# Define a filepath pattern for C files:
101+
C_FILTER ?= .*/.*
102+
103+
104+
# Define a filename pattern for Fortran files:
105+
FORTRAN_PATTERN ?= *.f
106+
107+
# Define a filepath pattern for Fortran files:
108+
FORTRAN_FILTER ?= .*/.*
109+
110+
111+
# Define a filename pattern for JavaScript files:
112+
JAVASCRIPT_PATTERN ?= *.js
113+
114+
# Define a filepath pattern for JavaScript files:
115+
JAVASCRIPT_FILTER ?= .*/.*
116+
117+
118+
# Define a filename pattern for Julia files:
119+
JULIA_PATTERN ?= *.jl
120+
121+
# Define a filepath pattern for Julia files:
122+
JULIA_FILTER ?= .*/.*
123+
124+
97125
# Define a filename pattern for Markdown files:
98126
MARKDOWN_PATTERN ?= *.md
99127

100128
# Define a filepath pattern for Markdown files:
101129
MARKDOWN_FILTER ?= .*/.*
102130

103131

132+
# Define a filename pattern for Python files:
133+
PYTHON_PATTERN ?= *.py
134+
135+
# Define a filepath pattern for Python files:
136+
PYTHON_FILTER ?= .*/.*
137+
138+
139+
# Define a filename pattern for R files:
140+
R_PATTERN ?= *.R
141+
142+
# Define a filepath pattern for R files:
143+
R_FILTER ?= .*/.*
144+
145+
104146
# Define a filepath pattern for packages:
105147
PACKAGES_FILTER ?= .*/.*
106148

@@ -132,7 +174,13 @@ include $(TOOLS_MAKE_LIB_DIR)/ls/examples_c.mk
132174
include $(TOOLS_MAKE_LIB_DIR)/ls/examples_julia.mk
133175
include $(TOOLS_MAKE_LIB_DIR)/ls/examples_python.mk
134176
include $(TOOLS_MAKE_LIB_DIR)/ls/examples_r.mk
177+
include $(TOOLS_MAKE_LIB_DIR)/ls/c.mk
178+
include $(TOOLS_MAKE_LIB_DIR)/ls/fortran.mk
179+
include $(TOOLS_MAKE_LIB_DIR)/ls/javascript.mk
180+
include $(TOOLS_MAKE_LIB_DIR)/ls/julia.mk
135181
include $(TOOLS_MAKE_LIB_DIR)/ls/markdown.mk
182+
include $(TOOLS_MAKE_LIB_DIR)/ls/python.mk
183+
include $(TOOLS_MAKE_LIB_DIR)/ls/r.mk
136184
include $(TOOLS_MAKE_LIB_DIR)/ls/pkgs.mk
137185
include $(TOOLS_MAKE_LIB_DIR)/ls/pkgs_addons.mk
138186
include $(TOOLS_MAKE_LIB_DIR)/ls/pkgs_clis.mk

0 commit comments

Comments
 (0)