alavrik / piqi

Piqi – universal schema language: JSON, XML, Protocol Buffers data validation and conversion
http://piqi.org
Apache License 2.0
246 stars 36 forks source link

piqi ocamlfind failure in getting the deps #25

Closed motiejus closed 11 years ago

motiejus commented 11 years ago

Hi,

I can successfully build piqi from opam, but not the bare repository. Here are the experiments I executed in command-line.

[1] motiejus@precise> dpkg -l ocaml camlp4-extra ocaml-findlib gcc make sed
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Vardas                               Versija                              Aprašymas
+++-====================================-====================================-========================================================================================
ii  camlp4-extra                         3.12.1-2ubuntu2                      Pre Processor Pretty Printer for OCaml - extras
ii  gcc                                  4:4.6.3-1ubuntu5                     GNU C compiler
ii  make                                 3.81-8.1ubuntu1.1                    An utility for Directing compilation.
ii  ocaml                                3.12.1-2ubuntu2                      ML language implementation with a class-based object system
ii  ocaml-findlib                        1.2.7+debian-1build3                 management tool for OCaml libraries
ii  sed                                  4.2.1-9                              The GNU sed stream editor
motiejus@precise> ./configure
checking whether necessary dependencies are already installed...
xmlm is not installed; it will be built during "make deps"
ulex is not installed; it will be built during "make deps"
easy-format is not installed; it will be built during "make deps"
motiejus@precise> make deps
mkdir -p /home/motiejus/code/stuff/piqi/build/lib/ocaml
make -C deps
make[1]: Entering directory `/home/motiejus/code/stuff/piqi/deps'
set -e; \
        for dir in ulex-1.1 xmlm-1.1.1 easy-format-1.0.0; do \
                make -C $dir ; \
        done
make[2]: Entering directory `/home/motiejus/code/stuff/piqi/deps/ulex-1.1'
ocamlbuild -byte-plugin pa_ulex.cma ulexing.cma
Finished, 1 target (0 cached) in 00:00:00.
Finished, 18 targets (0 cached) in 00:00:01.
ocamlbuild -byte-plugin pa_ulex.cma ulexing.cma pa_ulex.cmxa ulexing.cmxa
Finished, 0 targets (0 cached) in 00:00:00.
Finished, 25 targets (18 cached) in 00:00:01.
make[2]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/ulex-1.1'
make[2]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
ocamldep xmlm.mli > ._bcdi/xmlm.di
ocamldep xmlm.ml > ._d/xmlm.d
make[3]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
ocamlc -c xmlm.mli
ocamlc -c xmlm.ml
ocamlc -a                -o xmlm.cma xmlm.cmo
make[3]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
ocamldep -native xmlm.mli > ._ncdi/xmlm.di
make[3]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
ocamlopt -c xmlm.ml
ocamlopt -a                -o xmlm.cmxa xmlm.cmx
make[3]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[2]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[2]: Entering directory `/home/motiejus/code/stuff/piqi/deps/easy-format-1.0.0'
ocamlc -c easy_format.mli
ocamlc -c -dtypes easy_format.ml
touch bytecode
ocamlc -c easy_format.mli
ocamlopt -c -dtypes easy_format.ml
touch nativecode
make[2]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/easy-format-1.0.0'
make[1]: Leaving directory `/home/motiejus/code/stuff/piqi/deps'
make -C deps install
make[1]: Entering directory `/home/motiejus/code/stuff/piqi/deps'
set -e; \
        for dir in ulex-1.1 xmlm-1.1.1 easy-format-1.0.0; do \
                make -C $dir install; \
        done
make[2]: Entering directory `/home/motiejus/code/stuff/piqi/deps/ulex-1.1'
ocamlbuild -byte-plugin pa_ulex.cma ulexing.cma
Finished, 0 targets (0 cached) in 00:00:00.
Finished, 18 targets (18 cached) in 00:00:00.
cd _build && make -f ../Makefile realinstall
make[3]: Entering directory `/home/motiejus/code/stuff/piqi/deps/ulex-1.1/_build'
ocamlfind install ulex ../META ulexing.mli utf8.mli ulexing.cmi utf8.cmi ulexing.cmx utf8.cmx pa_ulex.cma ulexing.a ulexing.cma ulexing.cmxa
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/ulexing.cmxa
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/ulexing.cma
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/ulexing.a
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/pa_ulex.cma
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/utf8.cmx
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/ulexing.cmx
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/utf8.cmi
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/ulexing.cmi
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/utf8.mli
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/ulexing.mli
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/ulex/META
make[3]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/ulex-1.1/_build'
make[2]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/ulex-1.1'
make[2]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: `xmlm.cma' is up to date.
make[3]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: Entering directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[3]: `xmlm.cmxa' is up to date.
make[3]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'

Installing library with ocamlfind
ocamlfind install  xmlm META xmlm.mli xmlm.cmi xmlm.cma xmlm.cmxa xmlm.a
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/xmlm/xmlm.a
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/xmlm/xmlm.cmxa
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/xmlm/xmlm.cma
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/xmlm/xmlm.cmi
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/xmlm/xmlm.mli
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/xmlm/META

Installation successful.
make[2]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/xmlm-1.1.1'
make[2]: Entering directory `/home/motiejus/code/stuff/piqi/deps/easy-format-1.0.0'
echo "version = \"1.0.0\"" > META; cat META.tpl >> META
INSTALL_FILES="META easy_format.cmi easy_format.mli"; \
                if test -f bytecode; then \
                  INSTALL_FILES="$INSTALL_FILES easy_format.cmo "; \
                fi; \
                if test -f nativecode; then \
                  INSTALL_FILES="$INSTALL_FILES easy_format.cmx easy_format.o"; \
                fi; \
                ocamlfind install easy-format $INSTALL_FILES
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/easy-format/easy_format.o
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/easy-format/easy_format.cmx
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/easy-format/easy_format.cmo
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/easy-format/easy_format.mli
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/easy-format/easy_format.cmi
Installed /home/motiejus/code/stuff/piqi/build/lib/ocaml/easy-format/META
make[2]: Leaving directory `/home/motiejus/code/stuff/piqi/deps/easy-format-1.0.0'
make[1]: Leaving directory `/home/motiejus/code/stuff/piqi/deps'
motiejus@precise> ./configure
checking whether necessary dependencies are already installed...
xmlm is not installed; it will be built during "make deps"
ulex is not installed; it will be built during "make deps"
easy-format is not installed; it will be built during "make deps"
motiejus@precise> echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/motiejus/stuff/env/bin:/home/motiejus/.gems/bin
motiejus@precise> . ./setenv.sh
motiejus@precise> ./configure
checking whether necessary dependencies are already installed...
xmlm is not installed; it will be built during "make deps"
ulex is not installed; it will be built during "make deps"
easy-format is not installed; it will be built during "make deps"
motiejus@precise> echo $PATH
/home/motiejus/code/stuff/piqi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/motiejus/stuff/env/bin:/home/motiejus/.gems/bin
motiejus@precise> git describe --tags
v0.6.2-dev-1-g4d98c35

Seems like ocamlfind cannot find dependencies.. Let's see:

motiejus@precise> ls deps/xmlm-1.1.1
CHANGES  Makefile  META  README  xmlm.a  xmlm.cma  xmlm.cmi  xmlm.cmo  xmlm.cmx  xmlm.cmxa  xmlm.ml  xmlm.mli  xmlm.o
motiejus@precise> ocamlfind query xmlm
ocamlfind: Package `xmlm' not found
[2] motiejus@precise> ocamlfind query xmlm deps
ocamlfind: Package `xmlm' not found
[2] motiejus@precise> ocamlfind query xmlm deps/xmlm
ocamlfind: Package `xmlm' not found
[2] motiejus@precise> ocamlfind query xmlm deps/xmlm/
ocamlfind: Package `xmlm' not found

.. And I don't know where to go from here.

alavrik commented 11 years ago

Have you actually tried running make after make deps?

Things that you posted are normal, because make deps installs dependencies locally. make should pick them up from ./deps, not from system-wide location.

$ OCAMLPATH=build/lib/ocaml ocamlfind query xmlm
build/lib/ocaml/xmlm
motiejus commented 11 years ago

OK, now I get it. make deps actually searches these dependencies system-wide and tries to use them if they are available... And this is not an error.

Given that dependencies are bundled with ocaml, why is it searching for global deps?

For instance, if I install libxmlm-ocaml-dev in Ubuntu 12.04 and try to compile piqi, it will fail, because libxmlm-ocaml-dev in standard repos is version 1.0.2, which is incompatible (it does not have ?decl:bool argument in Xmlm.make_output).

If there is no plan to decouple dependencies, I would think it makes sense to always use the local dependencies. Or is there such plan for the future?

alavrik commented 11 years ago

./configure is searching for globally installed dependencies, because OCaml users may have them installed already. These days, a typical OCaml user would likely use opam for managing dependencies rather than relying on system package manager.

For the purpose of packaging Piqi, I would definitely not use system-level dependencies like libxmlm-ocaml-dev and even dependencies installed by opam. To ignore them, you can run OCAMLPATH= ./configure; OCAMLPATH= make deps all from the packaging scripts. It will force the build scripts to pick up dependencies from ./deps.

motiejus commented 11 years ago

Thanks for clarifications, for now it is good enough for me. I am closing the ticket.

Still, using system-wide deps raises another question, probably better discussed with a pint of beer.