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

Adds rattler-build recipe compatibility (and adds jolt-physics) #27008

Merged
merged 14 commits into from
Jul 30, 2024

Conversation

baszalmstra
Copy link
Member

@baszalmstra baszalmstra commented Jul 16, 2024

WIP: This PR is a testbed to test support for rattler-build.

Checklist

  • Title of this PR is meaningful: e.g. "Adding my_nifty_package", not "updated meta.yaml".
  • License file is packaged (see here for an example).
  • Source is from official source.
  • Package does not vendor other packages. (If a package uses the source of another package, they should be separate packages or the licenses of all packages need to be packaged).
  • If static libraries are linked in, the license of the static library is packaged.
  • Package does not ship static libraries. If static libraries are needed, follow CFEP-18.
  • Build number is 0.
  • A tarball (url) rather than a repo (e.g. git_url) is used in your recipe (see here for more details).
  • GitHub users listed in the maintainer section have posted a comment confirming they are willing to be listed there.
  • When in trouble, please check our knowledge base documentation before pinging a team.

@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 couldn't find any.
Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.

Copy link

Hi! Thanks for your contribution to conda-forge.
We appreciate your effort in improving our project.
However, it looks like some changes were made outside the recipes directory.
To ensure everything runs smoothly, please make sure that recipes are only added to the recipes folder and no other files are changed.
Please make sure that any changes are reverted before you submit your pull request for review.

If these changes are intentional (and you aren't submitting a recipe), please attach a maintenance label to the PR.
Thanks!

@baszalmstra baszalmstra force-pushed the jolt-physics branch 3 times, most recently from 90c1d13 to 93640c6 Compare July 16, 2024 14:29
azure-pipelines.yml Outdated Show resolved Hide resolved
@baszalmstra baszalmstra force-pushed the jolt-physics branch 6 times, most recently from 8f87e11 to 7a8c1d7 Compare July 18, 2024 08:04
.ci_support/build_all.py Outdated Show resolved Hide resolved
found_cuda = False
found_centos7 = False
for folder in folders:
meta_yaml = os.path.join(recipes_dir, folder, "meta.yaml")
if os.path.exists(meta_yaml):
has_meta_yaml = True
with(open(meta_yaml, "r", encoding="utf-8")) as f:
text = ''.join(f.readlines())
if 'cuda' in text:
found_cuda = True
if 'sysroot_linux-64' in text:
Copy link
Member

Choose a reason for hiding this comment

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

This is going to get out of date very soon after stdlib('c').

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this something you want me to change?

Copy link
Member

Choose a reason for hiding this comment

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

No, no, don't worry. Just noticed it while reading, so flagged it for the curious readers. Not part of the scope of this PR!

.ci_support/build_all.py Outdated Show resolved Hide resolved
.ci_support/build_all.py Outdated Show resolved Hide resolved
@jaimergp
Copy link
Member

Also I found other workflows with references to meta.yaml that you might like to adjust for nicer UX / less confusion:

body: 'Hi! Thanks for your contribution to conda-forge.' +
'\nUnfortunately, the recipe was added directly in the `recipes` folder without its own subfolder.\n' +
'Please move the recipe file into a folder with the name of the package you want to submit.\n\n' +
'For example: if your recipe is currently under `recipes/<your_package>.yaml`, ' +
'it should be moved to `recipes/<your_package>/meta.yaml`.\n' +
'Thanks!'
})

This block below reminds me we might want an example file for recipe.yaml too:

- 'recipes/example/meta.yaml'

The "new PR template":

