Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I guess this thread is quite old but here is my take on it with hudson:</p> <p>I decided to go with pip and set up a repo (the painful to get working but nice looking eggbasket), which hudson auto uploads to with a successful tests. Here is my rough and ready script for use with a hudson config execute script like: /var/lib/hudson/venv/main/bin/hudson_script.py -w $WORKSPACE -p my.package -v $BUILD_NUMBER, just put in **/coverage.xml, pylint.txt and nosetests.xml in the config bits:</p> <pre><code>#!/var/lib/hudson/venv/main/bin/python import os import re import subprocess import logging import optparse logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s') #venvDir = "/var/lib/hudson/venv/main/bin/" UPLOAD_REPO = "http://ldndev01:3442" def call_command(command, cwd, ignore_error_code=False): try: logging.info("Running: %s" % command) status = subprocess.call(command, cwd=cwd, shell=True) if not ignore_error_code and status != 0: raise Exception("Last command failed") return status except: logging.exception("Could not run command %s" % command) raise def main(): usage = "usage: %prog [options]" parser = optparse.OptionParser(usage) parser.add_option("-w", "--workspace", dest="workspace", help="workspace folder for the job") parser.add_option("-p", "--package", dest="package", help="the package name i.e., back_office.reconciler") parser.add_option("-v", "--build_number", dest="build_number", help="the build number, which will get put at the end of the package version") options, args = parser.parse_args() if not options.workspace or not options.package: raise Exception("Need both args, do --help for info") venvDir = options.package + "_venv/" #find out if venv is there if not os.path.exists(venvDir): #make it call_command("virtualenv %s --no-site-packages" % venvDir, options.workspace) #install the venv/make sure its there plus install the local package call_command("%sbin/pip install -e ./ --extra-index %s" % (venvDir, UPLOAD_REPO), options.workspace) #make sure pylint, nose and coverage are installed call_command("%sbin/pip install nose pylint coverage epydoc" % venvDir, options.workspace) #make sure we have an __init__.py #this shouldn't be needed if the packages are set up correctly #modules = options.package.split(".") #if len(modules) &gt; 1: # call_command("touch '%s/__init__.py'" % modules[0], # options.workspace) #do the nosetests test_status = call_command("%sbin/nosetests %s --with-xunit --with-coverage --cover-package %s --cover-erase" % (venvDir, options.package.replace(".", "/"), options.package), options.workspace, True) #produce coverage report -i for ignore weird missing file errors call_command("%sbin/coverage xml -i" % venvDir, options.workspace) #move it so that the code coverage plugin can find it call_command("mv coverage.xml %s" % (options.package.replace(".", "/")), options.workspace) #run pylint call_command("%sbin/pylint --rcfile ~/pylint.rc -f parseable %s &gt; pylint.txt" % (venvDir, options.package), options.workspace, True) #remove old dists so we only have the newest at the end call_command("rm -rfv %s" % (options.workspace + "/dist"), options.workspace) #if the build passes upload the result to the egg_basket if test_status == 0: logging.info("Success - uploading egg") upload_bit = "upload -r %s/upload" % UPLOAD_REPO else: logging.info("Failure - not uploading egg") upload_bit = "" #create egg call_command("%sbin/python setup.py egg_info --tag-build=.0.%s --tag-svn-revision --tag-date sdist %s" % (venvDir, options.build_number, upload_bit), options.workspace) call_command("%sbin/epydoc --html --graph all %s" % (venvDir, options.package), options.workspace) logging.info("Complete") if __name__ == "__main__": main() </code></pre> <p>When it comes to deploying stuff you can do something like:</p> <pre><code>pip -E /location/of/my/venv/ install my_package==X.Y.Z --extra-index http://my_repo </code></pre> <p>And then people can develop stuff using:</p> <pre><code>pip -E /location/of/my/venv/ install -e ./ --extra-index http://my_repo </code></pre> <p>This stuff assumes you have a repo structure per package with a setup.py and dependencies all set up then you can just check out the trunk and run this stuff on it.</p> <p>I hope this helps someone out.</p> <p>------update---------</p> <p>I've added epydoc which fits in really nicely with hudson. Just add javadoc to your config with the html folder</p> <p>Note that pip doesn't support the -E flag properly these days, so you have to create your venv separately</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload