pfultz2 / cget

C++ package retrieval
http://cget.readthedocs.io
Other
453 stars 27 forks source link

build command on non-local source always fail #37

Open nedforge opened 7 years ago

nedforge commented 7 years ago

Running v0.1.2 (the pip version at the time of writing) on Windows 10.

I'd like to fetch and run cmake-gui on a simple CMake-based project, like the one below. However, the following command fails:

> cget build -c https://github.com/ruslo/sugar
Unexpected error: <class 'TypeError'>

Failed to build package https://github.com/ruslo/sugar

It seems that not only the github sources, but every non-local sources will result in failing.

pfultz2 commented 7 years ago

Interesting, I've never thought of a use case for non-local sources for the build command, so I have never tested. Let me look into fixing this. However, for it to work even after a fix you will need to give a correct url, like cget build -c https://github.com/ruslo/sugar/archive/master.tar.gz or cget build -c ruslo/sugar

pfultz2 commented 7 years ago

Looking at this more, I am not sure exactly how this will work, as there needs to be a local source directory for cmake. On the install command, it creates a temporary directory to copy the source directory from remote urls, and then it deletes the temporary directory after install finishes. The build command could do the same thing, but it seems very inefficient, as it will download a new source every time. It seems better to just do:

git clone https://github.com/ruslo/sugar
cget build -c sugar

Is there a reason this is not useful for your use case?

nedforge commented 7 years ago

The particular use case that is close to mine is following:

  1. I want to fetch and cmake-gui some package P.
  2. P has lots of dependencies and It is described by an external recipe R.
  3. I want cget to handle the dependencies as well as running the CMake.

If R directs to the local source then it will have no issues, but it does not make much sense. Then one needs to manually fetch the repo of P, then copy requirements.txt from R to the repo, and then build it via cget. This is a bit cumbersome, and moreover, resulting in modifying the repo itself. So it would be handy to avoid such situation.

As a suggestion, I think there should be some options to leave intermediate files anyway for both install and build commands, since it's quite often the case that one needs to review which CMake options have been applied to each dependent package, e.g. finding collision of std. library versions. Once that option becomes available, leaving them for the remote source can be easily done, I guess.

pfultz2 commented 7 years ago

The particular use case that is close to mine is following:

I want to fetch and cmake-gui some package P.
P has lots of dependencies and It is described by an external recipe R.
I want cget to handle the dependencies as well as running the CMake.

That makes a lot of sense. So instead of having cget build take a non-local source directory, instead an extra flag(such as --from or --fetch) could be given to fetch the sources and then they will be stored in the source directory set by cget build, something like this:

cget build -c . --fetch ruslo/sugar@master

Of course, this doesn't fetch the git repository as cget doesn't ever use git. Alternatively, I could add a flag to install that will just install the dependencies of a recipe rather than installing the recipes. So you could clone the repo and install the dependencies from the external recipe.

nedforge commented 7 years ago

Either way would work.

pfultz2 commented 7 years ago

So I added the --fetch flag on the fetch branch already. Right now, there seems to be a problem with long names on windows, so I haven't merged it in yet.