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

Platform specific configuration #43

Closed
baszalmstra opened this issue Jun 1, 2023 · 4 comments · Fixed by #111
Closed

Platform specific configuration #43

baszalmstra opened this issue Jun 1, 2023 · 4 comments · Fixed by #111
Assignees

Comments

@baszalmstra
Copy link
Contributor

baszalmstra commented Jun 1, 2023

Multi-platform packages will require the need to have platform-specific dependencies or configurations.

Cargo supports this through the [target] section.

How to format them in TOML?

[dependencies]
bla = "3.1.*"
windows_specific = { version = "3.1.*", only_windows = true }

or cargos approach:

[dependencies]
bla = "3.1.*"

[target.'sel(win)'.dependencies]
windows_specific = "3.1"

I like the latter the most because its clearer that this is an exception that only applies in a certain scenario.

Selectors or platforms?

Cargo uses the cfg(..) syntax in its selectors. I think this is pretty cool because it allows you to do more complex things like selecting for two platforms or for specific architectures (arm vs x86).

We could also simplify things a little bit and only use platform names as selectors e.g. osx-arm64 vs sel(osx). Cargo also supports specifying the target directly.

I would opt to go for the full selector experience because it provides a lot of flexibility.

Todo

  • Figure out our approach
  • Implement it
@baszalmstra baszalmstra added this to the Add the multi platform magic milestone Jun 2, 2023
@baszalmstra
Copy link
Contributor Author

In light of the recent work on conda/ceps#54 maybe we can adopt a similar style if statement.

[dependencies]
bla = { matchspec = "3.1.*", if = "win or osx" }

@wolfv
Copy link
Member

wolfv commented Jun 15, 2023

I think I like this. It would only work for single dependencies, though. Should we come up with something for a list?

@baszalmstra
Copy link
Contributor Author

Ah this method:

[dependencies]
bla = { matchspec = "3.1.*", if = "win or osx" }

falls apart if you would want to have different matchspecs based on the os:

[dependencies]
bla = { matchspec = "3.1.*", if = "win" }
bla = { matchspec = "4.1.*", if = "osx" }

The key bla is defined twice which is illegal.

However, using the cargo method this is possible:

[target.'if(win)'.dependencies]
bla = "3.1.*"

[target.'if(osx)'.dependencies]
bla = "4.1.*"

Alternatively, we could also accept minijinja syntax in the dependencies list but it makes parsing a lot harder (because we have to post-process the expressions:

[dependencies]
bla = '${{ "3.1.*" if win else "4.1.*" }}'

its also a bit weird with the to types of quotes..

@baszalmstra
Copy link
Contributor Author

Target specific dependencies have been implemented in:

With that you can provide per platform specific dependencies but you cannot easily add a dependency for an architecture or os.

We could add a simple expression language to do that. E.g. target.if(os == win).dependencies or target.'if(os != win)'.dependencies. WDYT @tdejager ?

@baszalmstra baszalmstra changed the title [Tracking] Platform specific configuration Platform specific configuration Jun 19, 2023
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 a pull request may close this issue.

3 participants