changeset 53:af4155b0a260 default tip

add --prefix option
author Jeff Hammel <k0scist@gmail.com>
date Tue, 03 Nov 2020 07:59:36 -0800
parents b717de8b384f
children
files buttercup/buttercup.py buttercup/checkout.py setup.py
diffstat 3 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/buttercup/buttercup.py	Tue Nov 03 07:51:52 2020 -0800
+++ b/buttercup/buttercup.py	Tue Nov 03 07:59:36 2020 -0800
@@ -2,6 +2,8 @@
 the flower blooming to k0s.org
 """
 
+# TODO: this should all go in a `pip` requirements file
+
 import os
 from subprocess import check_call as call
 from . import source
@@ -52,13 +54,12 @@
               'wordstream',
               'wsgintegrate']
 
-    def __init__(self, srcdir):
+    def __init__(self, srcdir, prefix=None):
         self.srcdir = srcdir
-
-        # TODO: this should all go in a `pip` requirements file
+        self.prefix = prefix or self.HG
 
         # base webapps and dependencies
-        self.sources = {'hg': ['%s/%s' % (self.HG, package)
+        self.sources = {'hg': ['%s/%s' % (self.prefix, package)
                                for package in self.PACKAGES ]}
         self.sources['git'] = []
 
--- a/buttercup/checkout.py	Tue Nov 03 07:51:52 2020 -0800
+++ b/buttercup/checkout.py	Tue Nov 03 07:59:36 2020 -0800
@@ -25,25 +25,27 @@
                       help="install the packages")
     parser.add_option('--list', action="store_true", default=False,
                       help="list the source to be installed")
+    parser.add_option('--prefix',
+                      help="prefix or http://k0s.org/hg if not specified")
     options, args = parser.parse_args(args)
 
     # list sources if specified
     if options.list:
-        buttercup = Buttercup(srcdir=None)
+        buttercup = Buttercup(srcdir=None, prefix=options.prefix)
         sources = source.sources(buttercup.sources)
         for s in sources:
             print('%s: %s' % (s.directory_name(s.uri), s.uri))
-        sys.exit(0)
+        return
 
     # setup the src directory in a virtualenv
-    if 'VIRTUAL_ENV' in os.environ:
+    if 'VIRTUAL_ENV' not in os.environ:
         raise AssertionError("You must have a virtualenv activated")
     src = os.path.join(os.environ['VIRTUAL_ENV'], 'src')
     if not os.path.exists(src):
         os.mkdir(src)
 
     # grow a flower
-    buttercup = Buttercup(srcdir=src)
+    buttercup = Buttercup(srcdir=src, prefix=options.prefix)
 
     # clone/update the sources
     buttercup.install()
@@ -52,4 +54,4 @@
         buttercup.setup()
 
 if __name__ == '__main__':
-    main()
+    sys.exit(main() or 0)
--- a/setup.py	Tue Nov 03 07:51:52 2020 -0800
+++ b/setup.py	Tue Nov 03 07:59:36 2020 -0800
@@ -18,7 +18,7 @@
       license="GPL",
       packages=find_packages(exclude=['ez_setup', 'examples', 'tests*']),
       include_package_data=True,
-      install_requires = [ 'PasteScript' ],
+      install_requires = ['PasteScript'],
       zip_safe=False,
       entry_points = """
       [console_scripts]
@@ -28,4 +28,3 @@
       buttercup = buttercup:buttercup
       """,
       )
-