Skip to content

Commit

Permalink
Rap 614 use setuptools scm (#224)
Browse files Browse the repository at this point in the history
* Exclude all files/directories from the source dist first, then include what we want. This is needed, because `setuptools` when used in combination with `setuptools_scm` adds all the files under revision control in the source distribution. We do not want that.

* WIP: Add setuptools_scm

Only adding `setuptools_scm` already required changes to `MANIFEST.in` to avoid that all the files under version control are put into the source distribution.
TODO:
  * Actually start using automatic versioning
  * Move all project settings from `setup.py` to `pyproject.toml`

* WIP: Rename _version.py to _changelog.py

Make room for automatically generated `_version.py` file by renaming the existing file.

* WIP: More or less working version

This still needs some significant cleanup, but at least this appears to work.

* WIP: Remove name and version from setup.py

Automatic versioning only works if version is _not_ also set in `setup.py`.
Also added `bdsf/_version.py` to the `.gitignore` file, because is should *never* be put under version control anymore.

* WIP: Move (almost) all project settings from setup.py to pyproject.toml

All project settings have been moved from `setup.py` to `pyproject.toml`, except for a few that need to be set in the call to `setup()` in `setup.py`, as required by `scikit-build`.

* WIP: Add comment

Added a comment in `setup.py`, explaining why we need to pass some configuration options as arguments to `setup()`, instead of providing them in `pyproject.toml`.

* Strip trailing white-space
  • Loading branch information
gmloose authored May 6, 2024
1 parent 285058e commit 9246686
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ ENV/

# Visual Studio settings
.vscode

# Setuptools SCM
bdsf/_version.py
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Setuptools, when combined with setuptools_scm, puts all the files that are
# under version control in the source distribution. We only want to distribute
# the files needed to build a binary wheel. So, start with an empty slate.
prune *
exclude .*

# Python package files
graft bdsf

# Required scikit-build files
include CMakeLists.txt

Expand Down
10 changes: 3 additions & 7 deletions bdsf/_version.py → bdsf/_changelog.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
"""Version module.
"""Changelog module.
This module simply stores the version number, as well as a changelog.
This module records all the relevant changes made to the software.
The change list must be kept up-to-date manually.
"""

# Version number
__version__ = '1.11.0a1'


# Changelog
def changelog():
"""
PyBDSF Changelog.
Expand Down
3 changes: 2 additions & 1 deletion bdsf/pybdsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ def main():
# Define the welcome banner to print on startup. Also check if there is a newer
# version on the STRW ftp server. If there is, print a message to the user
# asking them to update.
from bdsf._version import __version__, changelog
from bdsf._changelog import changelog
from bdsf._version import __version__

divider1 = '=' * 72 + '\n'
divider2 = '_' * 72 + '\n'
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sphinx-rtd-theme
setuptools_scm
10 changes: 6 additions & 4 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
# import sys, os

from setuptools_scm import get_version

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -50,10 +52,10 @@
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.11'
# The full version, including alpha/beta/rc tags.
release = '1.11.0a1'
release = get_version(root='../..', relative_to=__file__)
# The short X.Y version.
version = version = ".".join(release.split('.')[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 2 additions & 0 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ PyBDSF Documentation

PyBDSF (the **Py**\thon **B**\lob **D**\etector and **S**\ource **F**\inder) is a tool designed to decompose radio interferometry images into sources and make available their properties for further use. PyBDSF can decompose an image into a set of Gaussians, shapelets, or wavelets as well as calculate spectral indices and polarization properties of sources and measure the psf variation across an image. PyBDSF uses an interactive environment based on CASA [#f1]_ that will be familiar to most radio astronomers. Additionally, PyBDSF may also be used in Python scripts.

Software version:
|release|

.. toctree::
:caption: Introduction
Expand Down
71 changes: 71 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#########################
# build-system settings #
#########################

[build-system]
requires = [
"build",
Expand All @@ -7,9 +11,68 @@ requires = [
"oldest-supported-numpy",
"scikit-build>=0.13",
"setuptools",
"setuptools_scm",
"wheel",
]


####################
# project settings #
####################

[project]
name = "bdsf"
dynamic = ["version"]
description = "Blob Detection and Source Finder"
readme = "README.rst"
requires-python = ">=3.7"
authors = [
{ name = "David Rafferty", email = "drafferty@hs.uni-hamburg.de" },
]
maintainers = [
{ name = "Marcel Loose", email = "loose@astron.nl" },
]
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Programming Language :: C++",
"Programming Language :: Fortran",
"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 :: Astronomy",
]
dependencies = [
"backports.shutil_get_terminal_size",
"astropy",
"numpy",
"scipy",
]

[project.optional-dependencies]
"ishell" = [
"ipython!=8.11.*,!=8.12.*,!=8.13.*,!=8.14.*,!=8.15.*",
"matplotlib",
]

[project.scripts]
pybdsf = "bdsf.pybdsf:main [ishell]"
pybdsm = "bdsf.pybdsf:main [ishell]"

[project.urls]
Homepage = "https://github.com/lofar-astron/PyBDSF"
Documentation = "https://pybdsf.readthedocs.io"


#########################
# cibuildwheel settings #
#########################

[tool.cibuildwheel]
before-all = "cibuildwheel/before_all.sh"
before-build = "cibuildwheel/before_build.sh"
Expand All @@ -36,3 +99,11 @@ repair-wheel-command = """\

[tool.cibuildwheel.linux]
skip = ["*-musllinux_*"]


###########################
# setuptools_scm settings #
###########################

[tool.setuptools_scm]
version_file = "bdsf/_version.py"
44 changes: 5 additions & 39 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,8 @@
from skbuild import setup # This line replaces 'from setuptools import setup'
from skbuild import setup

# Scikit-build requires some options to be passed in the call to `setup()`.
# Hence, these cannot be set in `pyproject.toml`
setup(
name='bdsf',
version='1.11.0a1',
author='David Rafferty',
author_email='drafferty@hs.uni-hamburg.de',
url='https://github.com/lofar-astron/PyBDSF',
description='Blob Detection and Source Finder',
long_description=open('README.rst', 'rt').read(),
long_description_content_type='text/x-rst',
platforms='Linux, Mac OS X',
packages=['bdsf', 'bdsf.nat'],
classifiers=[
'Intended Audience :: Science/Research',
'Programming Language :: C++',
'Programming Language :: Fortran',
'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',
'Topic :: Scientific/Engineering :: Astronomy'
],
extras_require={
'ishell': [
'ipython!=8.11.*,!=8.12.*,!=8.13.*,!=8.14.*,!=8.15.*',
'matplotlib',
],
},
install_requires=['backports.shutil_get_terminal_size',
'astropy', 'numpy', 'scipy'],
python_requires=">=3.7",
entry_points = {
'console_scripts': [
'pybdsf = bdsf.pybdsf:main [ishell]',
'pybdsm = bdsf.pybdsf:main [ishell]'
]
},
zip_safe=False,
packages=["bdsf", "bdsf.nat"],
include_package_data=False,
)

0 comments on commit 9246686

Please sign in to comment.