Skip to content

Commit

Permalink
Modernize the build system using pyproject.toml
Browse files Browse the repository at this point in the history
Also, remove vendored `versioneer.py`
  • Loading branch information
claudiodsf committed Sep 24, 2024
1 parent 955bd26 commit 508f69f
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 1,950 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ sourcespec.egg-info/
dist/
build/
RELEASE-VERSION
README_pkg.md
7 changes: 1 addition & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include CHANGELOG.md
include README.md
exclude README_pkg.md
include LICENSE.txt
include CONTRIBUTORS.txt
# include only files in docs, not subdirs like _build
Expand All @@ -9,9 +10,3 @@ include imgs/*
# building docs
exclude docs/configuration_file.rst
include bin/*.py
include versioneer.py
include sourcespec/_version.py
include sourcespec/config_files/configspec.conf
include sourcespec/config_files/ssp_event.yaml
include sourcespec/html_report_template/style.css
include sourcespec/html_report_template/*.html
2 changes: 0 additions & 2 deletions make_dist.sh

This file was deleted.

87 changes: 87 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[build-system]
requires = ["setuptools>=71", "versioneer[toml]"]
build-backend = "setuptools.build_meta"

[project]
name = "sourcespec"
dynamic = ["version"]
authors = [
{ name = "Claudio Satriano", email = "[email protected]" },
]
description = "Earthquake source parameters from P- or S-wave displacement spectra"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: CEA CNRS Inria Logiciel Libre License, version 2.1 (CeCILL-2.1)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
]
requires-python = ">=3.7"
dependencies = [
"numpy>=1.10",
"scipy>=0.17",
"matplotlib>=3.2,<3.10",
"pillow>=4.0.0",
"obspy>=1.2.0",
"pyproj",
"tzlocal",
"pyyaml>=5.1",
"h5py",
]

[project.license]
text = "CeCILL Free Software License Agreement, Version 2.1"

[project.readme]
file = "README_pkg.md"
content-type = "text/markdown"

[project.urls]
Homepage = "https://sourcespec.seismicsource.org"
Source = "https://github.com/SeismicSource/sourcespec"
Documentation = "https://sourcespec.readthedocs.io"

[project.scripts]
source_spec = "sourcespec.source_spec:main"
source_model = "sourcespec.source_model:main"
source_residuals = "sourcespec.source_residuals:main"
clipping_detection = "sourcespec.clipping_detection:main"
plot_sourcepars = "sourcespec.plot_sourcepars:main"

[tool.setuptools]
packages = [
"sourcespec",
"sourcespec.adjustText",
"sourcespec.config_files",
"sourcespec.configobj",
"sourcespec.html_report_template"
]
include-package-data = true
platforms = [
"OS",
"Independent",
]

[tool.setuptools.dynamic]
version = {attr = "sourcespec.__version__"}

[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "sourcespec/_version.py"
versionfile_build = "sourcespec/_version.py"
tag_prefix = "v"
parentdir_prefix = "sourcespec-"

[tool.pylama]
skip = "build/*,versioneer.py,*/_version.py,*/configobj/*,*/adjustText/*"
10 changes: 0 additions & 10 deletions setup.cfg

This file was deleted.

93 changes: 16 additions & 77 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: CECILL-2.1
"""
Setup script for SourceSpec
"""
# pylint: disable=wrong-import-position, consider-using-f-string
import sys
A minimal setup script for SourceSpec.
MIN_PYTHON_VERSION = (3, 7)
MIN_PYTHON_VERSION_STR = '.'.join(str(n) for n in MIN_PYTHON_VERSION)
PYTHON_VERSION_STR = '.'.join(str(n) for n in sys.version_info[:3])
if sys.version_info < MIN_PYTHON_VERSION:
MSG = (
'SourceSpec requires Python version >= {}'
' you are using Python version {}'.format(
MIN_PYTHON_VERSION_STR, PYTHON_VERSION_STR)
)
sys.exit(MSG)
This script ensures compatibility with versioneer
and generates a README_pkg.md for correctly displaying images on PyPI.
All the remaining configuration is in pyproject.toml.
"""
import os
from setuptools import setup
import versioneer

from setuptools import setup # noqa
import versioneer # noqa
# Generate a README_pkg.md file with CDN links to images, to be used for
# PKG-INFO on PyPI. This file is removed after the setup is complete.
revision = versioneer.get_versions()['full-revisionid']
cdn_baseurl = 'https://cdn.jsdelivr.net/gh/SeismicSource/sourcespec@{}'\
.format(revision)
with open('README.md', 'rb') as f:
long_descr = f.read().decode('utf-8').replace(
readme_pkg = f.read().decode('utf-8').replace(
'imgs/SourceSpec_logo.svg',
'{}/imgs/SourceSpec_logo.svg'.format(cdn_baseurl)
).replace(
Expand All @@ -36,65 +31,9 @@
'(CHANGELOG.md)',
'({}/CHANGELOG.md)'.format(cdn_baseurl)
)
with open('README_pkg.md', 'w', encoding='utf-8') as f:
f.write(readme_pkg)

project_urls = {
'Homepage': 'https://sourcespec.seismicsource.org',
'Source': 'https://github.com/SeismicSource/sourcespec',
'Documentation': 'https://sourcespec.readthedocs.io'
}
setup(cmdclass=versioneer.get_cmdclass())

setup(
name='sourcespec',
packages=['sourcespec', 'sourcespec.configobj', 'sourcespec.adjustText'],
include_package_data=True,
entry_points={
'console_scripts': [
'source_spec = sourcespec.source_spec:main',
'source_model = sourcespec.source_model:main',
'source_residuals = sourcespec.source_residuals:main',
'clipping_detection = sourcespec.clipping_detection:main',
'plot_sourcepars = sourcespec.plot_sourcepars:main',
]
},
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
description='Earthquake source parameters from P- or S-wave '
'displacement spectra',
long_description=long_descr,
long_description_content_type='text/markdown',
author='Claudio Satriano',
author_email='[email protected]',
url=project_urls['Homepage'],
project_urls=project_urls,
license='CeCILL Free Software License Agreement, Version 2.1',
platforms='OS Independent',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: CEA CNRS Inria Logiciel Libre '
'License, version 2.1 (CeCILL-2.1)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Physics'],
python_requires='>={}'.format(MIN_PYTHON_VERSION_STR),
install_requires=[
'numpy>=1.10',
'scipy>=0.17',
'matplotlib>=3.2,<3.10',
'pillow>=4.0.0',
'obspy>=1.2.0',
'pyproj',
'tzlocal',
'pyyaml>=5.1',
'h5py'
]
)
os.remove('README_pkg.md')
Loading

0 comments on commit 508f69f

Please sign in to comment.