From 3e08c5218256de9e0c03dc43e1aa502ac7f67a0b Mon Sep 17 00:00:00 2001 From: Duncan Macleod Date: Fri, 28 Jan 2022 11:41:06 +0000 Subject: [PATCH 1/2] use setuptools-scm for versioning --- .gitignore | 1 + dqsegdb2/__init__.py | 6 +++++- pyproject.toml | 6 +++++- setup.cfg | 7 +++++++ setup.py | 41 ----------------------------------------- 5 files changed, 18 insertions(+), 43 deletions(-) delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 45f55e1..c41363a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ __pycache__/ .coverage .pytest_cache/ /docs/api +/dqsegdb2/_version.py diff --git a/dqsegdb2/__init__.py b/dqsegdb2/__init__.py index 2e8426a..83bf473 100644 --- a/dqsegdb2/__init__.py +++ b/dqsegdb2/__init__.py @@ -18,6 +18,10 @@ """A simplified Python implementation of the DQSEGDB API. """ -__version__ = '1.0.1' +try: + from ._version import version as __version__ +except ModuleNotFoundError: # development mode + __version__ = 'dev' + __author__ = 'Duncan Macleod ' __credits__ = 'Ryan Fisher, Gary Hemming' diff --git a/pyproject.toml b/pyproject.toml index 0898375..12565d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,14 @@ [build-system] requires = [ - "setuptools>=30.3.0", + "setuptools>=42", + "setuptools_scm[toml]>=3.4", "wheel", ] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +write_to = "dqsegdb2/_version.py" + [tool.pytest.ini_options] addopts = "-r a" filterwarnings = [ diff --git a/setup.cfg b/setup.cfg index a5001ef..cbfebb6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,6 +41,8 @@ packages = find: python_requires = >=3.6 setup_requires = setuptools >= 30.3.0 + setuptools_scm + wheel install_requires = igwn-auth-utils[requests] ligo-segments @@ -51,6 +53,11 @@ tests_require = # -- extras +[coverage:run] +source = dqsegdb2 +omit = + dqsegdb2/_version.py + [flake8] exclude = __pycache__, diff --git a/setup.py b/setup.py deleted file mode 100644 index c4ada4b..0000000 --- a/setup.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# DQSEGDB2 -# Copyright (C) 2018,2020 Duncan Macleod -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -"""Install script for DQSEGDB2 -""" - -import os -import re - -from setuptools import setup - - -def parse_version(path): - """Extract the `__version__` string from the given file - """ - with open(path, 'r') as fp: - version_file = fp.read() - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - - -setup( - version=parse_version(os.path.join("dqsegdb2", "__init__.py")), -) From af3325dc98527b856b34f373527bf197cac97341 Mon Sep 17 00:00:00 2001 From: Duncan Macleod Date: Fri, 28 Jan 2022 11:58:24 +0000 Subject: [PATCH 2/2] docs: add readthedocs config file --- .readthedocs.yml | 21 +++++++++++++++++++++ docs/environment.yml | 20 ++++++++++++++++++++ requirements-docs.txt | 5 ----- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 .readthedocs.yml create mode 100644 docs/environment.yml delete mode 100644 requirements-docs.txt diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..dc397f9 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,21 @@ +# .readthedocs.yml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +version: 2 + +build: + os: "ubuntu-20.04" + tools: + python: "mambaforge-4.10" + +conda: + environment: docs/environment.yml + +sphinx: + configuration: docs/conf.py + +python: + install: + - method: pip + path: . diff --git a/docs/environment.yml b/docs/environment.yml new file mode 100644 index 0000000..5c2d0d5 --- /dev/null +++ b/docs/environment.yml @@ -0,0 +1,20 @@ +name: dqsegdb2 +channels: + - conda-forge +dependencies: + # build + - pip + - setuptools + - setuptools-scm + - wheel + # install + - igwn-auth-utils + - ligo-segments + - requests + - safe-netrc + # docs + - numpydoc + - sphinx + - sphinx_rtd_theme + - sphinx-automodapi + - sphinx-tabs diff --git a/requirements-docs.txt b/requirements-docs.txt deleted file mode 100644 index 6ae9cc0..0000000 --- a/requirements-docs.txt +++ /dev/null @@ -1,5 +0,0 @@ -numpydoc -sphinx -sphinx_rtd_theme -sphinx-automodapi -sphinx-tabs