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

Allow packages with no build commands #355

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

gridbugs
Copy link
Collaborator

If a package has no build commands, chances are that it's a metapackage which exists just so that its dependencies can be installed.

Signed-off-by: Stephen Sherratt stephen@sherra.tt

Copy link
Member

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

It's a useful change, it sounds like packages that don't need to be "built" can be safely included into the duniverse.

Could you add a test with a package that has no build instructions?

@@ -95,11 +95,12 @@ module Opam_monorepo_context (Base_context : BASE_CONTEXT) :
Opam.depends_on_dune ~allow_jbuilder depends
|| Opam.depends_on_dune ~allow_jbuilder depopts
in
let has_no_build_command = List.is_empty (OpamFile.OPAM.build opam_file) in
let summary = Opam.Package_summary.from_opam pkg opam_file in
let is_valid_dune_wise =
Opam.Package_summary.is_base_package summary
|| Opam.Package_summary.is_virtual summary
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering, wouldn't it make sense to add this to is_virtual? Or a new category in Opam.Package_summary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered that and conceptually it would make sense for packages without build commands to be considered "virtual". We could add a new field to Package_summary.t:

build : OpamTypes.command list

The problem is that in order to update Package_summary.equal and Package_summary.pp we'd need to implement equality and pretty-printing for OpamTypes.command and it looks like that would add a lot of code.

However, it appears that neither Package_summary.equal nor 'Package_summary.pp' are ever called, so perhaps they can just be deleted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've updated this PR so that the check is now done inside is_virtual

@gridbugs gridbugs mentioned this pull request Nov 24, 2022
@gridbugs gridbugs force-pushed the allow-metapackages branch 3 times, most recently from a59e6b9 to c8ced2a Compare November 25, 2022 04:11
Copy link
Member

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

Looks very good! Just make the code a bit less brittle and then this is ready to merge 🚢

depend-without-dune (this should fail due to the transitive dependency on
without-dune which has a build command but doesn't depend on dune)

$ opam-monorepo lock test-depend-without-dune.opam
Copy link
Member

@Leonidas-from-XIV Leonidas-from-XIV Nov 25, 2022

Choose a reason for hiding this comment

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

Can you please filter the output? Either with some grep trickery (which is admittedly quite annoying) or just by throwing the output away, as long as the [1] matches the test is passing. :)

All the text would make the output quite fragile if versions change or the wording changes slightly.

@gridbugs gridbugs force-pushed the allow-metapackages branch 2 times, most recently from 3ef4fd5 to 16b2793 Compare November 29, 2022 12:19
Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
Copy link
Member

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

Nice, it's ready to go. Thanks for the PR!

@gridbugs gridbugs merged commit 0a5c5ce into tarides:main Dec 1, 2022
Leonidas-from-XIV added a commit to Leonidas-from-XIV/opam-repository that referenced this pull request Dec 21, 2022
CHANGES:

### Changed

- Treat packages with no build commands as if they can be built with dune (tarides/opam-monorepo#355,
  @gridbugs)

### Fixed

- Fix resolving refs of locally pinned repositories (tarides/opam-monorepo#326, tarides/opam-monorepo#332, @hannesm,
  @Leonidas-from-XIV)
- Read the `compiler` flag from OPAM metadata thus classifying more packages
  correctly as base packages (tarides/opam-monorepo#328, @Leonidas-from-XIV)
- Fix bug where dev repo urls ending with a "/" would result in
  `opam monorepo pull` placing package source code directly inside the duniverse
  directory instead of in a subdirectory of the duniverse directory (tarides/opam-monorepo#359,
  @gridbugs)
Leonidas-from-XIV added a commit to Leonidas-from-XIV/mirage that referenced this pull request Dec 22, 2022
In tarides/opam-monorepo#355 opam-monorepo
marked packages without build instructions as virtual (e.g. packages
that are conf-packages, dependency-only packages, etc).

This requires that the dummy OPAM files used here also have `build`
stanzas, otherwise they are considered virtual and skipped.
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.

2 participants