diff --git a/.coveragerc b/.coveragerc index 4c15bf0b..4157778b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,8 +3,6 @@ [run] branch = True omit = - */setup.py - oct2py/compat.py oct2py/tests/* oct2py/ipython/tests/* diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..c62aab35 --- /dev/null +++ b/.flake8 @@ -0,0 +1,19 @@ +[flake8] +ignore = E501, W503, E402 +builtins = "c, get_config" +exclude = [ + .cache, + .github, + docs +] +enable-extensions = "G" +extend-ignore = [ + G001, G002, G004, G200, G201, G202, + # black adds spaces around ':' + E203 +] +per-file-ignores = [ + # B011: Do not call assert False since python -O removes these calls + # F841 local variable 'foo' is assigned to but never used + tests/*: B011, F841 +] diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..b8d0fc4b --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Run AutoFormatters: https://github.com/blink1073/oct2py/pull/232 +00192f2cd97f2395cfce8af69ba3671ae0cb70b1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ed11d9c3..3f503a7d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,8 +20,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - name: Install Octave run: | sudo apt-get update @@ -29,15 +28,6 @@ jobs: - name: Install dependencies run: | make install - - name: Run test - run: | - xvfb-run --auto-servernum make test - - name: Generate Docs - run: | - make docs - - name: Make sure the package is release-able - run: | - make release_prep - name: Generate coverage report run: | xvfb-run --auto-servernum make cover @@ -49,11 +39,23 @@ jobs: flags: unittests name: codecov-umbrella fail_ci_if_error: true - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - flags: unittests - name: codecov-umbrella - fail_ci_if_error: true + + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - name: Install Oct2py + run: make + - name: Generate Docs + run: make docs + + release_prep: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - name: Install Oct2py + run: make + - name: Make sure the package is release-able + run: make release_prep diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 00000000..004a03ae --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,2 @@ +conda: + file: docs/environment.yml diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 90650085..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,29 +0,0 @@ -include *.txt -include *.rst -include Makefile -include *.md -include *.yml -include .coveragerc -include pytest.ini - -recursive-include docs *.rst -recursive-include docs *.png -recursive-include docs *.py -recursive-include oct2py *.m -recursive-include example *.m -recursive-include example *.py -recursive-include example *.ipynb -recursive-include numpydoc *.py -recursive-include licenses *.txt -recursive-include docs *.bat -recursive-include docs *.html -recursive-include docs *.yml -recursive-include docs Makefile -recursive-include oct2py *.txt - -prune .git -prune docs/_build -prune dist -prune build - -exclude .pre-commit-config.yaml diff --git a/Makefile b/Makefile index 8fd458e1..648f9b18 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,15 @@ # Note: This is meant for Oct2Py developer use only -.PHONY: all clean test cover release gh-pages docs +.PHONY: all clean test cover release docs -NAME:=$(shell python setup.py --name 2>/dev/null) -VERSION:=$(shell python setup.py --version 2>/dev/null) +NAME:="oct2py" +VERSION:="5.5.1" KILL_PROC="from ${NAME} import kill_octave; kill_octave()" all: clean - python setup.py install - + pip install -e ".[docs,test]" install: clean - pip install -e .[docs,test] + pip install -e ".[docs,test]" pre-commit install octave --eval "pkg install -forge control" octave --eval "pkg install -forge signal" @@ -33,10 +32,9 @@ cover: clean pytest --doctest-modules -l --cov-report html --cov-report=xml --cov=${NAME} release_prep: clean - pip install -q wheel twine + pip install -q build twine git commit -a -m "Release ${VERSION}"; true - python setup.py bdist_wheel --universal - python setup.py sdist + python -m build . twine check dist/* release: release_prep @@ -46,6 +44,6 @@ release: release_prep twine upload dist/* docs: clean - pip install -q sphinx-rtd-theme numpydoc sphinx + pip install -e ".[docs]" export SPHINXOPTS=-W; make -C docs html export SPHINXOPTS=-W; make -C docs linkcheck || export SPHINXOPTS=-W; make -C docs linkcheck diff --git a/docs/environment.yml b/docs/environment.yml index f346ff52..31196058 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -2,8 +2,7 @@ name: oct2py_documentation channels: - conda-forge dependencies: - - python=3.5 + - python=3.9 - sphinx>=1.8 - sphinx_rtd_theme - - numpydoc - - recommonmark + - myst-parser diff --git a/docs/source/conf.py b/docs/source/conf.py index 121624f3..91ed748b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,7 +11,6 @@ # serve to show the default. import datetime -import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -25,12 +24,13 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ + "myst_parser", + "sphinx.ext.napoleon", "sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.todo", "sphinx.ext.intersphinx", "sphinx.ext.inheritance_diagram", - "numpydoc", ] # Add any paths that contain templates here, relative to this directory. @@ -46,16 +46,12 @@ project = "Oct2Py" copyright = f"2011 - {datetime.date.today().year}, Oct2Py contributors" -_version_py = os.path.join("..", "..", "oct2py", "_version.py") -version_ns = {} - -with open(_version_py) as version_file: - exec(version_file.read(), version_ns) +version = "5.5.1" # The short X.Y version. -version = "%i.%i" % version_ns["version_info"][:2] +version = ".".join(version.split(".")[:2]) # The full version, including alpha/beta/rc tags. -release = version_ns["__version__"] +release = version # The language for content autogenerated by Sphinx. Refer to documentation diff --git a/oct2py/_version.py b/oct2py/_version.py index f1745050..7556ccfa 100644 --- a/oct2py/_version.py +++ b/oct2py/_version.py @@ -5,9 +5,9 @@ VersionInfo = namedtuple("VersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]) -version_info = VersionInfo(5, 5, 1, "final", 0) +version_info = VersionInfo(5, 5, 1, "", "") __version__ = f"{version_info.major}.{version_info.minor}.{version_info.micro}" -if version_info.releaselevel != "final": +if version_info.releaselevel: __version__ += f"{version_info.releaselevel}{version_info.serial}" diff --git a/oct2py/core.py b/oct2py/core.py index 5486ccec..243d1982 100644 --- a/oct2py/core.py +++ b/oct2py/core.py @@ -559,7 +559,10 @@ def restart(self): if "OCTAVE_EXECUTABLE" not in os.environ and "OCTAVE" in os.environ: os.environ["OCTAVE_EXECUTABLE"] = os.environ["OCTAVE"] - self._engine = OctaveEngine(stdin_handler=self._handle_stdin, logger=self.logger) + try: + self._engine = OctaveEngine(stdin_handler=self._handle_stdin, logger=self.logger) + except Exception as e: + raise Oct2PyError(str(e)) # Add local Octave scripts. self._engine.eval('addpath("%s");' % HERE.replace(osp.sep, "/")) diff --git a/oct2py/utils.py b/oct2py/utils.py index b946bafc..fa3c9acc 100644 --- a/oct2py/utils.py +++ b/oct2py/utils.py @@ -21,12 +21,6 @@ def get_log(name=None): ---------- name : str Name of the log. - - References - ---------- - .. [1] Logging facility for Python, - http://docs.python.org/library/logging.html - """ if name is None: name = "oct2py" diff --git a/pyproject.toml b/pyproject.toml index fef6ace6..dc11fd86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,53 @@ [build-system] -requires = ["setuptools>=46.4.0", "wheel", "packaging", "numpy", "octave_kernel"] -build-backend = "setuptools.build_meta" +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "oct2py" +version = "5.5.1" +description = "'Python to GNU Octave bridge --> run m-files from python.'" +license = {text = "MIT"} +authors = [{name = "Steven Silvester", email = "steven.silvester@ieee.org"}] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering", + "Topic :: Software Development", +] +requires-python = ">=3.7" +dependencies = [ + "numpy >=1.12", + "scipy >=0.17", + "octave_kernel >= 0.34.0", +] +readme = "README.rst" + +[project.urls] +homepage = "https://github.com/blink1073/oct2py" +documentation = "https://blink1073.github.io/oct2py" + +[project.optional-dependencies] +test = [ + "pytest", + "pandas", + "nbconvert", + "pytest-timeout", + "pre-commit", +] +docs = [ + "sphinx", + "sphinx-bootstrap-theme", + "myst-parser", + "sphinx_rtd_theme" +] [tool.jupyter-releaser] -skip = ["check-links"] +skip = ["check-links", "check-manifest"] [tool.jupyter-releaser.hooks] before-build-python = ["sudo apt-get update", "sudo apt-get install -qq octave octave-signal liboctave-dev"] @@ -12,24 +56,36 @@ before-check-links = ["sudo apt-get update", "sudo apt-get install -qq octave oc [tool.tbump.version] current = "5.5.1" regex = ''' - (?P\d+)\.(?P\d+)\.(?P\d+)(?P[a-z]+)?(?P\d+)? + (?P\d+)\.(?P\d+)\.(?P\d+)(?P[a-z]+)?(?P[a-z]+)? ''' [tool.tbump.git] message_template = "Bump to {new_version}" tag_template = "v{new_version}" +[[tool.tbump.file]] +src = "pyproject.toml" +version_template = '{major}.{minor}.{micro}{releaselevel}{serial}' + [[tool.tbump.file]] src = "oct2py/_version.py" -version_template = '({major}, {minor}, {micro}, "{releaselevel}", {serial})' +version_template = '({major}, {minor}, {micro}, "{releaselevel}", "{serial}")' + +[[tool.tbump.file]] +src = "docs/source/conf.py" +version_template = '{major}.{minor}.{micro}{releaselevel}{serial}' + +[[tool.tbump.file]] +src = "Makefile" +version_template = '{major}.{minor}.{micro}{releaselevel}{serial}' [[tool.tbump.field]] name = "releaselevel" -default = "final" +default = "" [[tool.tbump.field]] name = "serial" -default = 0 +default = "" [tool.pytest.ini_options] testpaths = "oct2py" diff --git a/readthedocs.yml b/readthedocs.yml deleted file mode 100644 index 044f1457..00000000 --- a/readthedocs.yml +++ /dev/null @@ -1,6 +0,0 @@ -conda: - file: docs/environment.yml -python: - version: 3 - pip_install: false - setup_py_install: false diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8e601081..00000000 --- a/setup.cfg +++ /dev/null @@ -1,68 +0,0 @@ -[metadata] -name = oct2py -version = attr: oct2py._version.__version__ -description = 'Python to GNU Octave bridge --> run m-files from python.' -long_description = file: README.rst -long_description_content_type = text/x-rst -license = MIT -author = Steven Silvester -author_email = steven.silvester@ieee.org -url = http://github.com/blink1073/oct2py -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: Science/Research - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Topic :: Scientific/Engineering - Topic :: Software Development - -[options] -zip_safe = False -include_package_data = True -packages = find: -python_requires = >=3.7 -install_requires = - numpy >=1.12 - scipy >=0.17 - octave_kernel >= 0.34.0 - -[options.extras_require] -test = - pytest - pandas - nbconvert - pytest-timeout - pre-commit -docs = - sphinx - sphinx-bootstrap-theme - numpydoc - -[build_sphinx] -source-dir = docs -build-dir = docs/build -all_files = 1 - -[upload_sphinx] -upload-dir = docs/build/html - -[flake8] -ignore = E501, W503, E402 -builtins = c, get_config -exclude = - .cache, - .github, - docs, - setup.py -enable-extensions = G -extend-ignore = - G001, G002, G004, G200, G201, G202, - # black adds spaces around ':' - E203, -per-file-ignores = - # B011: Do not call assert False since python -O removes these calls - # F841 local variable 'foo' is assigned to but never used - tests/*: B011, F841 diff --git a/setup.py b/setup.py deleted file mode 100644 index 8a4e1954..00000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -"""Setup script for oct2py package. -""" -from setuptools import setup - -setup()