diff --git a/docs/conf.py b/docs/conf.py index 98de6d7..4f786d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ import os import sys import alabaster -from pkg_resources import get_distribution +from sigal import __version__ # 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 @@ -39,12 +39,8 @@ copyright = "2012-2020, Simon Conseil" # 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. -release = get_distribution("sigal").version -# for example take major/minor -version = ".".join(release.split(".")[:2]) - +release = __version__ +version = __version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/src/sigal/__init__.py b/src/sigal/__init__.py index 9e01997..a3cb7ee 100644 --- a/src/sigal/__init__.py +++ b/src/sigal/__init__.py @@ -22,6 +22,7 @@ import importlib import locale import logging import os +import pathlib import socketserver import sys import time @@ -55,7 +56,6 @@ def main(): resize images, create thumbnails with some options, generate html pages. """ - pass # pragma: no cover @main.command() @@ -64,16 +64,13 @@ def init(path): """Copy a sample config file in the current directory (default to 'sigal.conf.py'), or use the provided 'path'.""" - if os.path.isfile(path): + path = pathlib.Path(path) + if path.exists(): print("Found an existing config file, will abort to keep it safe.") sys.exit(1) - from pkg_resources import resource_string - - conf = resource_string(__name__, "templates/sigal.conf.py") - - with open(path, "w", encoding="utf-8") as f: - f.write(conf.decode("utf8")) + conf = pathlib.Path(__file__).parent / "templates" / "sigal.conf.py" + path.write_text(conf.read_text()) print(f"Sample config file created: {path}")