diff options
Diffstat (limited to 'pavement.py')
-rw-r--r-- | pavement.py | 217 |
1 files changed, 64 insertions, 153 deletions
diff --git a/pavement.py b/pavement.py index ac9a6fa1a..459f7c728 100644 --- a/pavement.py +++ b/pavement.py @@ -1,84 +1,41 @@ # -*- coding: utf-8 -*- - from paver.easy import * -from paver.setuputils import setup from paver.doctools import cog +import fnmatch + +# patch to let it support list of patterns +def new_fnmatch(self, pattern): + if type(pattern) == list: + for p in pattern: + if fnmatch.fnmatch(self.name, p): + return True + return False + else: + return fnmatch.fnmatch(self.name, pattern) + + +path.fnmatch = new_fnmatch + +import os import sys import re -from urllib import urlretrieve -from subprocess import call, Popen, PIPE -from zipfile import ZipFile +from subprocess import call, Popen PROJECT_DIR = path(__file__).dirname() sys.path.append(PROJECT_DIR) -options = environment.options -path('pyload').mkdir() - -extradeps = [] -if sys.version_info <= (2, 5): - extradeps += 'simplejson' - -setup( - name="pyload", - version="0.4.9", - description='Fast, lightweight and full featured download manager.', - long_description=open(PROJECT_DIR / "README").read(), - keywords = ('pyload', 'download-manager', 'one-click-hoster', 'download'), - url="http://pyload.org", - download_url='http://pyload.org/download', - license='GPL v3', - author="pyLoad Team", - author_email="support@pyload.org", - platforms = ('Any',), - #package_dir={'pyload': 'src'}, - packages=['pyload'], - #package_data=find_package_data(), - #data_files=[], - include_package_data=True, - exclude_package_data={'pyload': ['docs*', 'scripts*', 'tests*']}, #exluced from build but not from sdist - # 'bottle >= 0.10.0' not in list, because its small and contain little modifications - install_requires=['thrift >= 0.8.0', 'jinja2', 'pycurl', 'Beaker', 'BeautifulSoup>=3.2, <3.3'] + extradeps, - extras_require={ - 'SSL': ["pyOpenSSL"], - 'DLC': ['pycrypto'], - 'lightweight webserver': ['bjoern'], - 'RSS plugins': ['feedparser'], - }, - #setup_requires=["setuptools_hg"], - entry_points={ - 'console_scripts': [ - 'pyLoadCore = pyLoadCore:main', - 'pyLoadCli = pyLoadCli:main' - ]}, - zip_safe=False, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Topic :: Internet :: WWW/HTTP", - "Environment :: Console", - "Environment :: Web Environment", - "Intended Audience :: End Users/Desktop", - "License :: OSI Approved :: GNU General Public License (GPL)", - "Operating System :: OS Independent", - "Programming Language :: Python :: 2" - ] -) +from pyload import __version__ +options = environment.options options( sphinx=Bunch( builddir="_build", sourcedir="" ), - get_source=Bunch( - src="https://bitbucket.org/spoob/pyload/get/tip.zip", - rev=None, - clean=False - ), - thrift=Bunch( - path="../thrift/trunk/compiler/cpp/thrift", - gen="" + apitypes=Bunch( + path="thrift", ), virtualenv=Bunch( dir="env", @@ -86,90 +43,38 @@ options( virtual="virtualenv2", ), cog=Bunch( - pattern="*.py", + pattern=["*.py", "*.rst"], ) ) # xgettext args xargs = ["--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyLoad", - "--package-version=%s" % options.version, "--msgid-bugs-address='bugs@pyload.org'"] + "--package-version=%s" % __version__, "--msgid-bugs-address='bugs@pyload.org'"] + @task @needs('cog') def html(): """Build html documentation""" - module = path("docs") / "module" + module = path("docs") / "pyload" module.rmtree() call_task('paver.doctools.html') -@task -@cmdopts([ - ('src=', 's', 'Url to source'), - ('rev=', 'r', "HG revision"), - ("clean", 'c', 'Delete old source folder') -]) -def get_source(options): - """ Downloads pyload source from bitbucket tip or given rev""" - if options.rev: options.url = "https://bitbucket.org/spoob/pyload/get/%s.zip" % options.rev - - pyload = path("pyload") - - if len(pyload.listdir()) and not options.clean: - return - elif pyload.exists(): - pyload.rmtree() - - urlretrieve(options.src, "pyload_src.zip") - zip = ZipFile("pyload_src.zip") - zip.extractall() - path("pyload_src.zip").remove() - - folder = [x for x in path(".").dirs() if x.name.startswith("spoob-pyload-")][0] - folder.move(pyload) - - change_mode(pyload, 0644) - change_mode(pyload, 0755, folder=True) - - for file in pyload.files(): - if file.name.endswith(".py"): - file.chmod(0755) - - (pyload / ".hgtags").remove() - (pyload / ".hgignore").remove() - #(pyload / "docs").rmtree() - - f = open(pyload / "__init__.py", "wb") - f.close() - - #options.setup.packages = find_packages() - #options.setup.package_data = find_package_data() - - -@task -@needs('clean', 'generate_setup', 'minilib', 'get_source', 'setuptools.command.sdist') -def sdist(): - """ Build source code package with distutils """ - @task @cmdopts([ ('path=', 'p', 'Thrift path'), - ('gen=', 'g', "Extra --gen option") ]) -def thrift(options): - """ Generate Thrift stubs """ - - print "add import for TApplicationException manually as long it is not fixed" +def apitypes(options): + """ Generate data types stubs """ - outdir = path("module") / "remote" / "thriftbackend" - (outdir / "gen-py").rmtree() + outdir = PROJECT_DIR / "pyload" / "remote" - cmd = [options.thrift.path, "-strict", "-o", outdir, "--gen", "py:slots,dynamic", outdir / "pyload.thrift"] + if (outdir / "gen-py").exists(): + (outdir / "gen-py").rmtree() - if options.gen: - cmd.insert(len(cmd) - 1, "--gen") - cmd.insert(len(cmd) - 1, options.gen) + cmd = [options.apitypes.path, "-strict", "-o", outdir, "--gen", "py:slots,dynamic", outdir / "pyload.thrift"] print "running", cmd @@ -180,35 +85,41 @@ def thrift(options): (outdir / "gen-py").move(outdir / "thriftgen") #create light ttypes - from module.remote.socketbackend.create_ttypes import main + from pyload.remote.create_apitypes import main + + main() + from pyload.remote.create_jstypes import main + main() + @task -def compile_js(): - """ Compile .coffee files to javascript""" - - root = path("module") / "web" / "media" / "js" - for f in root.glob("*.coffee"): - print "generate", f - coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE) - yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE) - coffee.stdout.close() - content = yui.communicate()[0] - with open(root / f.name.replace(".coffee", ".js"), "wb") as js: - js.write("{% autoescape true %}\n") - js.write(content) - js.write("\n{% endautoescape %}") +def webapp(): + """ Builds the pyload web app. Nodejs and npm must be installed """ + + os.chdir(PROJECT_DIR / "pyload" / "web") + + # Preserve exit codes + ret = call(["npm", "install", "--no-color"]) + if ret: + exit(ret) + ret = call(["bower", "install", "--no-color"]) + if ret: + exit(ret) + ret = call(["grunt", "--no-color"]) + if ret: + exit(ret) @task def generate_locale(): """ Generates localisation files """ + # TODO restructure, many references are outdated EXCLUDE = ["BeautifulSoup.py", "module/gui", "module/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload", "setup.py"] - makepot("core", path("module"), EXCLUDE, "./pyLoadCore.py\n") + makepot("core", path("pyload"), EXCLUDE, "./pyLoadCore.py\n") - makepot("gui", path("module") / "gui", [], includes="./pyLoadGui.py\n") makepot("cli", path("module") / "cli", [], includes="./pyLoadCli.py\n") makepot("setup", "", [], includes="./module/setup.py\n") @@ -231,7 +142,7 @@ def generate_locale(): for s in strings: js.write('_("%s")\n' % s) - makepot("django", path("module/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"]) + makepot("web", path("module/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"]) trans.remove() @@ -242,9 +153,17 @@ def generate_locale(): @task def tests(): - call(["nosetests2"]) + """ Run complete test suite """ + call(["tests/run_pyload.sh"]) + call(["tests/nosetests.sh"]) + call(["tests/quit_pyload.sh"]) + @task +@cmdopts([ + ('virtual=', 'v', 'virtualenv path'), + ('python=', 'p', 'python path') +]) def virtualenv(options): """Setup virtual environment""" if path(options.dir).exists(): @@ -263,14 +182,6 @@ def clean_env(): @task -@needs('generate_setup', 'minilib', 'get_source', 'virtualenv') -def env_install(): - """Install pyLoad into the virtualenv""" - venv = options.virtualenv - call([path(venv.dir) / "bin" / "easy_install", "."]) - - -@task def clean(): """Cleans build directories""" path("build").rmtree() |