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

Fix jbuilder support without opam #179

Closed
wants to merge 3 commits into from
Closed

Conversation

bobot
Copy link
Collaborator

@bobot bobot commented Jul 5, 2017

Doesn't change that opam-installer must be available.

Should fix #174 by:

  • considering that an opam failing is an opam not present
  • use the option libdir of opam-installer for the case where libraries should not be installed in $PREFIX/lib

libdir is:

  1. the argument given on the command line of jbuilder install
  2. ocamlfind printconf destdir
  3. opam config lib
  4. OCaml standard library path.

@bobot
Copy link
Collaborator Author

bobot commented Jul 6, 2017

Could we add 4.05 to the CI matrix?

@dra27
Copy link
Member

dra27 commented Jul 6, 2017

It's on my todo list for later!

@dra27
Copy link
Member

dra27 commented Jul 6, 2017

https://github.com/dra27/jbuilder/tree/ci-4.05 - but in order to test with --dev, I presently have to do something which Jeremie has already rejected (altering the opam file). I'll see if I can find time to replace the entire script (there's no need to use opam at all for the CI)

@dra27 dra27 mentioned this pull request Jul 6, 2017
bin/main.ml Outdated
let get_libdir context ~from_command_line =
match from_command_line with
| Some p -> Future.return (Path.of_string p)
| None -> Context.install_ocaml_libdir context
Copy link

Choose a reason for hiding this comment

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

I think the default for --libdir should be $prefix/lib. This is what opam-installer does. Otherwise, if you call jbuilder install --prefix ..., it might install library files at a completely different location

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When is Context.install_ocaml_libdir used? I propose:

  1. use --libdir if present
  2. use --prefix if present with $prefix/lib
  3. use Context.install_ocaml_libdir

Copy link

Choose a reason for hiding this comment

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

Seems good to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, rebased and squashed

| Some s -> Path.absolute s
| None ->
(* If neither opam neither ocamlfind are present use stdlib dir *)
t.stdlib_dir
Copy link

Choose a reason for hiding this comment

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

I think it's a bit surprising that for the search path, jbuilder falls back to $(which ocamlc)/../../lib and for installation it falls back to $(ocamlc -where). I don't claim that I made the right choice for the search path, happy to change it if the current default is wrong, but I think the two should be consistent

Copy link
Collaborator Author

@bobot bobot Jul 18, 2017

Choose a reason for hiding this comment

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

Previously people used a lot -I +lib, and it is the place that debian use. As a side note in many tools the default installation prefix is /usr/local and not /usr .

Copy link

Choose a reason for hiding this comment

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

Ok. opam-installer uses /usr/local as default

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

opam-installer uses /usr/local as default

Do you want jbuilder to use this default?

Copy link

Choose a reason for hiding this comment

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

Not really, the current default is where OCaml is installed which seems fine to me, especially if we install the library files in the stdlib directory

else
return []
in
findlib_path >>= fun findlib_path ->
Copy link

Choose a reason for hiding this comment

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

Why did you move this bit? It is now run after ocamlc -config instead of in parallel with it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I need the value of stdlib_dir.

Copy link

Choose a reason for hiding this comment

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

Ah, indeed

doc/usage.rst Outdated
@@ -248,17 +248,27 @@ to be able to use ``jbuilder install``.
Destination
-----------

The place where the build artifacts are copied, usually referred as
The place where the build artifacts (except ocaml libraries) are copied, usually referred as
Copy link

Choose a reason for hiding this comment

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

s/ocaml libraries/library files/, we usually copy other stuff as well, such as binaries (ppx, ...)

doc/usage.rst Outdated
``/usr``
#. otherwise, take the parent of the directory where ``ocamlc`` was found.

The ocaml libraries build artifacts are copied, referred as
Copy link

Choose a reason for hiding this comment

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

place word missing. Same remark about ocaml libraries

doc/usage.rst Outdated
The ocaml libraries build artifacts are copied, referred as
**libdir**, is determined as follow for a given build context:

#. if an explicit ``--libdir <path>`` argument is passed, use this path
Copy link

