diff options
Diffstat (limited to 'pavement.py')
-rw-r--r-- | pavement.py | 148 |
1 files changed, 101 insertions, 47 deletions
diff --git a/pavement.py b/pavement.py index ac9a6fa1a..22eed957c 100644 --- a/pavement.py +++ b/pavement.py @@ -3,12 +3,30 @@ from paver.easy import * from paver.setuputils import setup -from paver.doctools import cog + +try: + from paver.doctools import cog +except: + cog = None + +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 sys import re from urllib import urlretrieve -from subprocess import call, Popen, PIPE +from subprocess import call, Popen from zipfile import ZipFile PROJECT_DIR = path(__file__).dirname() @@ -23,16 +41,16 @@ if sys.version_info <= (2, 5): setup( name="pyload", - version="0.4.9", + version="0.5.0", description='Fast, lightweight and full featured download manager.', - long_description=open(PROJECT_DIR / "README").read(), - keywords = ('pyload', 'download-manager', 'one-click-hoster', 'download'), + long_description=open(PROJECT_DIR / "README.md").read(), + keywords=('pyload', 'download-manager', 'one-click-hoster', 'download'), url="http://pyload.org", download_url='http://pyload.org/download', - license='GPL v3', + license='AGPL v3', author="pyLoad Team", author_email="support@pyload.org", - platforms = ('Any',), + platforms=('Any',), #package_dir={'pyload': 'src'}, packages=['pyload'], #package_data=find_package_data(), @@ -40,18 +58,20 @@ setup( 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, + install_requires=['pycurl', 'jinja2 >= 2.6', 'Beaker >= 1.6'] + extradeps, + tests_require=['websocket-client >= 0.8.0'], extras_require={ 'SSL': ["pyOpenSSL"], 'DLC': ['pycrypto'], - 'lightweight webserver': ['bjoern'], + 'Lightweight webserver': ['bjoern'], 'RSS plugins': ['feedparser'], + 'Few Hoster plugins': ['BeautifulSoup>=3.2, <3.3'] }, #setup_requires=["setuptools_hg"], entry_points={ 'console_scripts': [ - 'pyLoadCore = pyLoadCore:main', - 'pyLoadCli = pyLoadCli:main' + 'pyload = pyload:main', + 'pyload-cli = pyload_cli:main' #TODO fix ]}, zip_safe=False, classifiers=[ @@ -60,7 +80,7 @@ setup( "Environment :: Console", "Environment :: Web Environment", "Intended Audience :: End Users/Desktop", - "License :: OSI Approved :: GNU General Public License (GPL)", + "License :: OSI Approved :: GNU Affero General Public License v3", "Operating System :: OS Independent", "Programming Language :: Python :: 2" ] @@ -76,9 +96,11 @@ options( rev=None, clean=False ), - thrift=Bunch( - path="../thrift/trunk/compiler/cpp/thrift", - gen="" + apitypes=Bunch( + path="thrift", + ), + optimize_js=Bunch( + r="r.js" ), virtualenv=Bunch( dir="env", @@ -86,7 +108,7 @@ options( virtual="virtualenv2", ), cog=Bunch( - pattern="*.py", + pattern=["*.py", "*.rst"], ) ) @@ -147,7 +169,7 @@ def get_source(options): @task -@needs('clean', 'generate_setup', 'minilib', 'get_source', 'setuptools.command.sdist') +@needs('clean', 'generate_setup', 'get_source', 'setuptools.command.sdist') def sdist(): """ Build source code package with distutils """ @@ -155,21 +177,16 @@ def sdist(): @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 / "module" / "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,25 +197,61 @@ def thrift(options): (outdir / "gen-py").move(outdir / "thriftgen") #create light ttypes - from module.remote.socketbackend.create_ttypes import main + from module.remote.create_apitypes import main main() + from module.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 %}") +@cmdopts([ + ('r=', 'r', 'R.js path') +]) +def optimize_js(options): + """ Generate optimized version of the js code """ + + webdir = PROJECT_DIR / "module" / "web" / "static" + target = webdir / "js" / "app.build.js" + + (webdir / "js-optimized").rmtree() + cmd = ["node", options.optimize_js.r, "-o", target] + + print "running", cmd + p = Popen(cmd) + p.communicate() + + +@task +def load_icons(): + """ Load fontawesome icons """ + import json, requests + + f = PROJECT_DIR / "module" / "web" / "static" / "fonts" / "fontawesome.txt" + icons = [line.split() for line in open(f, "rb").read().splitlines() if not line.startswith("#")] + icons = [{"name": n, "uni": u, "file": "", "selected": True} for n, u in icons] + + r = requests.post("http://www.icnfnt.com/api/createpack", data={"json_data": json.dumps(icons)}) + r = requests.get("http://www.icnfnt.com" + r.text) + + zip = path("/tmp") / "fontawesome.zip" + f = open(zip, "wb") + f.write(r.content) + f.close() + + call(["unzip", zip, "-d", "/tmp"]) + + css = open("/tmp/fontawesome.css", "rb").read() + css = css.replace("icon-", "iconf-").replace("fontawesome-webfont", "../fonts/fontawesome-webfont") + + f = open(PROJECT_DIR / "module" / "web" / "static" / "css" / "fontawesome.css", "wb") + f.write(css) + f.close() + + from glob import glob + from shutil import copy + for f in glob("/tmp/fontawesome-webfont.*"): + copy(f, PROJECT_DIR / "module" / "web" / "static" / "fonts") @task def generate_locale(): @@ -208,7 +261,6 @@ def generate_locale(): "setup.py"] makepot("core", path("module"), 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 +283,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,7 +294,9 @@ def generate_locale(): @task def tests(): - call(["nosetests2"]) + """ Run nosetests """ + call(["tests/nosetests.sh"]) + @task def virtualenv(options): @@ -263,7 +317,7 @@ def clean_env(): @task -@needs('generate_setup', 'minilib', 'get_source', 'virtualenv') +@needs('generate_setup', 'get_source', 'virtualenv') def env_install(): """Install pyLoad into the virtualenv""" venv = options.virtualenv |