Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions constructor/osxpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ def create(info, verbose=False):
os.makedirs(pkgs_dir)
preconda.write_files(info, prefix)
preconda.copy_extra_files(info.get("extra_files", []), prefix)

# Add potential license file
if license_file := info.get("license_file"):
preconda.copy_extra_files([license_file], prefix)
# These are the user-provided scripts, maybe patched to have a shebang
# They will be called by a wrapping script added later, if present
if info.get("pre_install"):
Expand Down
14 changes: 10 additions & 4 deletions constructor/preconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,24 @@ def copy_extra_files(
Returns:
list[os.PathLike]: List of normalized paths of copied locations.
"""

def validate_file_path(file_path: str) -> Path:
fpath = Path(file_path)
if not fpath.exists():
raise FileNotFoundError(f"File {file_path} does not exist.")
return fpath

if not extra_files:
return []
copied = []
for path in extra_files:
if isinstance(path, str):
copied.append(shutil.copy(path, workdir))
orig_path = validate_file_path(path)
copied.append(shutil.copy(orig_path, workdir))
elif isinstance(path, dict):
assert len(path) == 1
origin, destination = next(iter(path.items()))
orig_path = Path(origin)
if not orig_path.exists():
raise FileNotFoundError(f"File {origin} does not exist.")
orig_path = validate_file_path(origin)
dest_path = Path(workdir) / destination
dest_path.parent.mkdir(parents=True, exist_ok=True)
copied.append(shutil.copy(orig_path, dest_path))
Expand Down
1 change: 1 addition & 0 deletions examples/extra_files/TEST_LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file only exists for testing the .sh and .pkg installers.
1 change: 1 addition & 0 deletions examples/extra_files/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
name: ExtraFiles
version: X
installer_type: all
license_file: TEST_LICENSE.txt
check_path_spaces: False
check_path_length: False
channels:
Expand Down
1 change: 1 addition & 0 deletions examples/extra_files/test_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ echo Added by test-install script > "%PREFIX%\test_install_sentinel.txt"

if not exist "%PREFIX%\more_data\README.md" exit 1
if not exist "%PREFIX%\something2.txt" exit 1
if not exist "%PREFIX%\TEST_LICENSE.txt" exit 1
32 changes: 30 additions & 2 deletions examples/extra_files/test_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,33 @@
set -euxo pipefail
echo "Added by test-install script" > "$PREFIX/test_install_sentinel.txt"

test -f "$PREFIX/more_data/README.md"
test -f "$PREFIX/something2.txt"
missing=false

if [ ! -f "$PREFIX/more_data/README.md" ]; then
echo "Missing: $PREFIX/more_data/README.md"
missing=true
fi

if [ ! -f "$PREFIX/something2.txt" ]; then
echo "Missing: $PREFIX/something2.txt"
missing=true
fi

# Ideally we should test the .pkg and .sh installers separately since
# the current behavior for .sh-installers is to include but also rename the license file to LICENSE.txt,
# but for .pkg the name of the provided license file remains unchanged.
if [ "$INSTALLER_TYPE" = "SH" ]; then
if [ ! -f "$PREFIX/LICENSE.txt" ]; then
echo "Missing: $PREFIX/LICENSE.txt"
missing=true
fi
else # .pkg
if [ ! -f "$PREFIX/TEST_LICENSE.txt" ]; then
echo "Missing: $PREFIX/TEST_LICENSE.txt"
missing=true
fi
fi

if [ "$missing" = true ]; then
exit 1
fi
19 changes: 19 additions & 0 deletions news/1085-include-installer-license-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* Include the license file in PKG installers. (#1074 via #1085)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
Loading