Skip to content
Snippets Groups Projects
Commit 1c86f81c authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

Fix incorrect installation of CWL files

Many CWL files were being installed in the wrong directory. This
has been fixed. This commit fixes RAP-249.
parent ad901939
No related branches found
No related tags found
2 merge requests!69Change the name of the pre-calibrated output MS,!49Fix incorrect installation of CWL files
Pipeline #19769 passed
from setuptools import setup from setuptools import setup
import os import os
import pathlib
def read(rel_path): def read(rel_path):
...@@ -12,6 +11,13 @@ def read(rel_path): ...@@ -12,6 +11,13 @@ def read(rel_path):
return fp.read() return fp.read()
data_files = []
for top in ('lofar-cwl/steps', 'steps', 'subworkflow', 'workflows'):
for root, _, files in os.walk(top):
cwl_files = [os.path.join(root, f) for f in files if f.endswith('.cwl')]
if cwl_files:
data_files.append((os.path.join('share/prefactor', root), cwl_files))
  • Developer

    Does "root" appear twice here (once in cwl_files and once in the this line)?

  • Author Owner

    Yes, but that's on purpose. data_files is a list of tuples of (dir, files) (see https://docs.python.org/3/distutils/setupscript.html#installing-additional-files), where dir must contain the destination directory, and files the list of files that must be installed in that directory.

  • Please register or sign in to reply
setup( setup(
name='prefactor3-cwl', name='prefactor3-cwl',
version='0.3.0', version='0.3.0',
...@@ -28,7 +34,5 @@ setup( ...@@ -28,7 +34,5 @@ setup(
install_requires=[ install_requires=[
'prefactor@git+https://github.com/lofar-astron/prefactor.git' 'prefactor@git+https://github.com/lofar-astron/prefactor.git'
], ],
data_files=[(os.path.join('share', 'prefactor', dir), data_files=data_files
[str(p) for p in pathlib.Path(dir).glob('**/*.cwl')]) for dir in
('lofar-cwl', 'steps', 'subworkflow', 'workflows')]
) )
  • Author Owner

    BTW: I do have a different implementation for lines 14-19 that doesn't use os.walk, but glob.glob instead. It's a bit slower, but maybe you consider it more readable:

    cwl_files = collections.defaultdict(list)
    for dir in ('lofar-cwl', 'steps', 'subworkflow', 'workflows'):
        for file in glob.glob(os.path.join(dir, '**/*.cwl'), recursive=True):
            cwl_files[os.path.join('share', 'prefactor', os.path.dirname(file))].append(file)
    data_files = cwl_files.items()
  • Developer

    The version with os.walk is fine with me -- though I did indeed misread it initially :)

  • Marcel Loose :sunglasses: @loose

    mentioned in commit 529e3eee

    ·

    mentioned in commit 529e3eee

    Toggle commit list
  • Marcel Loose :sunglasses: @loose

    mentioned in commit 1ecd06c9

    ·

    mentioned in commit 1ecd06c9

    Toggle commit list
  • Marcel Loose :sunglasses: @loose

    mentioned in commit 99899e96

    ·

    mentioned in commit 99899e96

    Toggle commit list
  • Marcel Loose :sunglasses: @loose

    mentioned in commit b95945e1

    ·

    mentioned in commit b95945e1

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment