From 1c3d024a0b933f96281890820a1bf579e0731693 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 31 Mar 2023 11:51:08 +0100 Subject: [PATCH] Use pyproject.toml for project configuration (#38) This PR: - Moves project configuration to `pyproject.toml`. One motivation for this was that `cibuildwheel` was picking up the wrong Python versions, and the recommended way to fix this is to have a `requires-python` setting in our `pyproject.toml`. - Removes `ibm2ieee.version` and `ibm2ieee.__version__`, whose presence complicates the versioning and release process. --- CHANGES | 11 ++++++ ibm2ieee/__init__.py | 2 -- ibm2ieee/test/test_ibm2ieee.py | 1 - ibm2ieee/test/test_version.py | 31 ---------------- ibm2ieee/version.py | 12 ------- pyproject.toml | 26 ++++++++++++++ setup.py | 65 +++++----------------------------- 7 files changed, 46 insertions(+), 102 deletions(-) delete mode 100644 ibm2ieee/test/test_version.py delete mode 100644 ibm2ieee/version.py diff --git a/CHANGES b/CHANGES index 686afcd..e042c35 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,17 @@ Changelog for ibm2ieee ====================== +Release 1.3.1 +------------- + +Release date: 2023-03-31 + +This bugfix release fixes the wheel building configuration. In the process, +we also: + +- Move most of the package configuration to `pyproject.toml` +- Drop the `ibm2ieee.version` module and the `ibm2ieee.__version__` attribute. + Release 1.3.0 ------------- diff --git a/ibm2ieee/__init__.py b/ibm2ieee/__init__.py index 028724a..ae3b63f 100644 --- a/ibm2ieee/__init__.py +++ b/ibm2ieee/__init__.py @@ -9,10 +9,8 @@ # Thanks for using Enthought open source! from ._ibm2ieee import ibm2float32, ibm2float64 -from .version import version as __version__ __all__ = [ - "__version__", "ibm2float32", "ibm2float64", ] diff --git a/ibm2ieee/test/test_ibm2ieee.py b/ibm2ieee/test/test_ibm2ieee.py index fd568ae..acfc821 100644 --- a/ibm2ieee/test/test_ibm2ieee.py +++ b/ibm2ieee/test/test_ibm2ieee.py @@ -483,7 +483,6 @@ def test_import_star(self): exec("from ibm2ieee import *", locals, locals) self.assertIn("ibm2float32", locals) self.assertIn("ibm2float64", locals) - self.assertIn("__version__", locals) def test_np_info(self): output = io.StringIO() diff --git a/ibm2ieee/test/test_version.py b/ibm2ieee/test/test_version.py deleted file mode 100644 index db53cfa..0000000 --- a/ibm2ieee/test/test_version.py +++ /dev/null @@ -1,31 +0,0 @@ -# (C) Copyright 2018-2023 Enthought, Inc., Austin, TX -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in LICENSE.txt and may be redistributed only under -# the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# -# Thanks for using Enthought open source! - -import unittest - -import pkg_resources - -import ibm2ieee.version - - -class TestVersion(unittest.TestCase): - def test_version_string(self): - version = ibm2ieee.version.version - self.assertIsInstance(version, str) - - # Check that version number is normalised and complies with PEP 440. - version_object = pkg_resources.parse_version(version) - self.assertEqual(str(version_object), version) - - def test_top_level_package_version(self): - self.assertEqual( - ibm2ieee.__version__, - ibm2ieee.version.version, - ) diff --git a/ibm2ieee/version.py b/ibm2ieee/version.py deleted file mode 100644 index 20833f0..0000000 --- a/ibm2ieee/version.py +++ /dev/null @@ -1,12 +0,0 @@ -# (C) Copyright 2018-2023 Enthought, Inc., Austin, TX -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in LICENSE.txt and may be redistributed only under -# the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# -# Thanks for using Enthought open source! - -# Version string. -version = "1.3.0" diff --git a/pyproject.toml b/pyproject.toml index be97f09..db4b0d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,32 @@ requires = ['oldest-supported-numpy', 'setuptools', 'wheel'] build-backend = 'setuptools.build_meta' +[project] +name = 'ibm2ieee' +version = '1.3.1' +description = 'Convert IBM hexadecimal floating-point to IEEE 754 floating-point' +readme = 'README.rst' +requires-python = ">=3.7" +license = {file = 'LICENSE.txt'} +authors = [{name = 'Enthought', email = 'info@enthought.com'}] +keywords = ['ibm', 'hfp', 'ieee754', 'hexadecimal', 'floating-point', 'ufunc'] +classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3', +] +dependencies = ['numpy'] + +[project.urls] +readme = 'https://github.com/enthought/ibm2ieee/blob/main/README.rst' +repository = 'https://github.com/enthought/ibm2ieee' +issues = 'https://github.com/enthought/ibm2ieee/issues' + +[tool.setuptools.packages.find] +include = ['ibm2ieee*'] + [tool.black] line-length = 79 target-version = ['py36'] diff --git a/setup.py b/setup.py index 95bf243..10b9c08 100644 --- a/setup.py +++ b/setup.py @@ -8,63 +8,16 @@ # # Thanks for using Enthought open source! -import os - import numpy import setuptools - -def get_version_info(): - """Extract version information as a dictionary from version.py.""" - version_info = {} - version_filename = os.path.join("ibm2ieee", "version.py") - with open(version_filename, "r", encoding="utf-8") as version_module: - version_code = compile(version_module.read(), "version.py", "exec") - exec(version_code, version_info) - return version_info - - -def get_long_description(): - """Read long description from README.txt.""" - with open("README.rst", "r", encoding="utf-8") as readme: - return readme.read() - - -ibm2ieee_extension = setuptools.Extension( - name="ibm2ieee._ibm2ieee", - sources=["ibm2ieee/_ibm2ieee.c"], - define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")], - include_dirs=[numpy.get_include()], +setuptools.setup( + ext_modules=[ + setuptools.Extension( + name="ibm2ieee._ibm2ieee", + sources=["ibm2ieee/_ibm2ieee.c"], + define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")], + include_dirs=[numpy.get_include()], + ) + ], ) - -SHORT_DESCRIPTION = """\ -Convert IBM hexadecimal floating-point data to IEEE 754 floating-point data. -""".rstrip() - - -if __name__ == "__main__": - setuptools.setup( - name="ibm2ieee", - version=get_version_info()["version"], - author="Enthought", - author_email="info@enthought.com", - url="https://github.com/enthought/ibm2ieee", - description=SHORT_DESCRIPTION, - long_description=get_long_description(), - long_description_content_type="text/x-rst", - keywords="ibm hfp ieee754 hexadecimal floating-point ufunc", - install_requires=["numpy"], - extras_require={ - "test": ["setuptools"], - }, - python_requires=">=3.7", - packages=setuptools.find_packages(), - ext_modules=[ibm2ieee_extension], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - ], - )