Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REF: Split libraries into separate outputs #74

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

carterbox
Copy link
Member

@carterbox carterbox commented Mar 5, 2024

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

Hi maintainers!

It looks like this feedstock is still shipping static libraries. It has been our channel's policy since 2020 that static libraries are not shipped or are separated into their own output. For more information about our static library policy, please read CFEP-18.

In this PR, I have restructured the recipe into multiple outputs including separating the static libraries and dev files from necessary run_exports (the shared objects). The method I am using is to "build everything, then split". Everything is built in the top-level section and installed to a staging directory. Then a custom python install script is used to selectively install the artifacts based on the name of each output.

My motivation for this PR is to reduce the size of artifacts in my packages dependency trees starting from packages with the largest artifacts to the smallest.

Checklist for multi-output transition

  • Compare info/has_prefix for changes
  • Compare info/files for changes
  • Choose package names to prevent breaks of existing builds

@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipe) and found some lint.

Here's what I've got...

For recipe:

  • The extra section contained an unexpected subsection name. feestock-name is not a valid subsection name.

For recipe:

  • It looks like the '_libcairo_api' output doesn't have any tests.

@carterbox carterbox changed the title Multi output REF: Split libraries into separate outputs Mar 5, 2024
@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

I do have some suggestions for making it better though...

For recipe:

  • It looks like the '_libcairo_api' output doesn't have any tests.

outputs:

# Everything needed to build against libcairo
- name: cairo
Copy link
Member Author

Choose a reason for hiding this comment

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

Because the "everything minus static libs" package is named "cairo" existing downstream packages should not break. Newly built packages will only recieve exports of the numbered shared libraries. (I believe cairo-trace is a dev package that does not need to be exported).

@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I was trying to look for recipes to lint for you, but it appears we have a merge conflict.
Please try to merge or rebase with the base branch to resolve this conflict.

Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.

@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

I do have some suggestions for making it better though...

For recipe:

  • It looks like the '_libcairo_api' output doesn't have any tests.

@carterbox
Copy link
Member Author

@conda-forge-admin, please rerender

@carterbox carterbox marked this pull request as ready for review April 4, 2024 20:57
@xhochy
Copy link
Member

xhochy commented Apr 16, 2024

@conda-forge-admin please restart ci

recipe/meta.yaml Outdated Show resolved Hide resolved
- pkg-config --cflags cairo-gobject

# Only what's needed for run_exports downstream
- name: libcairo{{ so_name_major }}
Copy link
Member

Choose a reason for hiding this comment

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

If it isn't co-installable, why include the major version in the name?

Copy link
Member Author

@carterbox carterbox Apr 17, 2024

Choose a reason for hiding this comment

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

I assume you are referring to the Windows build variant because the unix packages would be coinstallable with other ABI major version.

The reason is to keep consistency between Windows and Unix package names.

@@ -0,0 +1,167 @@
# This is free and unencumbered software released into the public domain.
Copy link
Member

Choose a reason for hiding this comment

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

You have used this probably before/somewhere else? I'm a bit confused we need such a lengthy script. In most other cases, I either installed the shared libraries explicitly or had a script which deletes some files from the PREFIX again and then uses conda-build's host deduplication.

Copy link
Member Author

Choose a reason for hiding this comment

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

You have used this probably before/somewhere else? I'm a bit confused we need such a lengthy script.

Yes. The length is because I want to use this same script in multiple feedstocks without changing it too much, so it needs to be generic (long).

In most other cases, I either installed the shared libraries explicitly or had a script which deletes some files from the PREFIX again and then uses conda-build's host deduplication.

Could you please explain better the approach you are describing here? I don't see how deleting files from the prefix is helpful for package splitting.

Copy link
Member

Choose a reason for hiding this comment

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

See the script in https://github.com/conda-forge/glib-feedstock/blob/2896c82bbbe09c898d3d1bd9f5668bfb22571b00/recipe/install.sh#L1 There we install everything as usual and remove afterwards the files that should not go into the respective output.

Copy link
Member Author

@carterbox carterbox Apr 29, 2024

Choose a reason for hiding this comment

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

This is an interesting approach which we can call split-by-subtraction. It is the opposite of my approach which is split-by-addition. split-by-subtraction relies on a behavior of conda-build that the state of PREFIX is reset between generating each output (i.e. that the files which have been deleted are restored). The advantage is that hardcoded PREFIX paths in the installed artifacts do not need patching because they are installed directly to the PREFIX instead of to a staging area as in split-by-addition. I could modify my install script to use split-by-subtraction instead since the main purpose of my script is to enable easy splitting of the artifacts using glob.

However, this restoration behavior between generating each output is undocumented, so relying on it as the primary package splitting method is (in my opinion) not a good idea because it could break at any time without warning. In fact, the only documented methods are pattern matching via glob and moving files into the prefix (split-by-addition).

I have an open PR to improve the glob (pattern matching) functionality in conda-build which will make both split-by-subtraction and split-by-addition obsolete, so I can refactor this PR to use that feature if/when it is merged and released.

Copy link
Member

Choose a reason for hiding this comment

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

split-by-subtraction relies on a behavior of conda-build that the state of PREFIX is reset between generating each output (i.e. that the files which have been deleted are restored).

However, this restoration behavior between generating each output is undocumented

The behaviour is clearly documented. Each output has its own set of host and build dependencies and thus gets its own environments during the build. We also never delete any files during a build phase that we have no copied into the PREFIX some lines above in the build script.

Copy link
Member Author

Choose a reason for hiding this comment

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

My mistake, I misread the glib install scripts. I thought that meson install was called inside build.sh, but that is not the case.

I was thinking this:

build.sh : build everything; install everything
install.sh : for each output, depending on the package name, remove things

but it's actually this:

build.sh : build everything; no installing
install.sh : for each output, install everything, then depending on the package name, remove things

I'll have to think about how to adapt this approach to make it more generic.

Co-authored-by: Uwe L. Korn <xhochy@users.noreply.github.com>
@carterbox carterbox marked this pull request as draft April 30, 2024 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants