Skip to content

Commit 4fffe21

Browse files
moved from setupy.py only to pyproject.toml
1 parent c9c6aac commit 4fffe21

File tree

3 files changed

+131
-133
lines changed

3 files changed

+131
-133
lines changed

Makefile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!make
2+
# -*- coding: utf-8 -*-
3+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
4+
# Github: https://github.com/btschwertfeger
5+
6+
VENV := venv
7+
GLOBAL_PYTHON := $(shell which python3)
8+
PYTHON := $(VENV)/bin/python3
9+
10+
.PHONY := build dev install test test_upload live_upload clean
11+
12+
## Builds the python-kraken-sdk
13+
##
14+
build:
15+
$(PYTHON) -m pip wheel -w dist --no-deps .
16+
17+
## Installs the package in edit mode
18+
##
19+
dev:
20+
$(PYTHON) -m pip install -e .[dev]
21+
22+
## Install the package
23+
##
24+
install:
25+
$(PYTHON) -m pip install .
26+
27+
## Run the unittests
28+
##
29+
test:
30+
$(PYTHON) -m pytest tests/
31+
32+
## Build the documentation
33+
##
34+
doc:
35+
cd docs && make html
36+
37+
## Run the documentation tests
38+
##
39+
doctest:
40+
cd docs && make doctest
41+
42+
## Pre-Commit
43+
pre-commit:
44+
@pre-commit run -a
45+
46+
## Clean the workspace
47+
##
48+
clean:
49+
rm -rf .pytest_cache build/ dist/ python_cmethods.egg-info docs/_build
50+
rm -f .coverage cmethods/_version.py
51+
52+
find tests -name "__pycache__" | xargs rm -rf
53+
find cmethods -name "__pycache__" | xargs rm -rf
54+
find examples -name "__pycache__" | xargs rm -rf

pyproject.toml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "python-cmethods"
7+
dynamic = ["version"]
8+
authors = [
9+
{ name="Benjamin Thomas Schwertfeger", email="[email protected]" },
10+
]
11+
description = "Collection of bias correction procedures for 1- and 3-dimensional climate data"
12+
readme = "README.md"
13+
license = {file = "LICENSE"}
14+
requires-python = ">=3.8"
15+
dependencies = [
16+
"xarray>=2022.11.0",
17+
"netCDF4>=1.6.1",
18+
"numpy",
19+
"tqdm",
20+
]
21+
keywords = [
22+
"climate-science",
23+
"bias",
24+
"bias-correction",
25+
"bias-adjustment",
26+
"climate-reanalysis",
27+
"reanalysis",
28+
"linear-scaling",
29+
"variance-scaling",
30+
"delta-method",
31+
"delta-change-method",
32+
"quantile-mapping",
33+
"quantile-delta-mapping"
34+
]
35+
classifiers = [
36+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
37+
"Programming Language :: Python",
38+
"Programming Language :: Python :: 3.8",
39+
"Programming Language :: Python :: 3.9",
40+
"Programming Language :: Python :: 3.10",
41+
"Programming Language :: Python :: 3.11",
42+
"Natural Language :: English",
43+
"Operating System :: MacOS",
44+
"Operating System :: Unix"
45+
]
46+
47+
[project.urls]
48+
"Homepage" = "https://github.com/btschwertfeger/python-cmethods"
49+
"Bug Tracker" = "https://github.com/btschwertfeger/python-cmethods/issues"
50+
51+
[tool.setuptools]
52+
include-package-data = false
53+
54+
[tool.setuptools.packages.find]
55+
include = ["cmethods*"]
56+
exclude = [
57+
"docs*",
58+
"tests*",
59+
"examples*",
60+
".env",
61+
]
62+
63+
[tool.setuptools_scm]
64+
write_to = "cmethods/_version.py"
65+
version_scheme = "guess-next-dev"
66+
local_scheme = "no-local-version"
67+
68+
[tool.pytest]
69+
junit_family = "xunit2"
70+
testpaths = ["tests"]
71+
72+
[project.optional-dependencies]
73+
dev = ["pytest", "scikit-learn", "scipy", "sphinx", "sphinx-rtd-theme"]
74+
examples = ["matplotlib"]

setup.py

Lines changed: 3 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -3,137 +3,7 @@
33
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
44
# Github: https://github.com/btschwertfeger
55

6-
import io
7-
import os
8-
import sys
9-
from shutil import rmtree
6+
import setuptools_scm
7+
from setuptools import setup
108

11-
from setuptools import Command, find_packages, setup
12-
13-
NAME = "python-cmethods"
14-
DESCRIPTION = (
15-
"Collection of bias adjustment procedures for multidimensional climate data"
16-
)
17-
URL = "https://github.com/btschwertfeger/Bias-Adjustment-Python"
18-
19-
AUTHOR = "Benjamin Thomas Schwertfeger"
20-
REQUIRES_PYTHON = ">=3.8.0"
21-
VERSION = "0.6.3"
22-
23-
# What packages are required for this module to be executed?
24-
REQUIRED = [
25-
"xarray>=2022.11.0",
26-
"netCDF4>=1.6.1",
27-
"numpy",
28-
"tqdm",
29-
]
30-
31-
# What packages are optional?
32-
EXTRAS = {
33-
"working examples notebook": ["matplotlib"],
34-
"tests": ["scikit-learn", "scipy"],
35-
}
36-
37-
here = os.path.abspath(os.path.dirname(__file__))
38-
39-
# only works if 'README.md' is present in your MANIFEST.in file!
40-
try:
41-
with io.open(os.path.join(here, "README.md"), encoding="utf-8") as f:
42-
long_description = f"\n{f.read()}"
43-
except FileNotFoundError:
44-
long_description = DESCRIPTION
45-
46-
47-
class UploadCommand(Command):
48-
"""Support setup.py upload."""
49-
50-
description = "Build and publish the package."
51-
user_options = []
52-
53-
@staticmethod
54-
def status(s):
55-
print(f"\033[1m{s}\033[0m")
56-
57-
def initialize_options(self):
58-
pass
59-
60-
def finalize_options(self):
61-
pass
62-
63-
def run(self):
64-
try:
65-
self.status("Removing previous builds…")
66-
rmtree(os.path.join(here, "dist"))
67-
except OSError:
68-
pass
69-
70-
self.status("Building Source and Wheel (universal) distribution…")
71-
os.system(f"{sys.executable} setup.py sdist bdist_wheel --universal")
72-
73-
self.status("Uploading the package to PyPI via Twine…")
74-
os.system("twine upload dist/*")
75-
sys.exit(0)
76-
77-
78-
class TestUploadCommand(Command):
79-
"""Support setup.py test upload."""
80-
81-
description = "Build and test publishing the package."
82-
user_options = []
83-
84-
@staticmethod
85-
def status(s):
86-
print(f"\033[1m{s}\033[0m")
87-
88-
def initialize_options(self):
89-
pass
90-
91-
def finalize_options(self):
92-
pass
93-
94-
def run(self):
95-
try:
96-
self.status("Removing previous builds…")
97-
rmtree(os.path.join(here, "dist"))
98-
except OSError:
99-
pass
100-
101-
self.status("Building Source and Wheel (universal) distribution…")
102-
os.system(f"{sys.executable} setup.py sdist bdist_wheel --universal")
103-
104-
self.status("Uploading the package to PyPI via Twine…")
105-
os.system("twine upload -r testpypi dist/*")
106-
107-
sys.exit(0)
108-
109-
110-
setup(
111-
name=NAME,
112-
version=VERSION,
113-
description=DESCRIPTION,
114-
long_description=long_description,
115-
long_description_content_type="text/markdown",
116-
author=AUTHOR,
117-
author_email=EMAIL,
118-
python_requires=REQUIRES_PYTHON,
119-
url=URL,
120-
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
121-
install_requires=REQUIRED,
122-
extras_require=EXTRAS,
123-
include_package_data=True,
124-
license="GPLv3",
125-
classifiers=[
126-
# Trove classifiers
127-
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
128-
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
129-
"Programming Language :: Python",
130-
"Programming Language :: Python :: 3.8",
131-
"Natural Language :: English",
132-
"Operating System :: MacOS",
133-
"Operating System :: Unix",
134-
],
135-
cmdclass={
136-
"upload": UploadCommand,
137-
"test": TestUploadCommand,
138-
},
139-
)
9+
setup()

0 commit comments

Comments
 (0)