Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make versioned minilib as an option (as well in setup generating), fix

  • Loading branch information...
commit 5a9fea2fc075b2c754ff19bfda4b06d79211a872 1 parent ed6a51a
@yedpodtrzitko yedpodtrzitko authored Almad committed
View
3  docs/samples/started/newway/pavement.py
@@ -36,7 +36,8 @@
# [[[section minilib]]]
options(
minilib = Bunch(
- extra_files=["doctools"]
+ extra_files=["doctools"],
+ versioned_name=False
)
)
# [[[endsection]]]
View
8 pavement.py
@@ -14,7 +14,8 @@
options(
minilib=Bunch(
- extra_files=['doctools', 'virtual']
+ extra_files=['doctools', 'virtual'],
+ versioned_name=False,
),
sphinx=Bunch(
builddir="build",
@@ -177,8 +178,3 @@ def publish_docs(options):
safe_clone.rmtree()
docs_repo.rmtree()
os.remove(git)
-
-
-
-
-
View
BIN  paver-minilib.zip
Binary file not shown
View
39 paver/misctasks.py
@@ -4,7 +4,7 @@
from StringIO import StringIO
from os.path import join, dirname, exists, abspath
from paver.easy import dry, task
-from paver.tasks import VERSION
+from paver.tasks import VERSION, cmdopts
_docsdir = join(dirname(__file__), "docs")
if exists(_docsdir):
@@ -15,6 +15,7 @@ def paverdocs():
webbrowser.open("file://%s" % join(abspath(_docsdir), 'index.html') )
@task
+@cmdopts([('versioned_name', 'v', 'Determine if minilib uses version in its name')])
def minilib(options):
"""Create a Paver mini library that contains enough for a simple
pavement.py to be installed using a generated setup.py. This
@@ -23,6 +24,13 @@ def minilib(options):
Options:
+ versioned_name
+ if set to True, paver version will be added into minilib's filename
+ (ie paver-minilib-1.1.0.zip)
+ purpose is to avoid import error while using different versions of minilib
+ with easy_install
+ (default False)
+
extra_files
list of other paver modules to include (don't include the .py
extension). By default, the following modules are included:
@@ -32,16 +40,17 @@ def minilib(options):
filelist = ['__init__', 'defaults', 'path', 'path25', 'release',
'setuputils', "misctasks", "options", "tasks", "easy"]
filelist.extend(options.get('extra_files', []))
- output_file = 'paver-minilib-%s.zip' % VERSION
+
+ output_version = "-%s" % VERSION if options.versioned_name else ""
+ output_file = 'paver-minilib%s.zip' % output_version
def generate_zip():
# Write the mini library to a buffer.
buf = StringIO()
destfile = zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED)
for filename in filelist:
- destfile.writestr(
- "paver/" + (filename + ".py"),
- pkgutil.get_data('paver', filename + ".py"))
+ destfile.writestr("paver/%s.py" % filename,
+ pkgutil.get_data('paver', "%s.py" % filename))
destfile.close()
# Write the buffer to disk.
@@ -51,24 +60,32 @@ def generate_zip():
dry("Generate %s" % output_file, generate_zip)
@task
-def generate_setup():
- """Generates a setup.py file that uses paver behind the scenes. This
+@cmdopts([('versioned_name', 'v', 'Determine if setup refer to minilib with version in its name')])
+def generate_setup(options):
+ """Generates a setup.py file that uses paver behind the scenes. This
setup.py file will look in the directory that the user is running it
in for a paver-minilib.zip and will add that to sys.path if available.
Otherwise, it will just assume that paver is available."""
+ if options.versioned_name:
+ minilib_name = "paver-minilib%s.zip" % ("-" + VERSION)
+ is_versioned_msg = ', referring versioned minilib: %s' % minilib_name
+ else:
+ is_versioned_msg = ""
+ minilib_name = 'paver-minilib.zip'
+
def write_setup():
setup = open("setup.py", "w")
setup.write("""try:
import paver.tasks
except ImportError:
from os.path import exists
- if exists("paver-minilib-%(VERSION)s.zip"):
+ if exists("%(minilib_name)s"):
import sys
- sys.path.insert(0, "paver-minilib-%(VERSION)s.zip")
+ sys.path.insert(0, "%(minilib_name)s")
import paver.tasks
paver.tasks.main()
-""" % {'VERSION': VERSION})
+""" % {'minilib_name': minilib_name})
setup.close()
- dry("Write setup.py", write_setup)
+ dry("Write setup.py%s" % is_versioned_msg, write_setup)
View
4 setup.py
@@ -2,9 +2,9 @@
import paver.tasks
except ImportError:
from os.path import exists
- if exists("paver-minilib.zip"):
+ if exists("paver-minilib-1.1.0.zip"):
import sys
- sys.path.insert(0, "paver-minilib.zip")
+ sys.path.insert(0, "paver-minilib-1.1.0.zip")
import paver.tasks
paver.tasks.main()
Please sign in to comment.
Something went wrong with that request. Please try again.