Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test packaging #61

Merged
merged 10 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/ci-cd-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
python-version: [3.9]

steps:
- name: Checkout repository
Expand All @@ -23,11 +23,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dev dependencies
# why pandas 1.1.5 breaks pylint, I do not know
run: |
pip install --upgrade pip wheel
pip install -e .[dev]
pip install pandas==1.1.4
- name: Formatting and linters
run: |
black --check src tests setup.py --exclude openscm_runner/_version.py
Expand Down Expand Up @@ -145,7 +143,17 @@ jobs:
pip install --upgrade pip wheel
pip install -e .[dev]
- name: Create package
run: python setup.py sdist bdist_wheel --universal
run: |
python setup.py sdist bdist_wheel --universal
for f in adapters/fair_adapter/natural-emissions-and-forcing.csv adapters/ciceroscm_adapter/utils_templates/gases_v1RCMIP.txt adapters/ciceroscm_adapter/utils_templates/run_dir/scm_vCH4fb adapters/ciceroscm_adapter/utils_templates/run_dir/input_RF/RFSUN/solar_IPCC.txt
do
if ! tar -tvf dist/openscm-runner*.tar.gz | grep "$f"
then
echo
echo "${f} csv not correctly packaged"
exit 1
fi
done
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
Expand Down
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: "3.9"

python:
install:
- method: pip
path: .
extra_requirements:
- docs
8 changes: 0 additions & 8 deletions .readthedocs.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Changed

- (`#58 <https://github.com/openscm/openscm-runner/pull/58>`_) Update README for FaIR conda install

Fixed
~~~~~

- (`#61 <https://github.com/openscm/openscm-runner/pull/61>`_) Packing (now uses setuptools-scm) and hence includes all required files in source distributions (which should also fix the conda distribution)

v0.9.1 - 2021-09-23
-------------------

Expand Down
6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test-install: $(VENV_DIR) ## test installing works
virtual-environment: ## update venv, create a new venv if it doesn't exist
make $(VENV_DIR)

$(VENV_DIR): setup.py
$(VENV_DIR): setup.py setup.cfg pyproject.toml
[ -d $(VENV_DIR) ] || python3 -m venv $(VENV_DIR)

$(VENV_DIR)/bin/pip install --upgrade pip wheel
Expand Down
15 changes: 4 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

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

import os
import sys

sys.path.append(os.path.dirname(os.path.dirname(__file__)))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../src/openscm_runner"))
from _version import get_versions # isort:skip # append path before

from importlib.metadata import version

# -- Project information -----------------------------------------------------

Expand All @@ -22,10 +15,10 @@
copyright = "{}, {}".format(copyright_year, authors)
author = authors

# The short X.Y version
version = get_versions()["version"].split("+")[0]
# The full version, including alpha/beta/rc tags
release = get_versions()["version"]
release = version("openscm_runner")
# The short X.Y version
version = ".".join(release.split(".")[:2])


