Skip to content

Commit be9c447

Browse files
committed
setup.py: mechanism for including only some files from src/data
Note: This is envisioned for small files (few kb). Larger files should come in a separate distribution. No files are included yet.
1 parent e89f522 commit be9c447

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
prune src/data/*
21
include src/native/*.h src/native/*.cpp

setup.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

33
import os, os.path, sys, glob
4+
from fnmatch import fnmatch
45

56
try:
67
import numpy
@@ -97,7 +98,22 @@ def get_filelist_aux(dir, res):
9798
return res.items()
9899

99100
# Enumerate data files that are to be copied to /share/lsd/data. Format them the way disttools wants it.
100-
data_files = [ (os.path.join('share', 'lsd', *dest.split('/')[1:]), f) for dest, f in get_filelist('src/data') ]
101+
if os.path.isdir('src/data'):
102+
data_files = [ (os.path.join('share', 'lsd', *dest.split('/')[1:]), f) for dest, f in get_filelist('src/data') ]
103+
else:
104+
data_files = []
105+
106+
# Filter only a "necessary" subset of all data. The user can download the whole lsd-data package
107+
# if they're interested. (TODO: provide an automated way to do this)
108+
data_files_whitelist = { } # 'src/data/sfd-dust-maps/SFD_dust_4096_*.fits'
109+
data_files2 = []
110+
for to, files in data_files:
111+
f2 = []
112+
for f in files:
113+
f2 += [ f for pat in data_files_whitelist if fnmatch(f, pat) ]
114+
if f2:
115+
data_files2.append((to, f2))
116+
data_files = data_files2
101117

102118
inc = [ numpy.get_include() ]
103119

0 commit comments

Comments
 (0)