Skip to content

Commit

Permalink
Switch to flit backend (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Mar 31, 2022
1 parent ea0de73 commit d34bba1
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 167 deletions.
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[run]
branch = True
omit =
*/setup.py
oct2py/compat.py
oct2py/tests/*
oct2py/ipython/tests/*

Expand Down
19 changes: 19 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
]
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Run AutoFormatters: https://github.com/blink1073/oct2py/pull/232
00192f2cd97f2395cfce8af69ba3671ae0cb70b1
40 changes: 21 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@ 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
sudo apt-get install -qq octave octave-signal liboctave-dev
- 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
Expand All @@ -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
2 changes: 2 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
conda:
file: docs/environment.yml
29 changes: 0 additions & 29 deletions MANIFEST.in

This file was deleted.

18 changes: 8 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -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
5 changes: 2 additions & 3 deletions docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 5 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions oct2py/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
5 changes: 4 additions & 1 deletion oct2py/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "/"))
Expand Down
6 changes: 0 additions & 6 deletions oct2py/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
70 changes: 63 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}]
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"]
Expand All @@ -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<major>\d+)\.(?P<minor>\d+)\.(?P<micro>\d+)(?P<releaselevel>[a-z]+)?(?P<serial>\d+)?
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<micro>\d+)(?P<releaselevel>[a-z]+)?(?P<serial>[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"
Expand Down
6 changes: 0 additions & 6 deletions readthedocs.yml

This file was deleted.

Loading

0 comments on commit d34bba1

Please sign in to comment.