1

conda build supports a variety of methods for importing source to be used in the build, as outlined here. Is there a way to import source from a local archive file (.zip,.tar.gz, etc.)? I have attempted to specify the location of the archive file using the path: option that is used to point at local source; however, the archive file is moved into the build work directory without being unziped. I can obviously explicitly unpack the archive; however, this requires me to specify the file name explicitly in the build file which is not desirable for a number of reasons. Is there a way to import source from a local archive file and have it automatically unpacked to the work directory as is done for files imported via url and fn specification?

mcguip
  • 5,947
  • 5
  • 25
  • 32

2 Answers2

2

You can try using the file:// protocol in the url field:

source:
   url: file:///home/src/mypkgsrc.tar.bz2

On Windows, one can try:

source:
   url: file://C:\path\to\mypkgsrc.tar.bz2
Nehal J Wani
  • 16,071
  • 3
  • 64
  • 89
  • This approach will attempt to resolve a relative path from the build dirctory to the file, not an absolute path. Given my file path can't be resolved, I can't confirm the source would be unpacked even if the file were located. – mcguip Nov 05 '18 at 07:39
  • No, it will resolve the absolute path. It is `file://` and then followed by the absolute path. Please try it before downvoting the answer. – Nehal J Wani Nov 05 '18 at 11:04
  • I did try this and it resolved the relative path, not the absolute hence my down vote – mcguip Nov 10 '18 at 23:43
  • `/home/src/mypkgsrc.tar.bz2` is an absolute path though? Also, one can specify multiple urls too. – Nehal J Wani Nov 11 '18 at 05:18
  • I just test this on linux as opposed to my earlier attempt on windows and found it successful. I'd happily upvote if you edit the answer as my vote is currently locked. – mcguip Nov 14 '18 at 10:44
  • Updated the answer. – Nehal J Wani Nov 14 '18 at 14:13
1

Expanding on the previous answer, the file:// URL has to be absolute, but you can use jinja2 variables to fix that. For instance, if you can find the file relative to the recipe directory you can write something like:

source:
    url: file://{{RECIPE_DIR}}/../src/mypkgsrc.tar.bz2
Christopher Barber
  • 2,548
  • 1
  • 22
  • 23