Skip to content

Conversation

lrandersson
Copy link
Contributor

@lrandersson lrandersson commented Oct 9, 2025

Description

To resolve #1074

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Oct 9, 2025
@lrandersson
Copy link
Contributor Author

What is the recommendation here for testing? Two ideas (I think option 1 is the most simple):

  1. Update test_example_extra_files, add also a license file and verify that it exists in the test_install.sh script.
  2. Add a new test similar to test_example_extra_files, but only for the purpose of checking that the license file exists.

Let me know if you have any other idea/preference.

@marcoesters
Copy link
Contributor

What is the recommendation here for testing? Two ideas (I think option 1 is the most simple):

1. Update `test_example_extra_files`, add also a license file and verify that it exists in the `test_install.sh` script.

2. Add a new test similar to `test_example_extra_files`, but only for the purpose of checking that the license file exists.

Let me know if you have any other idea/preference.

I think adding an extra test just for the license file itself is overkill, so option 1 seems simple. However, I also notices that we have no test coverage for all these other files like the content of conda-meta/history and all those required files. This may be out of scope, but something to think about.

@lrandersson lrandersson changed the title [WIP] Add license file to .pkg installers Add license file to .pkg installers Oct 9, 2025
@lrandersson lrandersson marked this pull request as ready for review October 9, 2025 20:04
@lrandersson lrandersson requested a review from a team as a code owner October 9, 2025 20:04
@lrandersson
Copy link
Contributor Author

Updated the test in 1dc095c so the error message when running the test actually points to which file is missing, below is the output from running the test locally (except that I forced it to fail for demonstration):

+ echo 'Added by test-install script'
+ missing=false
+ test -f '/tmp/pytest-of-root/pytest-3/test_example_extra_files0/i n s t a l l-ExtraFiles-X-Linux-aarch64-sh/more_data/README.md'
+ test -f '/tmp/pytest-of-root/pytest-3/test_example_extra_files0/i n s t a l l-ExtraFiles-X-Linux-aarch64-sh/something2.txt'
+ '[' SH = SH ']'
+ test -f '/tmp/pytest-of-root/pytest-3/test_example_extra_files0/i n s t a l l-ExtraFiles-X-Linux-aarch64-sh/LICENSE.txt'
+ echo 'Missing: /tmp/pytest-of-root/pytest-3/test_example_extra_files0/i n s t a l l-ExtraFiles-X-Linux-aarch64-sh/LICENSE.txt'
+ missing=true
+ '[' true = true ']'
+ exit 1
ERROR: executing post_install.sh failed

@lrandersson lrandersson force-pushed the dev-ra-include-license-file branch from 1dc095c to c82e1c8 Compare October 14, 2025 12:29
@lrandersson lrandersson force-pushed the dev-ra-include-license-file branch from c82e1c8 to 1da6431 Compare October 14, 2025 18:46
list[os.PathLike]: List of normalized paths of copied locations.
"""

def check_file_exists(file_path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def check_file_exists(file_path):
def check_file_exists(file_path: str) -> Path:

Let's try and add typing where we can. I'm not sure about that function name either - checking isn't really its primary purpose (or that would return a bool).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that, will make sure I do that in the future.
I've applied all the changes from the first review, see 436cae7.
For some reason it doesn't work to "Add suggestion to batch", even when I go to "File mode" as the UI suggests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may have to switch between the old and new UI to accept suggestions.

Comment on lines 6 to 7
test -f "$PREFIX/more_data/README.md" || { echo "Missing: $PREFIX/more_data/README.md"; missing=true; }
test -f "$PREFIX/something2.txt" || { echo "Missing: $PREFIX/something2.txt"; missing=true; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using proper if statements would make the code easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully agree, I changed all of them.


# 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 macOS the name of the provided license file remains unchanged.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# but for macOS the name of the provided license file remains unchanged.
# but for .pkg the name of the provided license file remains unchanged.

@@ -0,0 +1,19 @@
### Enhancements

* The license file is now also included in the installation directory for macOS package (.pkg) installers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The license file is now also included in the installation directory for macOS package (.pkg) installers.
* Include the license file in PKG installers. (#1074 via #1085)

orig_path = Path(origin)
if not orig_path.exists():
raise FileNotFoundError(f"File {origin} does not exist.")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Let's keep diffs small by not adding additional blank lines where they're not necessary.


tarball = join(tmp_dir, "pkgs", "tmp.tar")
t = tarfile.open(tarball, "w")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


t.add(preconda_tarball, basename(preconda_tarball))
t.add(postconda_tarball, basename(postconda_tarball))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


if "license_file" in info:
t.add(info["license_file"], "LICENSE.txt")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@lrandersson lrandersson force-pushed the dev-ra-include-license-file branch from 626b5e6 to 436cae7 Compare October 21, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

Include license files in PKG and SH installers

3 participants