From a029b09cd2a91a5ce752115fc4b85d989bfd50dc Mon Sep 17 00:00:00 2001 From: Jack Lovell Date: Thu, 23 Feb 2023 17:49:59 +0000 Subject: [PATCH] Package demo scripts and data in sdists and wheels This enables users who haven't cloned the git repository to still run the demos. A few unnecessary entries were removed from MANIFEST.in too. TODO: see whether we can get rid of MANIFEST.in completely and use setuptools' find_packages and package_data instead. --- MANIFEST.in | 7 ++----- setup.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 2f977070..2d850775 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,3 @@ -include README.md CHANGELOG.md LICENSE.txt CITE.md AUTHORS.md MANIFEST.in setup.py requirements.txt .gitignore +include CHANGELOG.md CITE.md AUTHORS.md include cherab/core/VERSION -recursive-include cherab *.py *.pyx *.pxd *.json *.cl *.npy *.obj -prune demos* - - +recursive-include cherab *.pyx *.pxd *.json *.cl *.npy *.obj diff --git a/setup.py b/setup.py index 476697e8..ba84e56e 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,10 @@ from setuptools import setup, find_packages, Extension +from collections import defaultdict import sys import numpy import os import os.path as path +from pathlib import Path import multiprocessing from Cython.Build import cythonize @@ -68,6 +70,16 @@ compiler_directives=cython_directives, ) +# Include demos in a separate directory in the distribution as data_files. +demo_parent_path = Path("share/cherab/demos/core") +data_files = defaultdict(list) +demos_source = Path("demos") +for item in demos_source.rglob("*"): + if item.is_file(): + install_dir = demo_parent_path / item.parent.relative_to(demos_source) + data_files[str(install_dir)].append(str(item)) +data_files = list(data_files.items()) + # parse the package version number with open(path.join(path.dirname(__file__), "cherab/core/VERSION")) as version_file: version = version_file.read().strip() @@ -105,8 +117,9 @@ "matplotlib", "raysect==0.8.1", ], - packages=find_packages(), + packages=find_packages(include=["cherab*"]), include_package_data=True, + data_files=data_files, zip_safe=False, ext_modules=extensions, )