Skip to content

Commit

Permalink
Update meta packag
Browse files Browse the repository at this point in the history
  • Loading branch information
wpreimes committed Jun 14, 2024
1 parent 775f70f commit 4a18eec
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 175 deletions.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AUTODOCDIR = api

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $?), 1)
$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/")
$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from https://sphinx-doc.org/")
endif

.PHONY: help clean Makefile
Expand Down
96 changes: 32 additions & 64 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,21 @@

import os
import sys
import inspect
import shutil
import subprocess


# Create kernel for notebooks
on_rtd = "READTHEDOCS" in os.environ and os.environ["READTHEDOCS"]
if on_rtd:
rtd_project = os.environ["READTHEDOCS_PROJECT"]
rtd_version = os.environ["READTHEDOCS_VERSION"]
interpreter = (
f"/home/docs/checkouts/readthedocs.org/user_builds/{rtd_project}/"
f"conda/{rtd_version}/bin/python"
)
else:
interpreter = "python"

print("Installing kernel")
subprocess.run(
[
interpreter,
"-m",
"ipykernel",
"install",
"--user",
"--name",
"conda-env-pytesmo-py",
"--display-name",
"Python [conda env:pytesmo]"
],
check=True,
capture_output=True,
)
print("Done")

# -- Path setup --------------------------------------------------------------

__location__ = os.path.join(
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
)
__location__ = os.path.dirname(__file__)

# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.join(__location__, "../src"))
sys.path.insert(0, os.path.join(__location__, "../src"))

# -- Run sphinx-apidoc -------------------------------------------------------
# This hack is necessary since RTD does not issue `sphinx-apidoc` before running
# `sphinx-build -b html . _build/html`. See Issue:
# https://github.com/rtfd/readthedocs.org/issues/1139
# https://github.com/readthedocs/readthedocs.org/issues/1139
# DON'T FORGET: Check the box "Install your project inside a virtualenv using
# setup.py install" in the RTD Advanced Settings.
# Additionally it helps us to avoid running apidoc manually
Expand All @@ -78,13 +43,7 @@
try:
import sphinx

cmd_line_template = (
"sphinx-apidoc --implicit-namespaces"
" -Me -d 3 -f -o {outputdir} {moduledir}"
)
cmd_line = cmd_line_template.format(
outputdir=output_dir, moduledir=module_dir
)
cmd_line = f"sphinx-apidoc --implicit-namespaces -f -o {output_dir} {module_dir}"

args = cmd_line.split(" ")
if tuple(sphinx.__version__.split(".")) >= ("1", "7"):
Expand Down Expand Up @@ -113,7 +72,6 @@
"sphinx.ext.ifconfig",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"nbsphinx",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -130,16 +88,25 @@

# General information about the project.
project = "pytesmo"
copyright = "2021, TU Wien"
copyright = "2024, TU Wien"

# 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 = "" # Is set by calling `setup.py docs`
# The full version, including alpha/beta/rc tags.
release = "" # Is set by calling `setup.py docs`
# version: The short X.Y version.
# release: The full version, including alpha/beta/rc tags.
# If you don’t need the separation provided between version and release,
# just set them both to the same value.
try:
from pytesmo import __version__ as version
except ImportError:
version = ""

if not version or version.lower() == "unknown":
version = os.getenv("READTHEDOCS_VERSION", "unknown") # automatically set by RTD

release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -178,32 +145,30 @@
# If true, keep warnings as "system message" paragraphs in the built documents.
# keep_warnings = False

# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"

html_theme = "alabaster"