Choose a reason for hiding this comment

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

Missing point about --prefix <path>

| Some s -> Path.absolute s
| None ->
(* If neither opam neither ocamlfind are present use stdlib dir *)
t.stdlib_dir
Copy link

Choose a reason for hiding this comment

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

Ok. opam-installer uses /usr/local as default

@ghost
Copy link

ghost commented Jul 19, 2017

BTW, why not simply call opam-installer with the right options? Unless you are installing for multiple workspaces simultaneously, in which case you need opam, jbuilder install just makes a simple call to opam-installer.

That would avoid adding more ad-hoc rules to jbuilder and relying even more on ocamlfind.

@bobot
Copy link
Collaborator Author

bobot commented Jul 19, 2017

BTW, why not simply call opam-installer with the right options?

What are the right options? opam-installer doesn't use ocamlfind or ocamlc -where by itself.

--libdir=PATH
           OCaml lib dir. Relative to prefix or absolute. By default $prefix/lib ; sometimes setting
           this to $(ocamlc -where) is preferable.

By default opam-installer is not installing things at the right place. Perhaps I could propose to modify opam-installer instead of jbuilder but the second could already use informations from ocamlfind, the first doesn't.

@ghost
Copy link

ghost commented Jul 19, 2017

I imagine that it would be:

$ opam-installer --libdir $(ocamlfind printconf destdir) foo.install

@bobot
Copy link
Collaborator Author

bobot commented Jul 19, 2017

Oh I see perhaps better what you mean. You are proposing that jbuilder install be removed and people use directly opam-installer? But they will have to handle all the case themselves no?

@ghost
Copy link

ghost commented Jul 19, 2017

I'm not proposing to remove it, I think it's fine in its current state. I'm just saying that if you want more control, you can simply use opam-installer directly and set the parameters that suit your configuration.

@bobot
Copy link
Collaborator Author

bobot commented Jul 20, 2017

I'm just saying that if you want more control, you can simply use opam-installer directly and set the parameters that suit your configuration.

I was not clear with the problem I tried to fix in this MR. My problem is to install other people library that use jbuilder in a context without opam (example ocaml is installed using debian packages).

For example the findlib package of debian already has all the interesting configuration /etc/ocamlfind.conf:

destdir="/usr/local/lib/ocaml/4.02.3"
path="/usr/local/lib/ocaml/4.02.3:/usr/lib/ocaml:/usr/lib/ocaml/METAS"

Is the installation in such setting not something that library developers want out-of-the-box?

@ghost
Copy link

ghost commented Jul 20, 2017

I suppose.

Many people want to get rid of ocamlfind, the idea being that once we have namespaces we don't need ocamlfind and especially findlib names anymore. So I'm a bit reluctant to rely more on ocamlfind.

For installation, given that we already require an external tool, it doesn't seem too bad to me to just use an external tool altogether. We could have a separate tool to handle installation for non-opam setups.

@bobot
Copy link
Collaborator Author

bobot commented Jul 20, 2017

the idea being that once we have namespaces we don't need ocamlfind and especially findlib names anymore.

It is simpler when the distribution could indicate where to install things in an uniform way instead for each project to guess for each distribution where to install things. We still generally need to know where to install things, of course in the namespace proposal ocamlc -config could indicate it, but it is not yet the case (lpw25/namespaces#5).

So I'm a bit reluctant to rely more on ocamlfind.

This PR just use it if it is present, I think it doesn't rely on it.

@ghost
Copy link

ghost commented Jul 21, 2017

Ok, I suppose this PR only uses ocamlfind if it's present in the PATH and in this case we can assume that it reflects the user setup. I'll read this one more time but I think I'm OK with it in the end.

@ghost
Copy link

ghost commented Jul 25, 2017

Ok, I merged this by hand and did some minor changes. I changed the rules so that we use ocamlfind printconf destdir if ocamlfind is available but we don't have a completely different set of rules for library files. I find it simpler to document and remember

This pull request was closed.
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.

opam not initialized
2 participants