What is the right way to programmatically check if a binstar channel has a package?

0 views
Skip to first unread message

Matt Craig

unread,
May 29, 2015, 4:22:37 PM5/29/15
to co...@continuum.io
Hi,

I'm building several conda packages and want to be able to check the channel to which the packages will be uploaded to see if the package already exists.

Right now I'm doing this with something like:

from binstar_client.scripts import cli
cli.main(args=['show','channel/package/version'])

and catching the NotFound error.

There seem to be a few problems with the approach, and I'm wondering if there is a better way.

The problems:

  1. I loop over the calls to `cli.main` and every iteration seems to increase the number of instances of `binstar show` that are running. So on the first iteration I get one check of the version, the second iteration (for the second package) I get the version report twice, for the third I get three, and so on.
  2. This doesn't allow one to check the platform without parsing the list of files returned by binstar show.
  3. This also doesn't allow one to check with version of numpy the package has been built against except by parsing the filenames.
Any suggestions appreciated!
Matt Craig





Bradley Kreider

unread,
May 29, 2015, 4:38:26 PM5/29/15
to co...@continuum.io, mattw...@gmail.com
Here is some rough code to get you started:

try:
   
from binstar_client import errors
   
from binstar_client.utils import get_binstar
except ImportError:
   
print "You need to install binstar"
    sys
.exit(1)

try:
    binstar
= get_binstar()
except errors.Unauthorized:
   
print "The action you are performing requires binstar authentication"
    sys
.exit(1)

all_wakari_server_packages
= binstar.package("wakari", "wakari-server")
latest_release
= binstar.release("wakari", "wakari-server", "1.7.0")

# next build number for linux
distributions
= latest_release["distributions"]
files
= [f["attrs"]["build_number"] for f in distributions
             
if f["attrs"]["platform"] == "linux"]

files
.sort()
next_build_number
= files[-1] + 1


Hope that helps,

Bradley Kreider

Matt Craig

unread,
May 29, 2015, 5:42:32 PM5/29/15
to co...@continuum.io, mattw...@gmail.com
Great, thanks!

Matt

Chris Barker

unread,
May 29, 2015, 11:38:45 PM5/29/15
to Matt Craig, conda
you might want to check out:

https://github.com/pelson/Obvious-CI/

while it was built for running on CI systems, it does a great job of managing a bunch of conda packages that you want set up on binstar --- even if you build them on your own machine.

-CHB


--
You received this message because you are subscribed to the Google Groups "conda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to conda+un...@continuum.io.
To post to this group, send email to co...@continuum.io.
Visit this group at http://groups.google.com/a/continuum.io/group/conda/.



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

Matt Craig

unread,
May 30, 2015, 12:09:20 AM5/30/15
to co...@continuum.io, mattw...@gmail.com
Interesting -- I had glanced at that when you mentioned it on another thread but hadn't really read through until just now. Looks like I won't need to think about upload code after all!

I'm actually trying, as much as I can, to avoid writing recipes; the set of packages is fairly uniform and most build with bdist_conda, so it saves updating recipes as the packages change (though I'm doing some templating and grabbing source md5 from the PyPI API to minimize version number changes).

Matt
Reply all
Reply to author
Forward
0 new messages