Skip to content

Commit

Permalink
Package demo scripts and data in sdists and wheels
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jacklovell committed Feb 23, 2023
1 parent 793c4c6 commit a029b09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 2 additions & 5 deletions 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
15 changes: 14 additions & 1 deletion 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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
)
Expand Down

0 comments on commit a029b09

Please sign in to comment.