constructor
constructor copied to clipboard
Local channels are not always properly recognized
I came across an unexpected behavior when defining local conda channels in Windows.
At the beginning I was not sure how to define a local conda channel in a yaml configuration file. Reason behind this is that you find many outdated resources online pointing at different ways to define the channel. For example:
-
file://Z:/condachannel
(https://zegami.com/blog/conda-constructor-tutorial-make-your-python-code-easy-to-install-cross-platform/) -
file://\condachannel
(https://stackoverflow.com/questions/36406584/conda-custom-channel-on-windows) -
file://Z:\condachannel
(https://stackoverflow.com/questions/36406584/conda-custom-channel-on-windows) - many other combinations with backslash/forwardslash, colon, file:// or file:///, missing drive letter and so on. All of those ended up giving me :
raise UnavailableInvalidChannel(Channel(dirname(url)), status_code)
conda.exceptions.UnavailableInvalidChannel: The channel is not accessible or is invalid.
channel name: condachannel
channel url: file://z:/condachannel
error code: 404
This confusion was not helped by neither conda and conda constructor documentation as they don't have an example for Windows (for example https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/create-custom-channels.html).
Also, intuitively I feel like it should be file://
+ conda_channel_path
, where in linux it would be file://
+ /path/to/conda/channel
(hence the triple forward slash).
At the end guided by this I tried simply z:/condachannel
, and finally conda constructor managed to build the installer.
However, when I tried to install it in another machine I got again the 404 error during installation!
Long story short I finally tried:
from conda.common.url import path_to_url
path_to_url( 'Z://condachannel' )
that returned file:///Z:/condachannel
, run again constructor and this time I got WARNING: local channel file:///Z:/condachannel does not have a remap. It will not be included in the installer
and an installer that also works on other machines
So, the issue I'm pointing out is that both z:/condachannel
and file:///Z:/condachannel
will successfully use the local conda channel at build time, but only the second option is properly captured by the rest of the workflow.
If this is not the expected behavior, maybe even just documenting the Windows case would help avoiding the problem
I think local channels need to be remapped so the installer "finds" the fake channel metadata during the solve. This needs to be better documented, though. Thanks for the report!