From 540a3944f66f9a208f9a24f8fbfa7c418c852de3 Mon Sep 17 00:00:00 2001 From: Kingsley Collie Date: Wed, 29 Jan 2025 21:22:42 +0000 Subject: [PATCH 1/7] Simplify building cython extension Fix attempting to compile all cython under repository directory. --- setup.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index eb1fbad..b0ded18 100644 --- a/setup.py +++ b/setup.py @@ -57,22 +57,18 @@ extra_compile_args = [] extra_link_args = ["-Wl,-rpath,.", "-Wl,-rpath,{}".format(idl_library_path)] -setup_path = path.dirname(path.abspath(__file__)) +idl_core_sources = ["idlbridge/_core.pyx"] +idl_core = Extension( + "idlbridge._core", + idl_core_sources, + include_dirs=include_dirs, + libraries=libraries, + library_dirs=library_dirs, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, +) -# build extension list -extensions = [] -for root, dirs, files in os.walk(setup_path): - for file in files: - if path.splitext(file)[1] == ".pyx": - pyx_file = path.relpath(path.join(root, file), setup_path) - module = path.splitext(pyx_file)[0].replace("/", ".") - extensions.append(Extension(module, - [pyx_file], - include_dirs=include_dirs, - libraries=libraries, - library_dirs=library_dirs, - extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args)) +extensions = [idl_core] if profile: directives = {"profile": True} From dc8edf6a1265f6d05bdded9c1bb3c0a543282cc8 Mon Sep 17 00:00:00 2001 From: Kingsley Collie Date: Mon, 3 Feb 2025 18:51:02 +0000 Subject: [PATCH 2/7] Add CI workflow to build source distribution --- .github/workflows/sdist.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/sdist.yml diff --git a/.github/workflows/sdist.yml b/.github/workflows/sdist.yml new file mode 100644 index 0000000..a938ff9 --- /dev/null +++ b/.github/workflows/sdist.yml @@ -0,0 +1,35 @@ +# This workflow will install Python and build sdist + +name: sdist + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - dev + +jobs: + build-dist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.13 + + - name: Build package + run: | + pip install build + # fake IDL_DIR to build source package without installing IDL + IDL_DIR=/fake-idl-dir python -m build --sdist . + + - name: Store source distribution as artifact + uses: actions/upload-artifact@v4 + with: + path: 'dist/idlbridge-*.tar.gz' From 2bd1088816a2f1f05136f532e1d973845a079b72 Mon Sep 17 00:00:00 2001 From: Kingsley Collie Date: Wed, 29 Jan 2025 17:40:47 +0000 Subject: [PATCH 3/7] Use setuptools rather than distutils imports in setup.py --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b0ded18..4e17cdc 100644 --- a/setup.py +++ b/setup.py @@ -15,8 +15,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with IDLBridge. If not, see . -from distutils.core import setup -from distutils.extension import Extension +from setuptools import setup, Extension from Cython.Build import cythonize import sys import numpy From 51ca34b7d8de0f867770af33fe77af0710a1bd32 Mon Sep 17 00:00:00 2001 From: Kingsley Collie Date: Wed, 29 Jan 2025 15:37:10 +0000 Subject: [PATCH 4/7] Specify build-system requirements using PEP518 --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..dcf2909 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "Cython", "numpy"] +build-backend = "setuptools.build_meta" From ed64e30ed9cb7d1b347d58f502a273d08e46da2f Mon Sep 17 00:00:00 2001 From: Kingsley Collie Date: Wed, 29 Jan 2025 21:34:55 +0000 Subject: [PATCH 5/7] Add numpy to install_requires --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4e17cdc..a7f5553 100644 --- a/setup.py +++ b/setup.py @@ -91,8 +91,7 @@ "Operating System :: POSIX :: Linux", "Topic :: Scientific/Engineering" ], -# setup_requires=["cython>=0.19"], -# install_requires=["cython>=0.19"], + install_requires=["numpy"], packages=["idlbridge"], ext_modules=cythonize(extensions, force=force, compiler_directives=directives) ) From 4651146f1a91dd5209ed202582551176cc85ee3d Mon Sep 17 00:00:00 2001 From: Kingsley Collie Date: Mon, 3 Feb 2025 15:40:40 +0000 Subject: [PATCH 6/7] Use importlib.metadata to get package version --- idlbridge/__init__.py | 8 +++++++- setup.py | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/idlbridge/__init__.py b/idlbridge/__init__.py index de451ef..743aca0 100644 --- a/idlbridge/__init__.py +++ b/idlbridge/__init__.py @@ -26,9 +26,15 @@ import ctypes as _ctypes from . import _core +try: + from importlib.metadata import version +except ImportError: + # try-except be removed if requires-python set to >= 3.8 + from importlib_metadata import version + __author__ = 'Dr. Alex Meakins' __responsible_officer__ = 'Dr. Alex Meakins' -__version__ = "1.1.0" +__version__ = version("idlbridge") # By default the core (IDL) library is opened by Python with RTLD_LOCAL # preventing subsequently loaded IDL DLM libraries from seeing the IDL_* diff --git a/setup.py b/setup.py index a7f5553..414a3f1 100644 --- a/setup.py +++ b/setup.py @@ -78,6 +78,7 @@ name="idlbridge", version=__version__, description="An IDL wrapper for Python", + requires_python=">=3.4", author='Dr. Alex Meakins', author_email='alex.meakins@ukaea.uk', license="LGPLv3", @@ -91,7 +92,10 @@ "Operating System :: POSIX :: Linux", "Topic :: Scientific/Engineering" ], - install_requires=["numpy"], + install_requires=[ + "importlib_metadata>=0.1 ; python_version < \"3.8\"", + "numpy", + ], packages=["idlbridge"], ext_modules=cythonize(extensions, force=force, compiler_directives=directives) ) From 39d30861ee1b8190fdb05caaefead59590667b3f Mon Sep 17 00:00:00 2001 From: Kingsley Collie Date: Mon, 3 Feb 2025 15:41:36 +0000 Subject: [PATCH 7/7] Remove VERSION file --- MANIFEST.in | 2 +- idlbridge/VERSION | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 idlbridge/VERSION diff --git a/MANIFEST.in b/MANIFEST.in index 33f21da..603ab84 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ include README.md MANIFEST.in setup.py .gitignore -recursive-include idlbridge *.py *.pyx *.pxd *.pxi *.pro VERSION +recursive-include idlbridge *.py *.pyx *.pxd *.pxi *.pro recursive-include dev * diff --git a/idlbridge/VERSION b/idlbridge/VERSION deleted file mode 100644 index 1cc5f65..0000000 --- a/idlbridge/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.1.0 \ No newline at end of file