From 183865950cce697c8f610a5d2d6352e3a17fe6d3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 11 Dec 2013 11:32:43 +0530 Subject: [PATCH] added setup.py --- .gitignore | 2 + requirements.txt | 4 +- setup.py | 24 +++++++++ webnotes/app.py | 3 ++ webnotes/app_manager.py | 2 + webnotes/plugins.py | 108 ---------------------------------------- 6 files changed, 32 insertions(+), 111 deletions(-) create mode 100644 setup.py create mode 100644 webnotes/app_manager.py delete mode 100644 webnotes/plugins.py diff --git a/.gitignore b/.gitignore index 59611dfaa9..a779a7b970 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ locale .wnf-lang-status *.swp +*.egg-info +dist/ \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 075ba9cfe7..a49c683222 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,6 @@ gunicorn httplib2 jinja2 markdown2 -markupsafe mysql-python pygeoip python-dateutil @@ -17,5 +16,4 @@ six slugify termcolor werkzeug -semantic_version -gitpython==0.3.2.RC1 +semantic_version \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..9ae99296fc --- /dev/null +++ b/setup.py @@ -0,0 +1,24 @@ +from setuptools import setup, find_packages +import os + +version = '4.0.0-wip' + +with open("requirements.txt", "r") as f: + install_requires = f.readlines() + +setup( + name='webnotes', + version=version, + description='Metadata driven, full-stack web framework', + author='Web Notes Technologies', + author_email='info@erpnext.com', + packages=find_packages(), + zip_safe=False, + include_package_data=True, + install_requires=install_requires, + entry_points= { + 'console_scripts':[ + 'wnf = webnotes.wnf:main' + ] + } +) \ No newline at end of file diff --git a/webnotes/app.py b/webnotes/app.py index 74add50098..570757bb4a 100644 --- a/webnotes/app.py +++ b/webnotes/app.py @@ -1,3 +1,6 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + import sys, os import json diff --git a/webnotes/app_manager.py b/webnotes/app_manager.py new file mode 100644 index 0000000000..c7c5d9f412 --- /dev/null +++ b/webnotes/app_manager.py @@ -0,0 +1,2 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt \ No newline at end of file diff --git a/webnotes/plugins.py b/webnotes/plugins.py deleted file mode 100644 index bf09a9ec0e..0000000000 --- a/webnotes/plugins.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# MIT License. See license.txt - -from __future__ import unicode_literals -import webnotes - -def get_code_and_execute(module, doctype, docname, plugin=None, namespace=None): - code = get_code(module, doctype, docname, plugin) - return exec_code(code, namespace) - -def exec_code(code, namespace=None): - if namespace is None: namespace = {} - - if code: - exec code in namespace - - return namespace - -def get_code(module, doctype, docname, plugin=None): - try: - code = read_file(module, doctype, docname, plugin, cache=True) - except webnotes.SQLError: - return None - - return code - -def get_cache_key(doctype, docname, extn="py"): - from webnotes.modules import scrub - return "plugin_file:{doctype}:{docname}:{extn}".format(doctype=scrub(doctype), - docname=scrub(docname), extn=scrub(extn)) - -def get_plugin_name(doctype=None, docname=None): - import os - from webnotes.utils import get_site_base_path - plugin = None - - if doctype: - meta = webnotes.get_doctype(doctype) - if meta.get_field("plugin"): - plugin = webnotes.conn.get_value(doctype, docname, "plugin") - - if not plugin: - plugin = os.path.basename(get_site_base_path()) - - return plugin - -def read_file(module, doctype, docname, plugin=None, extn="py", cache=False): - import os - content = None - - if cache: - content = webnotes.cache().get_value(get_cache_key(doctype, docname, extn)) - - if not content: - path = get_path(module, doctype, docname, plugin, extn) - if os.path.exists(path): - with open(path, 'r') as f: - content = f.read() or "Does Not Exist" - - if cache: - webnotes.cache().set_value(get_cache_key(doctype, docname, extn), content) - - return None if (content == "Does Not Exist") else content - -def get_path(module, doctype, docname, plugin=None, extn="py"): - from webnotes.modules import scrub - import os - - if not module: module = webnotes.conn.get_value(doctype, docname, "module") - if not plugin: plugin = get_plugin_name(doctype, docname) - - # site_abs_path/plugins/module/doctype/docname/docname.py - return os.path.join(get_plugin_path(scrub(plugin)), scrub(module), - scrub(doctype), scrub(docname), scrub(docname) + "." + extn) - -def get_plugin_path(plugin=None): - from webnotes.modules import scrub - from webnotes.utils import get_site_path - if not plugin: plugin = get_plugin_name(None, None) - - return get_site_path(webnotes.conf.get("plugins_path"), scrub(plugin)) - -def remove_init_files(): - import os - from webnotes.utils import get_site_path, cstr - for path, folders, files in os.walk(get_site_path(webnotes.conf.get("plugins_path"))): - for f in files: - # cstr(f) is required when filenames are non-ascii - if cstr(f) in ("__init__.py", "__init__.pyc"): - os.remove(os.path.join(path, f)) - -def clear_cache(doctype=None, docname=None): - import os - from webnotes.utils import get_site_path - - def clear_single(dt, dn): - webnotes.cache().delete_value(get_cache_key(dt, dn, "py")) - webnotes.cache().delete_value(get_cache_key(dt, dn, "js")) - - if not (doctype and docname): - for path, folders, files in os.walk(get_site_path(webnotes.conf.get("plugins_path"))): - if files: - dt = os.path.basename(os.path.dirname(path)) - dn = os.path.basename(path) - clear_single(dt, dn) - else: - clear_single(doctype, docname) - \ No newline at end of file