# -- General configuration ---------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
requires = [
"setuptools>=41.2",
"setuptools_scm[toml]>=1.15",
"wheel>=0.31.0",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
30 changes: 27 additions & 3 deletions scripts/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Thanks https://stackoverflow.com/a/25562415/10473080
"""
import importlib
import os.path
import pkgutil

import openscm_runner
Expand All @@ -22,8 +23,31 @@ def import_submodules(package_name):


import_submodules("openscm_runner")
# make sure csv was included
openscm_runner.adapters.fair_adapter.fair_adapter._get_natural_emissions_and_forcing(
1750, 4

# make sure csvs etc. are included
openscm_runner_root = os.path.dirname(openscm_runner.__file__)
assert os.path.isfile(
os.path.join(
openscm_runner_root, "adapters/fair_adapter/natural-emissions-and-forcing.csv"
)
)
assert os.path.isfile(
os.path.join(
openscm_runner_root,
"adapters/ciceroscm_adapter/utils_templates/gases_v1RCMIP.txt",
)
)
assert os.path.isfile(
os.path.join(
openscm_runner_root,
"adapters/ciceroscm_adapter/utils_templates/run_dir/scm_vCH4fb",
)
)
assert os.path.isfile(
os.path.join(
openscm_runner_root,
"adapters/ciceroscm_adapter/utils_templates/run_dir/input_RF/RFSUN/solar_IPCC.txt",
)
)

print(openscm_runner.__version__)
127 changes: 111 additions & 16 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,113 @@
[metadata]
name = openscm-runner
keywords = openscm, runner, python, simple, climate, model
author = Zeb Nicholls, Robert Gieseke, Jared Lewis, Sven Willner, Chris Smith
author_email = zebedee.nicholls@climate-energy-college.org, robert.gieseke@pik-potsdam.de, jared.lewis@climate-energy-college.org, sven.willner@pik-potsdam.de, c.j.smith1@leeds.ac.uk
license = 3-Clause BSD License

description = Thin wrapper to run simple climate models (emissions driven runs only)
description_file = README.rst
long_description_content_type = text/x-rst
long_description =
OpenSCM-Runner
==============

OpenSCM-Runner is a thin wrapper to run simple climate models with a
unified interface.
At present, it supports emissions driven runs only.
This wrapper is implemented while
`OpenSCM <https://github.com/openscm/openscm>`_ is still a work in
progress.

url = https://github.com/openscm/openscm-runner
# full list at https://pypi.org/pypi?%3Aaction=list_classifiers
classifiers =
"Development Status :: 4 - Beta"
"License :: OSI Approved :: BSD License"
"Intended Audience :: Developers"
"Operating System :: OS Independent"
Intended Audience :: Science/Research
Programming Language :: Python
Programming Language :: Python :: 3
"Programming Language :: Python :: 3.7"
"Programming Language :: Python :: 3.8"
"Programming Language :: Python :: 3.9"
Topic :: Scientific/Engineering

[options]
packages = find:
package_dir =
=src
include_package_data = True
python_requires = >=3.7
install_requires =
click
openscm-units >= 0.5.0
pyam-iamc
python-dotenv
scmdata >= 0.7.4
tqdm
importlib-metadata; python_version < '3.8'

[options.packages.find]
where = src

[options.extras_require]
fair =
fair

magicc =
pymagicc >= 2.0.0, < 3

models =
%(fair)s
%(magicc)s

notebooks =
ipywidgets
notebook
seaborn

tests =
codecov
coverage
nbval
pytest-cov
pytest>=4.0
xlrd

docs =
sphinx >= 1.4
sphinx_rtd_theme
sphinx-click

dev =
bandit
black == 19.10b0
black-nb
flake8
isort > 5
mypy
nbdime
pydocstyle
pylint >= 2.4.4
%(docs)s
%(notebooks)s
%(tests)s
%(models)s

[options.package_data]
openscm_runner =
adapters/fair_adapter/*.csv
adapters/ciceroscm_adapter/utils_templates/*.txt
adapters/ciceroscm_adapter/utils_templates/pam_RCMIP_test_klimsensdefault.scm
adapters/ciceroscm_adapter/utils_templates/run_dir/*.txt
adapters/ciceroscm_adapter/utils_templates/run_dir/scm_vCH4fb
adapters/ciceroscm_adapter/utils_templates/run_dir/input_OTHER/NATEMIS/*.txt
adapters/ciceroscm_adapter/utils_templates/run_dir/input_RF/RFLUC/*.txt
adapters/ciceroscm_adapter/utils_templates/run_dir/input_RF/RFSUN/*.txt
adapters/ciceroscm_adapter/utils_templates/run_dir/input_RF/RFVOLC/*.txt

[flake8]
max-line-length = 88
ignore = E203, E266, E501, W503
Expand All @@ -7,14 +117,7 @@ default_section = THIRDPARTY
# comma after multiline breaks like black:
include_trailing_comma = true
known_first_party = openscm_runner
# black default line length:
line_length = 88
# multiline breaks like black:
multi_line_output = 3
skip = versioneer.py, src/openscm_runner/_version.py

[metadata]
description-file = README.rst
profile = black

[mypy]
disallow_incomplete_defs = true
Expand All @@ -40,11 +143,3 @@ match = (?!test_|_version).*\.py

[tool:pytest]
testpaths = tests

[versioneer]
VCS = git
style = pep440
versionfile_source = src/openscm_runner/_version.py
versionfile_build = openscm_runner/_version.py
tag_prefix = v
parentdir_prefix = openscm_runner-
Loading