# 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 = {"sidebar_width": "300px", "page_width": "1200px",
"show_navbar_depth": 2
}
html_theme_options = {
"sidebar_width": "300px",
"page_width": "1200px"
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
try:
from pytesmo import __version__ as version
except ImportError:
pass
else:
release = version
# html_title = None

# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
Expand Down Expand Up @@ -307,12 +272,15 @@
# -- External mapping --------------------------------------------------------
python_version = ".".join(map(str, sys.version_info[0:2]))
intersphinx_mapping = {
"sphinx": ("http://www.sphinx-doc.org/en/stable", None),
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
"python": ("https://docs.python.org/" + python_version, None),
"matplotlib": ("https://matplotlib.org", None),
"numpy": ("https://docs.scipy.org/doc/numpy", None),
"numpy": ("https://numpy.org/doc/stable", None),
"sklearn": ("https://scikit-learn.org/stable", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
"setuptools": ("https://setuptools.pypa.io/en/stable/", None),
"pyscaffold": ("https://pyscaffold.org/en/stable", None),
}

print(f"loading configurations for {project} {version} ...", file=sys.stderr)
1 change: 1 addition & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../DEVELOPERS_GUIDE.md
1 change: 1 addition & 0 deletions docs/readme.rst
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.. _readme:
.. include:: ../README.rst
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ exclude =
[pyscaffold]
# PyScaffold's parameters when the project was created.
# This will be used when updating. Do not change!
version = 4.0
version = 4.5
package = pytesmo
extensions =
no_skeleton
Expand Down
104 changes: 18 additions & 86 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,89 +1,21 @@
# -*- coding: utf-8 -*-

"""
Setup file for pytesmo.
Use setup.cfg to configure your project.
This file was generated with PyScaffold 4.5.
PyScaffold helps you to put up the scaffold of your new Python project.
Learn more under: https://pyscaffold.org/
"""
from setuptools import setup
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.command.sdist import sdist as _sdist
from setuptools.extension import Extension
import numpy


# list of C/Cython extensions
def get_ext_modules(ext):
return [
Extension(
"pytesmo.time_series.filters",
["src/pytesmo/time_series/filters" + ext],
include_dirs=[numpy.get_include()],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
),
Extension(
"pytesmo.metrics._fast",
["src/pytesmo/metrics/_fast" + ext],
include_dirs=[numpy.get_include()],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
),
Extension(
"pytesmo.metrics._fast_pairwise",
["src/pytesmo/metrics/_fast_pairwise" + ext],
include_dirs=[numpy.get_include()],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
),
]


# defining a custom cythonize function that sets all the options we want and
# that can be reused for the different options
def cythonize_extensions():
from Cython.Build import cythonize

cythonize(
get_ext_modules(".pyx"),
compiler_directives={
"embedsignature": True,
"language_level": 3,
# "warn.undeclared": True,
# "warn.maybe_unitialized": True,
"warn.unused": True,
# "warn.unused_arg": True,
# "warn.unused_result": True,
},
# include_path=[numpy.get_include()],
)


class CythonizeMixin(object):

user_options = [
("cythonize", None, "recreate the c extionsions with cython")
]

def initialize_options(self):
super().initialize_options()
self.cythonize = False

def run(self):
if self.cythonize:
cythonize_extensions()
super().run()


class sdist(CythonizeMixin, _sdist):
user_options = getattr(_sdist, 'user_options', [])\
+ CythonizeMixin.user_options


class build_ext(CythonizeMixin, _build_ext):
user_options = getattr(_build_ext, 'user_options', [])\
+ CythonizeMixin.user_options


if __name__ == "__main__":
cmdclass = {}
cmdclass["sdist"] = sdist
cmdclass["build_ext"] = build_ext
setup(
cmdclass=cmdclass,
# at this point the C modules have already been generated if necessary
ext_modules=get_ext_modules(".c"),
use_scm_version={"version_scheme": "no-guess-dev"}
)
try:
setup(use_scm_version={"version_scheme": "no-guess-dev"})
except: # noqa
print(
"\n\nAn error occurred while building the project, "
"please ensure you have the most updated version of setuptools, "
"setuptools_scm and wheel with:\n"
" pip install -U setuptools setuptools_scm wheel\n\n"
)
raise
26 changes: 3 additions & 23 deletions src/pytesmo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import sys

if sys.version_info[:2] >= (3, 8):
# TODO: Import directly (no need for conditional) when
# `python_requires = >= 3.8`
from importlib.metadata import (
PackageNotFoundError,
version,
) # pragma: no cover
# TODO: Import directly (no need for conditional) when `python_requires = >= 3.8` # noqa: E501
from importlib.metadata import PackageNotFoundError, version # pragma: no cover # noqa: E501
else:
from importlib_metadata import (
PackageNotFoundError,
version,
) # pragma: no cover
from importlib_metadata import PackageNotFoundError, version # pragma: no cover # noqa: E501

try:
# Change here if project is renamed and does not equal the package name
Expand All @@ -21,16 +14,3 @@
__version__ = "unknown"
finally:
del version, PackageNotFoundError


# custom code not generated by PyScaffold
__all__ = [
"metrics",
"scaling",
"temporal_matching",
"timedate",
"time_series",
"grid",
"colormaps",
"validation_framework"
]
Loading

0 comments on commit 4a18eec

Please sign in to comment.