From 247c86a9b0aa2e7a8565f9740b709d6fbe39cd8f Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Sat, 6 Oct 2012 14:58:46 -0400 Subject: [PATCH 1/3] QuickStart 1 has a bunch of whining about how pypi-install isn't the proper way to do it, but the other tools are tedious internal components. Instead, add --build-here which does all the setup in a local dir named for the package, so that you can do the easy thing if it works, and *then* you can refine it in place using the other interfaces, if it turns out that there's actually anything wrong... --- scripts/pypi-install | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/scripts/pypi-install b/scripts/pypi-install index 5bac8bde..a54c5b98 100755 --- a/scripts/pypi-install +++ b/scripts/pypi-install @@ -4,6 +4,7 @@ import xmlrpclib import urllib2 import hashlib import warnings +import glob from optparse import OptionParser import tempfile import subprocess @@ -90,6 +91,8 @@ def main(): parser.add_option('--verbose', type='int', help='verbosity level', default=0) + parser.add_option('--build-here', action='store_true', + help='build the pieces in this dir, skip install') parser.add_option('--keep', action='store_true', default=False, help='do not remove temporary files') @@ -99,10 +102,18 @@ def main(): parser.print_help() sys.exit(1) + if options.build_here: + options.keep = True + package_name = args[0] orig_dir = os.path.abspath( os.curdir ) - tmpdir = os.path.abspath(tempfile.mkdtemp()) + if options.build_here: + tmpdir = os.path.abspath(package_name) + if not os.path.isdir(tmpdir): + os.mkdir(tmpdir) + else: + tmpdir = os.path.abspath(tempfile.mkdtemp()) try: if options.verbose >= 2: myprint('downloading to %s'%tmpdir) @@ -127,12 +138,14 @@ def main(): myprint('executing: %s'%cmd) subprocess.check_call(cmd, shell=True) - os.chdir( 'deb_dist' ) - cmd = 'sudo dpkg -i *.deb' - if options.verbose >= 2: - myprint('executing: %s'%cmd) - subprocess.check_call(cmd, shell=True) - + if not options.build_here: + os.chdir( 'deb_dist' ) + cmd = 'sudo dpkg -i *.deb' + if options.verbose >= 2: + myprint('executing: %s'%cmd) + subprocess.check_call(cmd, shell=True) + else: + print "Now dpkg -i", " ".join(glob.glob(os.path.join(tmpdir, expanded_dir, "deb_dist/*.deb"))) finally: os.chdir( orig_dir ) if not options.keep: From 14a7fe042b5bae2b383f23e2cc99d77469f9d6cd Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Sat, 6 Oct 2012 15:04:22 -0400 Subject: [PATCH 2/3] improve Quickstart 1 by using pypi-install as a starting point, instead of a dead end --- README.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 47a610e1..fe812a31 100644 --- a/README.rst +++ b/README.rst @@ -201,12 +201,13 @@ Quickstart 1: Install something from PyPI now, I don't care about anything else Do this from the command line:: - pypi-install mypackage + pypi-install --build-here mypackage **Warning: Despite doing its best, there is absolutely no way stdeb can guarantee all the Debian package dependencies will be properly -fulfilled without manual intervention. Using pypi-install bypasses -your ability to customize stdeb's behavior. Read the rest of this +fulfilled without manual intervention. Consider the output of this to +be a "first draft", which you can use as a stopgap, and then refine in +place. Read the rest of this document to understand how to make better packages.** Quickstart 2: Just tell me the fastest way to make a .deb From 9e71922d197dcdab607b8d58d9df181b459189c9 Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Sat, 6 Oct 2012 15:18:19 -0400 Subject: [PATCH 3/3] Many pypi packages have StuDlyCaps names, but of course *python* names (and in particular, the names listed in MANIFEST) don't have them, so if that's all we have to go by, we're at another pointless roadblock. Instead, if the what the user asked for doesn't match perfectly, try a pypi.search on the name; if there's exactly one match, run with it (if there are multiple matches, display them so the user can easily pick the right one and cut&paste it.) (Simple example: I'm trying to use SST (selenium-simple-test), it needs PyVirtualDisplay, which has an unparseable MANIFEST.in; pydist ends up reporting "Cannot find installed package that provides easyprocess", so I try "pypi-install --build-here easyprocess", which failed to find anything. With this change, I instead get easyprocess not found, trying search: EasyProcess 0.1.4 Easy to use python subprocess interface. Assuming you meant EasyProcess and it goes on and builds the package, which is what everyone actually wants...) --- scripts/pypi-install | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/pypi-install b/scripts/pypi-install index a54c5b98..3f56f59b 100755 --- a/scripts/pypi-install +++ b/scripts/pypi-install @@ -29,6 +29,22 @@ def find_tar_gz(package_name, pypi_url = 'http://python.org/pypi',verbose=0): myprint( 'querying PyPI (%s) for package name "%s"' % (pypi_url, package_name) ) releases = pypi.package_releases(package_name) + if not releases: + print package_name, "not found, trying search:" + matches = pypi.search(dict(name=package_name)) + if not matches: + raise ValueError("No pypi search results for %s, try google" % package_name) + for match in matches: + print match["name"], match["version"] + print match["summary"] + if len(matches) > 1: + raise ValueError("Multiple options, pick one and try again") + package_name = matches[0]["name"] + releases = pypi.package_releases(package_name) + if not releases: + raise ValueError("%s found, but no releases found" % package_name) + print "Assuming you meant", package_name + if verbose >= 2: myprint( 'found releases: %s' % (', '.join(releases),) ) if len(releases) > 1: