Skip to content

Commit b30b80b

Browse files
committed
build: created pyproject.toml and deleted setup.py for compliance with PEP621 and PEP660. Added automatic versioning with setuptools_scm. Added tox as dev dependency to run local tests on multiple python versions. Changed conda build file to environment.yml
docs: modified installing instructions accordingly lic: change license name to LICENSE
1 parent 1c81958 commit b30b80b

File tree

9 files changed

+89
-84
lines changed

9 files changed

+89
-84
lines changed
File renamed without changes.

MANIFEST.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include README.md
22
include CONTRIBUTING.md
33
include CODE_OF_CONDUCT.md
44
include Dockerfile
5-
include LICENSE.txt
5+
include LICENSE
66
include CHANGELOG.md
77
include CREDITS.md
88
include codemeta.json
@@ -23,8 +23,5 @@ global-exclude .git*
2323
global-exclude *.pyc
2424
global-exclude *.html
2525
global-exclude *.so
26-
global-exclude *.xls
27-
global-exclude *.xlsm
28-
global-exclude *.xlsx
2926
global-exclude *~
3027
global-exclude .DS_Store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ Development of pyCSEP is a group effort. A list of developers that have contribu
8989
are listed in the [credits](CREDITS.md) file in this repository.
9090

9191
# License:
92-
The pyCSEP software is distributed under the BSD 3-Clause open-source license. Please see the [license](LICENSE.txt) file for more information.
92+
The pyCSEP software is distributed under the BSD 3-Clause open-source license. Please see the [license](LICENSE) file for more information.

csep/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import os
33
import time
44

5-
from csep._version import __version__
6-
75
from csep.core import forecasts
86
from csep.core import catalogs
97
from csep.core import poisson_evaluations
@@ -37,6 +35,13 @@
3735
utc_now_epoch
3836
)
3937

38+
from importlib.metadata import version as _pkg_version, PackageNotFoundError
39+
40+
try:
41+
__version__ = _pkg_version("pycsep")
42+
except PackageNotFoundError:
43+
__version__ = "0+unknown"
44+
4045
# this defines what is imported on a `from csep import *`
4146
__all__ = [
4247
'load_json',
@@ -80,8 +85,8 @@ def load_stochastic_event_sets(filename, type='csv', format='native',
8085
(generator): :class:`~csep.core.catalogs.AbstractBaseCatalog`
8186
8287
"""
83-
if type not in ('ucerf3', 'csv'):
84-
raise ValueError("type must be one of the following: (ucerf3)")
88+
if type not in ('ucerf3', 'csv', 'csep'):
89+
raise ValueError("type must be one of the following: (ucerf3, csv, csep)")
8590

8691
# use mapping to dispatch to correct function
8792
# in general, stochastic event sets are loaded with classmethods and single catalogs use the
@@ -105,7 +110,7 @@ def load_stochastic_event_sets(filename, type='csv', format='native',
105110
elif format == 'csep':
106111
yield catalog.get_csep_format()
107112
else:
108-
raise ValueError('format must be either "native" or "csep!')
113+
raise ValueError('format must be either "native" or "csep!"')
109114

110115

111116
def load_catalog(filename, type='csep-csv', format='native', loader=None,

csep/_version.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/getting_started/installing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ If you don't have ``conda`` on your machine, download and install `Miniconda <ht
6060

6161
git clone https://github.com/SCECcode/pycsep
6262
cd pycsep
63-
conda env create -f requirements.yml
63+
conda env create -f environment.yml
6464
conda activate csep-dev
6565
# Installs in editor mode with all dependencies
6666
pip install -e .
@@ -79,7 +79,7 @@ follow these instructions: ::
7979
python -m virtualenv venv
8080
source venv/bin/activate
8181
# Installs in editor mode dependencies are installed by conda
82-
pip install -e .[all]
82+
pip install -e .
8383

8484
Note: If you want to go back to your default environment use the command ``deactivate``.
8585

@@ -92,9 +92,9 @@ We recommend using ``conda`` to install the development environment. ::
9292

9393
git clone https://github.com/<YOUR_GITHUB_USERNAME>/pycsep.git
9494
cd pycsep
95-
conda env create -f requirements.yml
95+
conda env create -f environment.yml
9696
conda activate csep-dev
97-
pip install -e .[all]
97+
pip install -e .[dev]
9898
# Allow sync with default repository
9999
git remote add upstream https://github.com/SCECCode/pycsep.git
100100

requirements.yml renamed to environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6-
- python>=3.7
6+
- python = 3.10
7+
- pip
78
- numpy
89
- pandas
910
- scipy

pyproject.toml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
[build-system]
2+
requires = ["setuptools>=69", "wheel", "build", "setuptools-scm>=8"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pycsep"
7+
dynamic = ["version"] # <— version comes from SCM
8+
description = "Python tools from the Collaboratory for the Study of Earthquake Predictability"
9+
readme = "README.md"
10+
requires-python = ">=3.9"
11+
license = { file = "LICENSE" }
12+
authors = [{ name = "William Savran", email = "[email protected]" }]
13+
urls = { "Homepage" = "https://github.com/SCECCode/pycsep" }
14+
15+
dependencies = [
16+
"numpy",
17+
"scipy",
18+
"pandas",
19+
"matplotlib",
20+
"cartopy",
21+
"obspy",
22+
"pyproj",
23+
"python-dateutil",
24+
"rasterio",
25+
"mercantile",
26+
"shapely",
27+
]
28+
29+
[project.optional-dependencies]
30+
dev = ["pytest", "vcrpy", "pytest-cov", "sphinx", "sphinx-gallery", "sphinx-rtd-theme", "pillow", "tox"]
31+
32+
[tool.setuptools]
33+
include-package-data = true
34+
35+
[tool.setuptools.packages.find]
36+
where = ["."]
37+
include = ["csep*"]
38+
39+
[tool.setuptools_scm]
40+
version_scheme = "post-release"
41+
42+
[tool.tox]
43+
min_version = "4.0"
44+
env_list = ["py39", "py310", "py311", "py312"]
45+
skip_missing_interpreters = true
46+
47+
[tool.tox.requires]
48+
requires = ["tox-conda>=0.10"]
49+
50+
[tool.tox.env.py]
51+
package = "wheel"
52+
wheel_build_env = ".pkg"
53+
extras = ["dev"]
54+
conda_channels = ["conda-forge"]
55+
conda_deps = [
56+
"python",
57+
"numpy",
58+
"pandas",
59+
"scipy",
60+
"matplotlib",
61+
"pyproj",
62+
"obspy",
63+
"python-dateutil",
64+
"cartopy",
65+
"shapely",
66+
"rasterio",
67+
"mercantile"
68+
]
69+
set_env = { MPLBACKEND = "Agg" }
70+
pass_env = ["PYTEST_ADDOPTS"]
71+
commands = ["pytest --basetemp={envtmpdir}"]

setup.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)