- [ ] License file is packaged (see [here](https://github.com/conda-forge/staged-recipes/blob/5eddbd7fc9d1502169089da06c3688d9759be978/recipes/example/meta.yaml#L64-L73) for an example).

@baszalmstra
Copy link
Member Author

Thanks for the early review @jaimergp ! Much appreciated!

The biggest issue I face atm is that rattler-build doesn't read the proper conda_build_config.yamls. This makes rattler-build not properly use the pinnings. (This is why the win-64 build is failing). I am contemplating either adding this to rattler-build or doing some magic in build_all.py. WDYT?

@jaimergp
Copy link
Member

jaimergp commented Jul 18, 2024

There are some elements to consider, but I'm not fully sure of how this works, so just a couple ideas:

  • conda-forge-ci-setup installs conda-forge-pinning in base. The CBC from conda-forge-pinning is placed in the root of $PREFIX.
  • This is then combined with the yaml files in .ci_support and, optionally, a recipe-adjacent CBC (e.g. recipes/<project>/conda_build_config.yaml).

The code is here:

def get_config(arch, channel_urls):
exclusive_config_files = [os.path.join(conda.base.context.context.root_prefix,
'conda_build_config.yaml')]
script_dir = os.path.dirname(os.path.realpath(__file__))
# since variant builds override recipe/conda_build_config.yaml, see
# https://github.com/conda/conda-build/blob/3.21.8/conda_build/variants.py#L175-L181
# we need to make sure not to use variant_configs here, otherwise
# staged-recipes PRs cannot override anything using the recipe-cbc.
exclusive_config_file = os.path.join(script_dir, '{}.yaml'.format(
get_config_name(arch)))
if os.path.exists(exclusive_config_file):
exclusive_config_files.append(exclusive_config_file)
config = conda_build.api.Config(
arch=arch, exclusive_config_files=exclusive_config_files,
channel_urls=channel_urls, error_overlinking=True,
)
return config

So you can either replicate that logic in rattler-build, or get ahold of get_config and render a temporary YAML you can pass as an argument? Not sure what's easier, tbh 😂

@jaimergp
Copy link
Member

I see two warnings in the macOS logs, maybe related to the SDK versions, deployment targets, etc etc.

During build:

 │ │ [139/140] Linking CXX shared library libJolt.dylib
 │ │ ld: warning: dylib ($PREFIX/lib/libc++.dylib) was built for newer macOS version (10.13) than being linked (10.9)

During analysis:

 │ │ ⚠ warning Overlinking against "/usr/lib/libSystem.B.dylib" for "lib/libJolt.dylib"

Not sure if they are related, or just noise, or whether important, but I thought I'd flag it in case there's a problem with how the CBCs are being loaded etc.

@jaimergp
Copy link
Member

Also, there's some funky slash dance in the artifact content listing on Windows, although I guess that's rattler-build specific, not the implementation in this setup.

 │ │   - info/about.json
 │ │   - info\hash_input.json
 │ │   - info/index.json
 │ │   - info/licenses/LICENSE
 │ │   - info/paths.json
 │ │   - info/recipe/recipe.yaml
 │ │   - info/recipe/rendered_recipe.yaml
 │ │   - info/recipe/variant_config.yaml
 │ │   - info/tests\tests.yaml

Comment on lines 1 to 9
from itertools import chain
import json
from shutil import rmtree
import tempfile
import conda.base.context
import conda.core.index
import conda.resolve
import conda_build.api
import conda_build.variants
Copy link
Member

Choose a reason for hiding this comment

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

This import block makes me wanna run isort. Maybe in another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I ran ruff format and isort..

Comment on lines +247 to +248
for example_recipe in EXAMPLE_RECIPE_FOLDERS:
rmtree(os.path.join(recipes_dir, example_recipe), ignore_errors=True)
Copy link
Member

Choose a reason for hiding this comment

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

This would become a problem locally if the user accidentally commits after debugging something, but I think we copy the staged-recipes folder before we start the script, so we are ok.

.ci_support/build_all.py Outdated Show resolved Hide resolved
# to rattler-build.
with tempfile.NamedTemporaryFile(delete=False) as fp:
fp.write(variant_config.encode('utf-8'))
fp.close()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fp.close()

No need; once you exit the context, it's done for you.

Copy link
Member Author

Choose a reason for hiding this comment

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

I close it because rattler-build will need to read it, but if the file is already open for writing it won't be able to open the file.


# Construct a temporary file where we write the combined variant config. We can then pass that
# to rattler-build.
with tempfile.NamedTemporaryFile(delete=False) as fp:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
with tempfile.NamedTemporaryFile(delete=False) as fp:
with tempfile.NamedTemporaryFile(delete=False) as fp:

Maybe we should register this with atexit so it's removed once done.

README.md Outdated Show resolved Hide resolved
Comment on lines 1 to 8
# This example shows how to define a recipe using the new YAML based recipe format introduced by
# CEP 13.

# For more information about this format see: https://prefix-dev.github.io/rattler-build/latest/reference/recipe_file/

# Note: there are many handy hints in comments in this example -- remove them when you've finalized your recipe

# Define variables in this section that you can use in other parts.
Copy link
Member

Choose a reason for hiding this comment

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

I think this block should also mention the main differences across formats. Namely:

  • No selectors, but if-then-else expressions (and link to docs)
  • Jinja uses ${{ }}

Comment on lines 37 to 39
# Add the line "skip: True # [py<35]" (for example) to limit to Python 3.5 and newer, or "skip: True # [not win]" to limit to Windows.
# More info about selectors can be found in the conda-build docs:
# https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#preprocessing-selectors
Copy link
Member

Choose a reason for hiding this comment

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

Update this block so it refers to the new syntax for selectors.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added information to the top block.

@baszalmstra baszalmstra changed the title Added jolt-physics Adds rattler-build recipe compatibility (and adds jolt-physics) Jul 30, 2024
.ci_support/build_all.py Outdated Show resolved Hide resolved
@wolfv wolfv merged commit 1573839 into conda-forge:main Jul 30, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants