fades-5/ 0000775 0001750 0001750 00000000000 12660652702 013372 5 ustar facundo facundo 0000000 0000000 fades-5/fades/ 0000775 0001750 0001750 00000000000 12660652702 014454 5 ustar facundo facundo 0000000 0000000 fades-5/fades/cache.py 0000664 0001750 0001750 00000013652 12656517052 016103 0 ustar facundo facundo 0000000 0000000 # Copyright 2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General
# Public License version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
# If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""The cache manager for virtualenvs."""
import fcntl
import json
import logging
import os
import time
from contextlib import contextmanager
from pkg_resources import Distribution
from fades import helpers
logger = logging.getLogger(__name__)
class VEnvsCache:
"""A cache for virtualenvs."""
def __init__(self, filepath):
"""Init."""
logger.debug("Using cache index: %r", filepath)
self.filepath = filepath
def _venv_match(self, installed, requirements):
"""Return True if what is installed satisfies the requirements.
This method has multiple exit-points, but only for False (because
if *anything* is not satisified, the venv is no good). Only after
all was checked, and it didn't exit, the venv is ok so return True.
"""
if not requirements:
# special case for no requirements, where we can't actually
# check anything: the venv is useful if nothing installed too
return not bool(installed)
useful_inst = set()
for repo, req_deps in requirements.items():
if repo not in installed:
# the venv doesn't even have the repo
return False
inst_deps = {Distribution(project_name=dep, version=ver)
for (dep, ver) in installed[repo].items()}
for req in req_deps:
for inst in inst_deps:
if inst in req:
useful_inst.add(inst)
break
else:
# nothing installed satisfied that requirement
return False
# assure *all* that is installed is useful for the requirements
if useful_inst != inst_deps:
return False
# it did it through!
return True
def _select(self, current_venvs, requirements=None, interpreter='', uuid='', options=None):
"""Select which venv satisfy the received requirements."""
def match_by_uuid(env):
return env.get('metadata', {}).get('env_path') == env_path
def match_by_req_and_interpreter(env):
return (env.get('options') == options and
env.get('interpreter') == interpreter and
self._venv_match(venv['installed'], requirements))
if uuid:
logger.debug("Searching a venv by uuid: %s", uuid)
env_path = os.path.join(helpers.get_basedir(), uuid)
match = match_by_uuid
else:
logger.debug("Searching a venv for reqs: %s and interpreter: %s",
requirements, interpreter)
match = match_by_req_and_interpreter
for venv_str in current_venvs:
venv = json.loads(venv_str)
if match(venv):
logger.debug("Found a matching venv! %s", venv)
return venv['metadata']
logger.debug("No matching venv found :(")
def get_venv(self, requirements=None, interpreter='', uuid='', options=None):
"""Find a venv that serves these requirements, if any."""
lines = self._read_cache()
return self._select(lines, requirements, interpreter, uuid=uuid, options=options)
def store(self, installed_stuff, metadata, interpreter, options):
"""Store the virtualenv metadata for the indicated installed_stuff."""
new_content = {
'timestamp': int(time.mktime(time.localtime())),
'installed': installed_stuff,
'metadata': metadata,
'interpreter': interpreter,
'options': options
}
logger.debug("Storing installed=%s metadata=%s interpreter=%s options=%s",
installed_stuff, metadata, interpreter, options)
with self.lock_cache():
self._write_cache([json.dumps(new_content)], append=True)
def remove(self, env_path):
"""Remove metadata for a given virtualenv from cache."""
with self.lock_cache():
cache = self._read_cache()
logger.debug("Removing virtualenv from cache: %s" % env_path)
lines = [
line for line in cache
if json.loads(line).get('metadata', {}).get('env_path') != env_path
]
self._write_cache(lines)
@contextmanager
def lock_cache(self):
"""Context manager used to lock over the cache usage."""
lock_file = self.filepath + '.lock'
with open(lock_file, 'a') as fh:
fcntl.flock(fh, fcntl.LOCK_EX)
yield
fcntl.flock(fh, fcntl.LOCK_UN)
if os.path.exists(lock_file):
os.remove(lock_file)
def _read_cache(self):
"""Read virtualenv metadata from cache."""
if os.path.exists(self.filepath):
with open(self.filepath, 'rt', encoding='utf8') as fh:
lines = [x.strip() for x in fh]
else:
logger.debug("Index not found, starting empty")
lines = []
return lines
def _write_cache(self, lines, append=False):
"""Write virtualenv metadata to cache."""
mode = 'at' if append else 'wt'
with open(self.filepath, mode, encoding='utf8') as fh:
fh.writelines(line + '\n' for line in lines)
fades-5/fades/__main__.py 0000664 0001750 0001750 00000000157 12643524377 016560 0 ustar facundo facundo 0000000 0000000 """Init file to allow execution of fades as a module."""
import sys
from fades import main
main.go(sys.argv)
fades-5/fades/envbuilder.py 0000664 0001750 0001750 00000013760 12643524377 017203 0 ustar facundo facundo 0000000 0000000 # Copyright 2014 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Extended class from EnvBuilder to create a venv using a uuid4 id.
NOTE: this class only work in the same python version that Fades is
running. So, you don't need to have installed a virtualenv tool. For
other python versions Fades needs a virtualenv tool installed.
"""
import logging
import os
import shutil
import sys
from venv import EnvBuilder
from uuid import uuid4
from fades import REPO_PYPI
from fades import helpers
from fades.pipmanager import PipManager
logger = logging.getLogger(__name__)
class FadesEnvBuilder(EnvBuilder):
"""Create always a virtualenv."""
def __init__(self, env_path=None):
"""Init."""
basedir = helpers.get_basedir()
if env_path is None:
env_path = os.path.join(basedir, str(uuid4()))
self.env_path = env_path
self.env_bin_path = ''
logger.debug("Env will be created at: %s", self.env_path)
if sys.version_info >= (3, 4):
# try to install pip using default machinery (which will work in a lot
# of systems, noticeably it won't in some debians or ubuntus, like
# Trusty; in that cases mark it to install manually later)
try:
import ensurepip # NOQA
self.pip_installed = True
except ImportError:
self.pip_installed = False
super().__init__(with_pip=self.pip_installed, symlinks=True)
else:
# old Python doesn't have integrated pip
self.pip_installed = False
super().__init__(symlinks=True)
def create_with_virtualenv(self, interpreter, virtualenv_options):
"""Create a virtualenv using the virtualenv lib."""
args = ['virtualenv', '--python', interpreter, self.env_path]
args.extend(virtualenv_options)
if not self.pip_installed:
args.insert(3, '--no-pip')
try:
helpers.logged_exec(args)
self.env_bin_path = os.path.join(self.env_path, 'bin')
except FileNotFoundError as error:
logger.error('Virtualenv is not installed. It is needed to create a virtualenv with '
'a different python version than fades (got {})'.format(error))
exit()
except helpers.ExecutionError as error:
error.dump_to_log(logger)
exit()
except Exception as error:
logger.exception("Error creating virtualenv: %s", error)
exit()
def create_env(self, interpreter, is_current, options):
"""Create the virtualenv and return its info."""
if is_current:
# apply pyvenv options
pyvenv_options = options['pyvenv_options']
if "--system-site-packages" in pyvenv_options:
self.system_site_packages = True
logger.debug("Creating virtualenv with pyvenv. options=%s", pyvenv_options)
self.create(self.env_path)
else:
virtualenv_options = options['virtualenv_options']
logger.debug("Creating virtualenv with virtualenv")
self.create_with_virtualenv(interpreter, virtualenv_options)
logger.debug("env_bin_path: %s", self.env_bin_path)
# Re check if pip was installed.
pip_exe = os.path.join(self.env_bin_path, "pip")
if not os.path.exists(pip_exe):
logger.debug("pip isn't installed in the venv, setting pip_installed=False")
self.pip_installed = False
return self.env_path, self.env_bin_path, self.pip_installed
def destroy_env(self):
"""Destroy the virtualenv."""
logger.debug("Destroying virtualenv at: %s", self.env_path)
shutil.rmtree(self.env_path, ignore_errors=True)
def post_setup(self, context):
"""Get the bin path from context."""
self.env_bin_path = context.bin_path
def create_venv(requested_deps, interpreter, is_current, options, pip_options):
"""Create a new virtualvenv with the requirements of this script."""
# create virtualenv
env = FadesEnvBuilder()
env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options)
venv_data = {}
venv_data['env_path'] = env_path
venv_data['env_bin_path'] = env_bin_path
venv_data['pip_installed'] = pip_installed
# install deps
installed = {}
for repo in requested_deps.keys():
if repo == REPO_PYPI:
mgr = PipManager(env_bin_path, pip_installed=pip_installed, options=pip_options)
else:
logger.warning("Install from %r not implemented", repo)
continue
installed[repo] = {}
repo_requested = requested_deps[repo]
logger.debug("Installing dependencies for repo %r: requested=%s", repo, repo_requested)
for dependency in repo_requested:
mgr.install(dependency)
# always store the installed dependency, as in the future we'll select the venv
# based on what is installed, not what used requested (remember that user may
# request >, >=, etc!)
project = dependency.project_name
installed[repo][project] = mgr.get_version(project)
logger.debug("Installed dependencies: %s", installed)
return venv_data, installed
def destroy_venv(env_path):
"""Destroy a venv."""
env = FadesEnvBuilder(env_path)
env.destroy_env()
fades-5/fades/__init__.py 0000664 0001750 0001750 00000001475 12620445633 016573 0 ustar facundo facundo 0000000 0000000 # Copyright 2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General
# Public License version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
# If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Main package."""
from ._version import __version__ # NOQA; provides module level version attr
REPO_PYPI = 'pypi'
fades-5/fades/_version.py 0000664 0001750 0001750 00000000075 12660652363 016657 0 ustar facundo facundo 0000000 0000000 """Holder of the fades version number."""
__version__ = '5'
fades-5/fades/main.py 0000664 0001750 0001750 00000023003 12656517052 015753 0 ustar facundo facundo 0000000 0000000 # Copyright 2014-2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General
# Public License version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
# If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Main 'fades' modules."""
import argparse
import os
import signal
import sys
import subprocess
import fades
from fades import parsing, logger, cache, helpers, envbuilder, file_options
# the signals to redirect to the child process (note: only these are
# allowed in Windows, see 'signal' doc).
REDIRECTED_SIGNALS = [
signal.SIGABRT,
signal.SIGFPE,
signal.SIGILL,
signal.SIGINT,
signal.SIGSEGV,
signal.SIGTERM,
]
help_epilog = """
The "child program" is the script that fades will execute. It's an
optional parameter, it will be the first thing received by fades that
is not a parameter. If no child program is indicated, a Python
interactive interpreter will be opened.
The "child options" (everything after the child program) are
parameters passed as is to the child program.
"""
help_usage = """
fades [-h] [-V] [-v] [-q] [-i] [-d DEPENDENCY] [-r REQUIREMENT] [-p PYTHON]
[child_program [child_options]]
"""
def _merge_deps(*deps):
"""Merge all the dependencies; latest dicts overwrite first ones."""
final = {}
for dep in deps:
for repo, info in dep.items():
final.setdefault(repo, []).extend(info)
return final
def go(argv):
"""Make the magic happen."""
parser = argparse.ArgumentParser(prog='PROG', epilog=help_epilog, usage=help_usage,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-V', '--version', action='store_true',
help="show version and info about the system, and exit")
parser.add_argument('-v', '--verbose', action='store_true',
help="send all internal debugging lines to stderr, which may be very "
"useful to debug any problem that may arise.")
parser.add_argument('-q', '--quiet', action='store_true',
help="don't show anything (unless it has a real problem), so the "
"original script stderr is not polluted at all.")
parser.add_argument('-d', '--dependency', action='append',
help="specify dependencies through command line (this option can be "
"used multiple times)")
parser.add_argument('-r', '--requirement',
help="indicate from which file read the dependencies")
parser.add_argument('-p', '--python', action='store',
help=("Specify the Python interpreter to use.\n"
" Default is: %s") % (sys.executable,))
parser.add_argument('-x', '--exec', dest='executable', action='store_true',
help=("Indicate that the child_program should be looked up in the "
"virtualenv."))
parser.add_argument('-i', '--ipython', action='store_true', help="use IPython shell.")
parser.add_argument('--system-site-packages', action='store_true', default=False,
help=("Give the virtual environment access to the "
"system site-packages dir."))
parser.add_argument('--virtualenv-options', action='append', default=[],
help=("Extra options to be supplied to virtualenv. (this option can be "
"used multiple times)"))
parser.add_argument('--check-updates', action='store_true',
help=("check for packages updates"))
parser.add_argument('--pip-options', action='append', default=[],
help=("Extra options to be supplied to pip. (this option can be "
"used multiple times)"))
parser.add_argument('--rm', dest='remove', metavar='UUID',
help=("Remove a virtualenv by UUID."))
parser.add_argument('child_program', nargs='?', default=None)
parser.add_argument('child_options', nargs=argparse.REMAINDER)
# support the case when executed from a shell-bang, where all the
# parameters come in sys.argv[1] in a single string separated
# by spaces (in this case, the third parameter is what is being
# executed)
if len(sys.argv) > 1 and " " in sys.argv[1]:
real_args = sys.argv[1].split() + sys.argv[2:]
cli_args = parser.parse_args(real_args)
else:
cli_args = parser.parse_args()
# update args from config file (if needed).
args = file_options.options_from_file(cli_args)
# validate input, parameters, and support some special options
if args.version:
print("Running 'fades' version", fades.__version__)
print(" Python:", sys.version_info)
print(" System:", sys.platform)
sys.exit()
# set up logger and dump basic version info
l = logger.set_up(args.verbose, args.quiet)
l.debug("Running Python %s on %r", sys.version_info, sys.platform)
l.debug("Starting fades v. %s", fades.__version__)
l.debug("Arguments: %s", args)
if args.verbose and args.quiet:
l.warning("Overriding 'quiet' option ('verbose' also requested)")
# start the virtualenvs manager
venvscache = cache.VEnvsCache(os.path.join(helpers.get_basedir(), 'venvs.idx'))
uuid = args.remove
if uuid:
venv_data = venvscache.get_venv(uuid=uuid)
if venv_data:
# remove this venv from the cache
env_path = venv_data.get('env_path')
if env_path:
venvscache.remove(env_path)
envbuilder.destroy_venv(env_path)
else:
l.warning("Invalid 'env_path' found in virtualenv metadata: %r. "
"Not removing virtualenv.", env_path)
else:
l.warning('No virtualenv found with uuid: %s.', uuid)
return
# parse file and get deps
if args.ipython:
l.debug("Adding ipython dependency because --ipython was detected")
ipython_dep = parsing.parse_manual(['ipython'])
else:
ipython_dep = {}
if args.executable:
indicated_deps = {}
docstring_deps = {}
else:
indicated_deps = parsing.parse_srcfile(args.child_program)
l.debug("Dependencies from source file: %s", indicated_deps)
docstring_deps = parsing.parse_docstring(args.child_program)
l.debug("Dependencies from docstrings: %s", docstring_deps)
reqfile_deps = parsing.parse_reqfile(args.requirement)
l.debug("Dependencies from requirements file: %s", reqfile_deps)
manual_deps = parsing.parse_manual(args.dependency)
l.debug("Dependencies from parameters: %s", manual_deps)
indicated_deps = _merge_deps(ipython_dep, indicated_deps, docstring_deps,
reqfile_deps, manual_deps)
# Check for packages updates
if args.check_updates:
helpers.check_pypi_updates(indicated_deps)
# get the interpreter version requested for the child_program
interpreter, is_current = helpers.get_interpreter_version(args.python)
# options
pip_options = args.pip_options # pip_options mustn't store.
options = {}
options['pyvenv_options'] = []
options['virtualenv_options'] = args.virtualenv_options
if args.system_site_packages:
options['virtualenv_options'].append("--system-site-packages")
options['pyvenv_options'] = ["--system-site-packages"]
# start the virtualenvs manager
venvscache = cache.VEnvsCache(os.path.join(helpers.get_basedir(), 'venvs.idx'))
venv_data = venvscache.get_venv(indicated_deps, interpreter, uuid, options)
if venv_data is None:
venv_data, installed = envbuilder.create_venv(indicated_deps, args.python, is_current,
options, pip_options)
# store this new venv in the cache
venvscache.store(installed, venv_data, interpreter, options)
# run forest run!!
python_exe = 'ipython' if args.ipython else 'python'
python_exe = os.path.join(venv_data['env_bin_path'], python_exe)
if args.child_program is None:
l.debug("Calling the interactive Python interpreter")
p = subprocess.Popen([python_exe])
else:
if args.executable:
cmd = [os.path.join(venv_data['env_bin_path'], args.child_program)]
else:
cmd = [python_exe, args.child_program]
l.debug("Calling the child program %r with options %s",
args.child_program, args.child_options)
p = subprocess.Popen(cmd + args.child_options)
def _signal_handler(signum, _):
"""Handle signals received by parent process, send them to child."""
l.debug("Redirecting signal %s to child", signum)
os.kill(p.pid, signum)
# redirect these signals
for s in REDIRECTED_SIGNALS:
signal.signal(s, _signal_handler)
# wait child to finish, end
rc = p.wait()
if rc:
l.debug("Child process not finished correctly: returncode=%d", rc)
sys.exit(rc)
fades-5/fades/pkgnamesdb.py 0000664 0001750 0001750 00000001777 12656517052 017160 0 ustar facundo facundo 0000000 0000000 # Copyright 2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""A list of packages containing names which don't match with the PyPi distrbution's name."""
PKG_NAMES_DB = {
'bs4': 'beautifulsoup4',
'github3': 'github3.py',
'uritemplate': 'uritemplate.py',
'postgresql': 'py-postgresql',
'yaml': 'pyyaml',
'PIL': 'Pillow',
'Crypto': 'pycrypto',
}
fades-5/fades/file_options.py 0000664 0001750 0001750 00000005062 12656517052 017526 0 ustar facundo facundo 0000000 0000000 # Copyright 2016 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Parse fades options from config files."""
import logging
import os
from configparser import ConfigParser, NoSectionError
from fades.helpers import get_confdir
logger = logging.getLogger(__name__)
CONFIG_FILES = ("/etc/fades/fades.ini", os.path.join(get_confdir(), 'fades.ini'), ".fades.ini")
MERGEABLE_CONFIGS = ("dependency", "pip_options", "virtualenv-options")
def options_from_file(args):
"""Get a argparse.Namespace and return it updated with options from config files.
Config files will be parsed with priority equal to his order in CONFIG_FILES.
"""
logger.debug("updating options from config files")
updated_from_file = []
for config_file in CONFIG_FILES:
logger.debug("updating from: %s", config_file)
parser = ConfigParser()
parser.read(config_file)
try:
items = parser.items('fades')
except NoSectionError:
continue
for config_key, config_value in items:
if config_value in ['true', 'false']:
config_value = config_value == 'true'
if config_key in MERGEABLE_CONFIGS:
current_value = getattr(args, config_key, [])
if current_value is None:
current_value = []
current_value.append(config_value)
setattr(args, config_key, current_value)
if not getattr(args, config_key, False) or config_key in updated_from_file:
# By default all 'store-true' arguments are False. So we only
# override them if they are False. If they are True means that the
# user is setting those on the CLI.
setattr(args, config_key, config_value)
updated_from_file.append(config_key)
logger.debug("updating %s to %s from file settings", config_key, config_value)
return args
fades-5/fades/helpers.py 0000664 0001750 0001750 00000015771 12656517052 016506 0 ustar facundo facundo 0000000 0000000 # Copyright 2014-2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""A collection of utilities for fades."""
import os
import sys
import json
import logging
import subprocess
from urllib import request
from urllib.error import HTTPError
import pkg_resources
logger = logging.getLogger(__name__)
SHOW_VERSION_CMD = """
import sys, json
d = dict(path=sys.executable)
d.update(zip('major minor micro releaselevel serial'.split(), sys.version_info))
print(json.dumps(d))
"""
BASE_PYPI_URL = 'https://pypi.python.org/pypi/{name}/json'
STDOUT_LOG_PREFIX = ":: "
class ExecutionError(Exception):
"""Execution of subprocess ended not in 0."""
def __init__(self, retcode, cmd, collected_stdout):
"""Init."""
self._retcode = retcode
self._cmd = cmd
self._collected_stdout = collected_stdout
super().__init__()
def dump_to_log(self, logger):
"""Send the cmd info and collected stdout to logger."""
logger.error("Execution ended in %s for cmd %s", self._retcode, self._cmd)
for line in self._collected_stdout:
logger.error(STDOUT_LOG_PREFIX + line)
def logged_exec(cmd):
"""Execute a command, redirecting the output to the log."""
logger = logging.getLogger('fades.exec')
logger.debug("Executing external command: %r", cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout = []
for line in p.stdout:
line = line[:-1].decode("utf8")
stdout.append(line)
logger.debug(STDOUT_LOG_PREFIX + line)
retcode = p.wait()
if retcode:
raise ExecutionError(retcode, cmd, stdout)
return stdout
def get_basedir():
"""Get the base fades directory, from xdg or kinda hardcoded."""
try:
from xdg import BaseDirectory # NOQA
return os.path.join(BaseDirectory.xdg_data_home, 'fades')
except ImportError:
logger.debug("Package xdg not installed; using ~/.fades folder")
from os.path import expanduser
return expanduser("~/.fades")
def get_confdir():
"""Get the config fades directory, from xdg or kinda hardcoded."""
try:
from xdg import BaseDirectory # NOQA
return os.path.join(BaseDirectory.xdg_config_home, 'fades')
except ImportError:
logger.debug("Package xdg not installed; using ~/.fades folder")
from os.path import expanduser
return expanduser("~/.fades")
def _get_interpreter_info(interpreter=None):
"""Return the interpreter's full path using pythonX.Y format."""
if interpreter is None:
# If interpreter is None by default returns the current interpreter data.
major, minor = sys.version_info[:2]
executable = sys.executable
else:
args = [interpreter, '-c', SHOW_VERSION_CMD]
try:
requested_interpreter_info = logged_exec(args)
except Exception as error:
logger.error("Error getting requested interpreter version: %s", error)
exit()
requested_interpreter_info = json.loads(requested_interpreter_info[0])
executable = requested_interpreter_info['path']
major = requested_interpreter_info['major']
minor = requested_interpreter_info['minor']
if executable[-1].isdigit():
executable = executable.split(".")[0][:-1]
interpreter = "{}{}.{}".format(executable, major, minor)
return interpreter
def get_interpreter_version(requested_interpreter):
"""Return a 'sanitized' interpreter and indicates if it is the current one."""
logger.debug('Getting interpreter version for: %s', requested_interpreter)
current_interpreter = _get_interpreter_info()
logger.debug('Current interpreter is %s', current_interpreter)
if requested_interpreter is None:
return(current_interpreter, True)
else:
requested_interpreter = _get_interpreter_info(requested_interpreter)
is_current = requested_interpreter == current_interpreter
logger.debug('Interpreter=%s. It is the same as fades?=%s',
requested_interpreter, is_current)
return (requested_interpreter, is_current)
def get_latest_version_number(project_name):
"""Return latest version of a package."""
try:
raw = request.urlopen(BASE_PYPI_URL.format(name=project_name)).read()
except HTTPError as error:
logger.warning("Network error. Error: %s", error)
raise error
try:
data = json.loads(raw.decode("utf8"))
latest_version = data["info"]["version"]
return latest_version
except (KeyError, ValueError) as error: # malformed json or empty string
logger.error("Could not get the version of the package. Error: %s", error)
raise error
def check_pypi_updates(dependencies):
"""Return a list of dependencies to upgrade."""
dependencies_up_to_date = []
for dependency in dependencies.get('pypi', []):
# get latest version from PyPI api
try:
latest_version = get_latest_version_number(dependency.project_name)
except Exception as error:
logger.warning("--check-updates command will be aborted. Error: %s", error)
return dependencies
# get required version
required_version = None
if dependency.specs:
_, required_version = dependency.specs[0]
if required_version:
dependencies_up_to_date.append(dependency)
if latest_version > required_version:
logger.info("There is a new version of %s: %s",
dependency.project_name, latest_version)
elif latest_version < required_version:
logger.warning("The requested version for %s is greater "
"than latest found in PyPI: %s",
dependency.project_name, latest_version)
else:
logger.info("The requested version for %s is the latest one in PyPI: %s",
dependency.project_name, latest_version)
else:
project_name_plus = "{}=={}".format(dependency.project_name, latest_version)
dependencies_up_to_date.append(pkg_resources.Requirement.parse(project_name_plus))
logger.info("There is a new version of %s: %s and will use it.",
dependency.project_name, latest_version)
dependencies["pypi"] = dependencies_up_to_date
return dependencies
fades-5/fades/parsing.py 0000664 0001750 0001750 00000014436 12610322506 016470 0 ustar facundo facundo 0000000 0000000 # Copyright 2014, 2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Script parsing to get needed dependencies."""
import logging
import re
from pkg_resources import parse_requirements
from fades import REPO_PYPI
from fades.pkgnamesdb import PKG_NAMES_DB
logger = logging.getLogger(__name__)
def _parse_content(fh):
"""Parse the content of a script to find marked dependencies."""
content = iter(fh)
deps = {}
for line in content:
# quickly discard most of the lines
if 'fades' not in line:
continue
# discard other string with 'fades' that isn't a comment
if '#' not in line:
continue
# assure that it's a well commented line and no other stuff
line = line.strip()
import_part, fades_part = line.rsplit("#", 1)
# discard other comments in the same line that aren't for fades
if "fades" not in fades_part:
import_part, fades_part = import_part.rsplit("#", 1)
fades_part = fades_part.strip()
if not fades_part.startswith("fades"):
continue
if not import_part:
# the fades comment was done at the beginning of the line,
# which means that the import info is in the next one
import_part = next(content).strip()
if import_part.startswith('#'):
continue
# get module
import_tokens = import_part.split()
if import_tokens[0] == 'import':
module_path = import_tokens[1]
elif import_tokens[0] == 'from' and import_tokens[2] == 'import':
module_path = import_tokens[1]
else:
logger.warning("Not understood import info: %s", import_tokens)
continue
module = module_path.split(".")[0]
# If fades know the real name of the pkg. Replace it!
if module in PKG_NAMES_DB:
module = PKG_NAMES_DB[module]
# To match the "safe" name that pkg_resources creates:
module = module.replace('_', '-')
# get the fades info
if fades_part.startswith("fades.pypi"):
repo = REPO_PYPI
marked = fades_part[10:].strip()
elif fades_part.startswith("fades") and (len(fades_part) == 5 or fades_part[5] in "<>=! "):
# starts with 'fades' only, and continues with a space or a
# comparison, not a dot, neither other word stuck together
repo = REPO_PYPI
marked = fades_part[5:].strip()
else:
logger.warning("Not understood fades info: %r", fades_part)
continue
if not marked:
# nothing after the pypi token
requirement = module
elif marked[0] in "<>=!":
# the rest is just the version
requirement = module + ' ' + marked
else:
# the rest involves not only a version, but also the project name
requirement = marked
# record the dependency
dependency = list(parse_requirements(requirement))[0]
deps.setdefault(repo, []).append(dependency)
return deps
def _parse_docstring(fh):
"""Parse the docstrings of a script to find marked dependencies."""
find_fades = re.compile(r'\b(fades)\b:').search
for line in fh:
if line.startswith("'"):
quote = "'"
break
if line.startswith('"'):
quote = '"'
break
else:
return {}
if line[1] == quote:
# comment start with triple quotes
endquote = quote * 3
else:
endquote = quote
if endquote in line[len(endquote):]:
docstring_lines = [line[:line.index(endquote)]]
else:
docstring_lines = [line]
for line in fh:
if endquote in line:
docstring_lines.append(line[:line.index(endquote)])
break
docstring_lines.append(line)
docstring_lines = iter(docstring_lines)
for doc_line in docstring_lines:
if find_fades(doc_line):
break
else:
return {}
return _parse_requirement(list(docstring_lines))
def _parse_requirement(iterable):
"""Actually parse the requirements, from file or manually specified."""
deps = {}
for line in iterable:
line = line.strip()
if not line or line[0] == '#':
continue
if "::" in line:
try:
repo_raw, requirement = line.split("::")
repo = {'pypi': REPO_PYPI}[repo_raw]
except:
logger.warning("Not understood dependency: %r", line)
continue
else:
repo = REPO_PYPI
requirement = line
dependency = list(parse_requirements(requirement))[0]
deps.setdefault(repo, []).append(dependency)
return deps
def parse_manual(dependencies):
"""Parse a string and return specified dependencies."""
if dependencies is None:
return {}
return _parse_requirement(dependencies)
def parse_reqfile(filepath):
"""Parse a requirement file and return the indicated dependencies."""
if filepath is None:
return {}
with open(filepath, 'rt', encoding='utf8') as fh:
return _parse_requirement(fh)
def parse_srcfile(filepath):
"""Parse a source file and return its marked dependencies."""
if filepath is None:
return {}
with open(filepath, 'rt', encoding='utf8') as fh:
return _parse_content(fh)
def parse_docstring(filepath):
"""Parse a source file and return its dependencies specified into docstrings."""
if filepath is None:
return {}
with open(filepath, 'rt', encoding='utf8') as fh:
return _parse_docstring(fh)
fades-5/fades/logger.py 0000664 0001750 0001750 00000004063 12637014666 016315 0 ustar facundo facundo 0000000 0000000 # Copyright 2014 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Logging set up."""
import logging
import logging.handlers
FMT_SIMPLE = "*** fades *** %(asctime)s %(levelname)-8s %(message)s"
FMT_DETAILED = "*** fades *** %(asctime)s %(name)-18s %(levelname)-8s %(message)s"
FMT_SYSLOG = "[%(process)d] %(name)-18s %(levelname)-8s %(message)s"
def set_up(verbose, quiet):
"""Set up the logging."""
logger = logging.getLogger('fades')
logger.setLevel(logging.DEBUG)
# select logging level according to user desire; also use a simpler
# formatting for non-verbose logging
if verbose:
log_level = logging.DEBUG
log_format = FMT_DETAILED
elif quiet:
log_level = logging.WARNING
log_format = FMT_SIMPLE
else:
log_level = logging.INFO
log_format = FMT_SIMPLE
# all to the stdout
handler = logging.StreamHandler()
handler.setLevel(log_level)
logger.addHandler(handler)
formatter = logging.Formatter(log_format)
handler.setFormatter(formatter)
# and to the syslog
try:
handler = logging.handlers.SysLogHandler(address='/dev/log')
except:
# silently ignore that the user doesn't have a syslog active; can
# see all the info with "-v" anyway
pass
else:
logger.addHandler(handler)
formatter = logging.Formatter(FMT_SYSLOG)
handler.setFormatter(formatter)
return logger
fades-5/fades/pipmanager.py 0000664 0001750 0001750 00000007426 12643524377 017171 0 ustar facundo facundo 0000000 0000000 # Copyright 2014, 2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Interface to handle pip.
We are not using pip as a API because fades is not running in the same
env that the child program. So we have to call the pip binary that is inside
the created virtualenv.
"""
import os
import logging
from urllib import request
from fades import helpers
logger = logging.getLogger(__name__)
PIP_INSTALLER = "https://bootstrap.pypa.io/get-pip.py"
class PipManager():
"""A manager for all PIP related actions."""
def __init__(self, env_bin_path, pip_installed=False, options=None):
"""Init."""
self.env_bin_path = env_bin_path
self.pip_installed = pip_installed
self.options = options
self.pip_exe = os.path.join(self.env_bin_path, "pip")
basedir = helpers.get_basedir()
self.pip_installer_fname = os.path.join(basedir, "get-pip.py")
def install(self, dependency):
"""Install a new dependency."""
if not self.pip_installed:
logger.info("Need to install a dependency with pip, but no builtin, "
"doing it manually (just wait a little, all should go well)")
self._brute_force_install_pip()
str_dep = str(dependency)
args = [self.pip_exe, "install", str_dep]
if self.options:
for option in self.options:
args.extend(option.split())
logger.info("Installing dependency: %s", str_dep)
try:
helpers.logged_exec(args)
except helpers.ExecutionError as error:
error.dump_to_log(logger)
exit()
except Exception as error:
logger.exception("Error installing %s: %s", str_dep, error)
exit()
def get_version(self, dependency):
"""Return the installed version parsing the output of 'pip show'."""
logger.debug("getting installed version for %s", dependency)
stdout = helpers.logged_exec([self.pip_exe, "show", dependency])
version = [line for line in stdout if line.startswith('Version:')]
if len(version) == 1:
version = version[0].strip().split()[1]
logger.debug("Installed version of %s is: %s", dependency, version)
return version
else:
logger.error('Fades is having problems getting the installed version. '
'Run with -v or check the logs for details')
return ''
def _brute_force_install_pip(self):
"""A brute force install of pip itself."""
if os.path.exists(self.pip_installer_fname):
logger.debug("Using pip installer from %r", self.pip_installer_fname)
else:
logger.debug(
"Installer for pip not found in %r, downloading it", self.pip_installer_fname)
u = request.urlopen(PIP_INSTALLER)
with open(self.pip_installer_fname, 'wb') as fh:
fh.write(u.read())
logger.debug("Installing PIP manually in the virtualenv")
python_exe = os.path.join(self.env_bin_path, "python")
helpers.logged_exec([python_exe, self.pip_installer_fname, '-I'])
self.pip_installed = True
fades-5/README.rst 0000664 0001750 0001750 00000032534 12660636607 015076 0 ustar facundo facundo 0000000 0000000 fades
=====
.. image:: https://travis-ci.org/PyAr/fades.svg?branch=master
:target: https://travis-ci.org/PyAr/fades
.. image:: https://readthedocs.org/projects/fades/badge/?version=latest
:target: http://fades.readthedocs.org/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://badge.fury.io/py/fades.svg
:target: https://badge.fury.io/py/fades
.. image:: https://coveralls.io/repos/PyAr/fades/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/PyAr/fades?branch=master
fades is a system that automatically handles the virtualenvs in the
cases normally found when writing scripts and simple programs, and
even helps to administer big projects.
.. image:: https://raw.githubusercontent.com/PyAr/fades/master/resources/logo256.png
What does it do?
----------------
*fades* will automagically create a new virtualenv (or reuse a previous
created one), installing the necessary dependencies, and execute
your script inside that virtualenv, with the only requirement
of executing the script with *fades* and also marking the required
dependencies.
*(If you don't have a clue why this is necessary or useful, I'd recommend you
to read this small text about* `Python and the Management of Dependencies
`_ *.)*
The first non-option parameter (if any) would be then the child program
to execute, and any other parameters after that are passed as is to that
child script.
*fades* can also be executed without passing a child script to execute:
in this mode it will open a Python interactive interpreter inside the
created/reused virtualenv (taking dependencies from ``--dependency`` or
``--requirement`` options).
How to use it?
==============
When you write an script, you have to take two special measures:
- need to execute it with *fades* (not *python*)
- need to mark those dependencies
At the moment you execute the script, fades will search a
virtualenv with the marked dependencies, if it doesn't exists
fades will create it, and execute the script in that environment.
How to execute the script with fades?
-------------------------------------
You can always call your script directly with fades::
fades myscript.py
However, for you to not forget about fades and to not execute it
directly with python, it's better if you put at the beggining of
the script the indication for the operating system that it should
be executed with fades... ::
#!/usr/bin/fades
...and also set the executable bit in the script::
chmod +x yourscript.py
How to mark the dependencies to be installed?
---------------------------------------------
The procedure to mark a module imported by the script as a *dependency
to be installed by fades* is by using a comment.
This comment will normally be in the same line of the import (recommended,
less confusing and less error prone in the future), but it also can be in
the previous one.
The simplest comment is like::
import somemodule # fades.pypi
from somepackage import othermodule # fades.pypi
The ``fades.pypi`` is mandatory, it may allow more options in the future.
With that comment, *fades* will install automatically in the virtualenv the
``somemodule`` or ``somepackage`` from PyPI.
Also, you can indicate a particular version condition, examples::
import somemodule # fades.pypi == 3
import somemodule # fades.pypi >= 2.1
import somemodule # fades.pypi >=2.1,<2.8,!=2.6.5
Sometimes, the project itself doesn't match the name of the module; in
these cases you can specify the project name (optionally, before the
version)::
import bs4 # fades.pypi beautifulsoup4
import bs4 # fades.pypi beautifulsoup4 == 4.2
Other ways to specify dependencies
----------------------------------
Apart of marking the imports in the source file, there are other ways
to tell *fades* which dependencies to install in the virtualenv.
One way is through command line, passing the ``--dependency`` parameter.
This option can be specified multiple times (once per dependency), and
each time the format is ``repository::dependency``. The dependency may
have versions specifications, and the repository is optional (defaults
to 'pypi').
Other way is to specify the dependencies in a text file, one dependency
per line, with each line having the format previously described for
the ``--dependency`` parameter. This file is then indicated to fades
through the ``--requirement`` parameter.
In case of multiple definitions of the same dependency, command line
overrides everything else, and requirements file overrides what is
specified in the source code.
How to control the virtualenv creation and usage?
-------------------------------------------------
You can influence several details of all the virtualenv related process.
The most important detail is which version of Python will be used in
the virtualenv. Of course, the corresponding version of Python needs to
be installed in your system, but you can control exactly which one to use.
No matter which way you're executing the script (see above), you can
pass a ``-p`` or ``--python`` argument, indicating the Python version to
be used just with the number (``2.7``), the whole name (``python2.7``) or
the whole path (``/usr/bin/python2.7``).
Other detail is the verbosity of *fades* when telling what is doing. By
default, *fades* only will use stderr to tell if a virtualenv is being
created, and to let the user know that is doing an operation that
requires an active network connection (e.g. installing a new dependency).
If you call *fades* with ``-v`` or ``--verbose``, it will send all internal
debugging lines to stderr, which may be very useful if any problem arises.
On the other hand if you pass the ``-q`` or ``--quiet`` parameter, *fades*
will not show anything (unless it has a real problem), so the original
script stderr is not polluted at all.
Sometimes, you want to run a script provided by one of the dependencies
installed into the virtualenv. *fades* supports this via the ``-x`` (
or ``--exec`` argument).
If you want to use IPython shell you need to call *fades* with ``-i`` or
``--ipython`` option. This option will add IPython as a dependency to *fades*
and it will launch this shell instead of the python one.
You can also use ``--system-site-packages`` to create a venv with access to the system libs.
How to deal with packages that are upgraded in PyPI
---------------------------------------------------
When you tell *fades* to create a virtualenv using one dependency and
don't specify a version, it will install the latest one from PyPI.
For example, you do ``fades -d foobar`` and it installs foobar in
version 7. At some point, there is a new version of foobar in PyPI,
version 8, but if do ``fades -d foobar`` it will just reuse previously
created virtualenv, with version 7, not using the new one!
You can tell fades to do otherwise, just do::
fades -d foobar --check-updates
...and *fades* will search updates for the package on PyPI, and as it will
found version 8, will create a new virtualenv using the latest version.
You can even use this parameter when specifying the package version. Say
you call ``fades -d foobar==7``, *fades* will install version 7 no matter
which one is the latest. But if you do::
fades -d foobar==7 --check-updates
...it will still use version 7, but will inform you that a new version
is available!
Under the hood options
----------------------
For particular use cases you can send specifics arguments to ``virtualenv`` or ``pip``. using the
``--virtuaenv-options`` and ``--pip-options``. You have to use that argument for each argument
sent.
Examples:
``fades -d requests --virtualenv-options="--always-copy" --virtualenv-options="--extra-search-dir=/tmp"``
``fades -d requests --pip-options="--index-url="http://example.com"``
Setting options using config files
----------------------------------
You can also configure fades using `.ini` config files. fades will search config files in
`/etc/fades/fades.ini`, the path indicated by `xdg` for your system
(for example `~/config/fades/fades.ini`) and `.fades.ini`.
So you can have different settings at system, user and project level.
With fades installed you can get your config dir running::
python -c "from fades.helpers import get_confdir; print(get_confdir())"
The config files are in `.ini` format. (configparser) and fades will search for a `[fades]` section.
You have to use the same configurations that in the CLI. The only difference is with the config
options with a dash, it has to be replaced with a underscore.::
[fades]
ipython=true
verbose=true
python=python3
check_updates=true
dependency=requests;django>=1.8 # separated by semicolon
There is a little difference in how fades handle these settings: "dependency", "pip-options" and
"virtualenv-options". In these cases you have to use a semicolon separated list.
The most important thing is that these options will be merged. So if you configure in
`/etc/fades/fades.ini` "dependency=requests" you will have requests in all the virtualenvs
created by fades.
How to clean up old virtualenvs?
--------------------------------
When using *fades* virtual environments are something you should not have to think about.
*fades* will do the right thing and create a new virtualenv that matches the required
dependencies. There are cases however when you'll want to do some clean up to remove
unnecessary virtual environments from disk.
By running *fades* with the ``--rm`` argument, *fades* will remove the virtualenv
matching the provided uuid if such a virtualenv exists.
Some command line examples
--------------------------
``fades foo.py --bar``
Executes ``foo.py`` under *fades*, passing the ``--bar`` parameter to the child program, in a virtualenv with the dependencies indicated in the source code.
``fades -v foo.py``
Executes ``foo.py`` under *fades*, showing all the *fades* messages (verbose mode).
``fades -d dependency1 -d dependency2>3.2 foo.py --bar``
Executes ``foo.py`` under *fades* (passing the ``--bar`` parameter to it), in a virtualenv with the dependencies indicated in the source code and also ``dependency1`` and ``dependency2`` (any version > 3.2).
``fades -d dependency1``
Executes the Python interactive interpreter in a virtualenv with ``dependency1`` installed.
``fades -r requirements.txt``
Executes the Python interactive interpreter in a virtualenv after installing there all dependencies taken from the ``requirements.txt`` file.
``fades -d django -x django-admin.py startproject foo``
Uses the ``django-admin.py`` script to start a new project named ``foo``, without having to have django previously installed.
``fades --rm 89a2bf83-c280-4918-a78d-c35506efd69d``
Removes a virtualenv matching the given uuid from disk and cache index.
How to install it
=================
Several instructions to install ``fades`` in different platforms.
Simplest way
------------
In some systems you can install ``fades`` directly, no needing to
install previously any dependency.
If you are in debian unstable or testing, just do:
sudo apt-get install fades
For Arch linux:
yaourt -S fades
Else, keep reading to know how to install the dependencies first, and
``fades`` in your system next.
Dependencies
------------
Fades depends on the ``pkg_resources`` package, that comes in with
``setuptools``. It's installed almost everywhere, but in any case,
you can install it in Ubuntu/Debian with::
apt-get install python3-setuptools
And on Archlinux with::
pacman -S python-setuptools
It also depends on ``python-xdg`` package. This package should be
installed on any GNU/Linux OS wiht a freedesktop.org GUI. However it
is an **optional** dependency.
You can install it in Ubuntu/Debian with::
apt-get install python3-xdg
And on Archlinux with::
pacman -S python-xdg
Fades also needs the `virtualenv ` package to
support different Python versions for child execution. (see `--python` argument.)
For others debian and ubuntu
----------------------------
If you are NOT in debian unstable or testing (if you are, see
above for better instructions), you can use this
`.deb `_.
Download it and install doing::
sudo dpkg -i fades-latest.deb
Using pip if you want
----------------------
::
pip3 install fades
Multiplatform tarball
---------------------
Finally you can always get the multiplatform tarball and install
it in the old fashion way::
wget http://taniquetil.com.ar/fades/fades-latest.tar.gz
tar -xf fades-latest.tar.gz
cd fades-*
sudo ./setup.py install
Can I try it without installing it?
-----------------------------------
Yes! Branch the project and use the executable::
git clone https://github.com/PyAr/fades.git
cd fades
bin/fades your_script.py
Get some help, give some feedback
=================================
You can ask any question or send any recommendation or request to
the `mailing list `_.
Come chat with us on IRC. The #fades channel is located at the `Freenode `_ network.
Also, you can open an issue
`here `_ (please do if you
find any problem!).
Thanks in advance for your time.
Development
===========
See the documentation for detailed instructions about `how to setup everything and
develop fades `_.
fades-5/AUTHORS 0000664 0001750 0001750 00000000240 12465747074 014450 0 ustar facundo facundo 0000000 0000000 Copyright 2014-2015
Facundo Batista
Nicolás Demarchi
Diego Mascialino
fades-5/COPYING 0000664 0001750 0001750 00000104374 12436333657 014444 0 ustar facundo facundo 0000000 0000000
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
fades-5/setup.py 0000775 0001750 0001750 00000005514 12620445633 015113 0 ustar facundo facundo 0000000 0000000 #!/usr/bin/env python3.4
# Copyright 2014, 2015 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Build tar.gz for fades.
Needed packages to run (using Debian/Ubuntu package names):
python3.4
python3-xdg (optional)
python3-pkg-resources
python3-setuptools
"""
import os
import re
import shutil
from distutils.core import setup
from setuptools.command.install import install
def get_version():
"""Retrieves package version from the file."""
with open('fades/_version.py') as fh:
m = re.search("'([^']*)'", fh.read())
if m is None:
raise ValueError("Unrecognized version in 'fades/_version.py'")
return m.groups()[0]
class CustomInstall(install):
"""Custom installation to fix script info and install man."""
def run(self):
"""Run parent install, and then save the man file."""
install.run(self)
# man directory
if not os.path.exists(self._custom_man_dir):
os.makedirs(self._custom_man_dir)
shutil.copy("man/fades.1", self._custom_man_dir)
def finalize_options(self):
"""Alter the installation path."""
install.finalize_options(self)
man_dir = os.path.join(self.prefix, "share", "man", "man1")
# if we have 'root', put the building path also under it (used normally
# by pbuilder)
if self.root is not None:
man_dir = os.path.join(self.root, man_dir[1:])
self._custom_man_dir = man_dir
setup(
name='fades',
version=get_version(),
license='GPL-3',
author='Facundo Batista, Nicolás Demarchi',
author_email='facundo@taniquetil.com.ar, mail@gilgamezh.me',
description=(
'A system that automatically handles the virtualenvs in the cases '
'normally found when writing scripts and simple programs, and '
'even helps to administer big projects.'),
long_description=open('README.rst').read(),
url='https://github.com/PyAr/fades',
packages=["fades"],
scripts=["bin/fades"],
cmdclass={
'install': CustomInstall,
},
install_requires=['setuptools'],
extras_require={
'pyxdg': 'pyxdg',
'virtualenv': 'virtualenv',
'setuptools': 'setuptools',
}
)
fades-5/MANIFEST.in 0000664 0001750 0001750 00000000107 12620445633 015125 0 ustar facundo facundo 0000000 0000000 include README.rst
include COPYING
include AUTHORS
include man/fades.1
fades-5/setup.cfg 0000664 0001750 0001750 00000000073 12660652702 015213 0 ustar facundo facundo 0000000 0000000 [egg_info]
tag_date = 0
tag_build =
tag_svn_revision = 0
fades-5/bin/ 0000775 0001750 0001750 00000000000 12660652702 014142 5 ustar facundo facundo 0000000 0000000 fades-5/bin/fades 0000775 0001750 0001750 00000002222 12620445633 015147 0 ustar facundo facundo 0000000 0000000 #!/usr/bin/env python3
#
# Copyright 2014 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
# For further info, check https://github.com/PyAr/fades
"""Script to run the 'fades' utility."""
import os
import sys
# small hack to allow fades to be run directly from the project, using code
# from project itself, not anything already installed in the system
parent_dir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
if os.path.basename(parent_dir) == 'fades':
# inside the project!!
sys.path.insert(0, parent_dir)
from fades import main
main.go(sys.argv)
fades-5/PKG-INFO 0000664 0001750 0001750 00000041565 12660652702 014502 0 ustar facundo facundo 0000000 0000000 Metadata-Version: 1.0
Name: fades
Version: 5
Summary: A system that automatically handles the virtualenvs in the cases normally found when writing scripts and simple programs, and even helps to administer big projects.
Home-page: https://github.com/PyAr/fades
Author: Facundo Batista, Nicolás Demarchi
Author-email: facundo@taniquetil.com.ar, mail@gilgamezh.me
License: GPL-3
Description: fades
=====
.. image:: https://travis-ci.org/PyAr/fades.svg?branch=master
:target: https://travis-ci.org/PyAr/fades
.. image:: https://readthedocs.org/projects/fades/badge/?version=latest
:target: http://fades.readthedocs.org/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://badge.fury.io/py/fades.svg
:target: https://badge.fury.io/py/fades
.. image:: https://coveralls.io/repos/PyAr/fades/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/PyAr/fades?branch=master
fades is a system that automatically handles the virtualenvs in the
cases normally found when writing scripts and simple programs, and
even helps to administer big projects.
.. image:: https://raw.githubusercontent.com/PyAr/fades/master/resources/logo256.png
What does it do?
----------------
*fades* will automagically create a new virtualenv (or reuse a previous
created one), installing the necessary dependencies, and execute
your script inside that virtualenv, with the only requirement
of executing the script with *fades* and also marking the required
dependencies.
*(If you don't have a clue why this is necessary or useful, I'd recommend you
to read this small text about* `Python and the Management of Dependencies
`_ *.)*
The first non-option parameter (if any) would be then the child program
to execute, and any other parameters after that are passed as is to that
child script.
*fades* can also be executed without passing a child script to execute:
in this mode it will open a Python interactive interpreter inside the
created/reused virtualenv (taking dependencies from ``--dependency`` or
``--requirement`` options).
How to use it?
==============
When you write an script, you have to take two special measures:
- need to execute it with *fades* (not *python*)
- need to mark those dependencies
At the moment you execute the script, fades will search a
virtualenv with the marked dependencies, if it doesn't exists
fades will create it, and execute the script in that environment.
How to execute the script with fades?
-------------------------------------
You can always call your script directly with fades::
fades myscript.py
However, for you to not forget about fades and to not execute it
directly with python, it's better if you put at the beggining of
the script the indication for the operating system that it should
be executed with fades... ::
#!/usr/bin/fades
...and also set the executable bit in the script::
chmod +x yourscript.py
How to mark the dependencies to be installed?
---------------------------------------------
The procedure to mark a module imported by the script as a *dependency
to be installed by fades* is by using a comment.
This comment will normally be in the same line of the import (recommended,
less confusing and less error prone in the future), but it also can be in
the previous one.
The simplest comment is like::
import somemodule # fades.pypi
from somepackage import othermodule # fades.pypi
The ``fades.pypi`` is mandatory, it may allow more options in the future.
With that comment, *fades* will install automatically in the virtualenv the
``somemodule`` or ``somepackage`` from PyPI.
Also, you can indicate a particular version condition, examples::
import somemodule # fades.pypi == 3
import somemodule # fades.pypi >= 2.1
import somemodule # fades.pypi >=2.1,<2.8,!=2.6.5
Sometimes, the project itself doesn't match the name of the module; in
these cases you can specify the project name (optionally, before the
version)::
import bs4 # fades.pypi beautifulsoup4
import bs4 # fades.pypi beautifulsoup4 == 4.2
Other ways to specify dependencies
----------------------------------
Apart of marking the imports in the source file, there are other ways
to tell *fades* which dependencies to install in the virtualenv.
One way is through command line, passing the ``--dependency`` parameter.
This option can be specified multiple times (once per dependency), and
each time the format is ``repository::dependency``. The dependency may
have versions specifications, and the repository is optional (defaults
to 'pypi').
Other way is to specify the dependencies in a text file, one dependency
per line, with each line having the format previously described for
the ``--dependency`` parameter. This file is then indicated to fades
through the ``--requirement`` parameter.
In case of multiple definitions of the same dependency, command line
overrides everything else, and requirements file overrides what is
specified in the source code.
How to control the virtualenv creation and usage?
-------------------------------------------------
You can influence several details of all the virtualenv related process.
The most important detail is which version of Python will be used in
the virtualenv. Of course, the corresponding version of Python needs to
be installed in your system, but you can control exactly which one to use.
No matter which way you're executing the script (see above), you can
pass a ``-p`` or ``--python`` argument, indicating the Python version to
be used just with the number (``2.7``), the whole name (``python2.7``) or
the whole path (``/usr/bin/python2.7``).
Other detail is the verbosity of *fades* when telling what is doing. By
default, *fades* only will use stderr to tell if a virtualenv is being
created, and to let the user know that is doing an operation that
requires an active network connection (e.g. installing a new dependency).
If you call *fades* with ``-v`` or ``--verbose``, it will send all internal
debugging lines to stderr, which may be very useful if any problem arises.
On the other hand if you pass the ``-q`` or ``--quiet`` parameter, *fades*
will not show anything (unless it has a real problem), so the original
script stderr is not polluted at all.
Sometimes, you want to run a script provided by one of the dependencies
installed into the virtualenv. *fades* supports this via the ``-x`` (
or ``--exec`` argument).
If you want to use IPython shell you need to call *fades* with ``-i`` or
``--ipython`` option. This option will add IPython as a dependency to *fades*
and it will launch this shell instead of the python one.
You can also use ``--system-site-packages`` to create a venv with access to the system libs.
How to deal with packages that are upgraded in PyPI
---------------------------------------------------
When you tell *fades* to create a virtualenv using one dependency and
don't specify a version, it will install the latest one from PyPI.
For example, you do ``fades -d foobar`` and it installs foobar in
version 7. At some point, there is a new version of foobar in PyPI,
version 8, but if do ``fades -d foobar`` it will just reuse previously
created virtualenv, with version 7, not using the new one!
You can tell fades to do otherwise, just do::
fades -d foobar --check-updates
...and *fades* will search updates for the package on PyPI, and as it will
found version 8, will create a new virtualenv using the latest version.
You can even use this parameter when specifying the package version. Say
you call ``fades -d foobar==7``, *fades* will install version 7 no matter
which one is the latest. But if you do::
fades -d foobar==7 --check-updates
...it will still use version 7, but will inform you that a new version
is available!
Under the hood options
----------------------
For particular use cases you can send specifics arguments to ``virtualenv`` or ``pip``. using the
``--virtuaenv-options`` and ``--pip-options``. You have to use that argument for each argument
sent.
Examples:
``fades -d requests --virtualenv-options="--always-copy" --virtualenv-options="--extra-search-dir=/tmp"``
``fades -d requests --pip-options="--index-url="http://example.com"``
Setting options using config files
----------------------------------
You can also configure fades using `.ini` config files. fades will search config files in
`/etc/fades/fades.ini`, the path indicated by `xdg` for your system
(for example `~/config/fades/fades.ini`) and `.fades.ini`.
So you can have different settings at system, user and project level.
With fades installed you can get your config dir running::
python -c "from fades.helpers import get_confdir; print(get_confdir())"
The config files are in `.ini` format. (configparser) and fades will search for a `[fades]` section.
You have to use the same configurations that in the CLI. The only difference is with the config
options with a dash, it has to be replaced with a underscore.::
[fades]
ipython=true
verbose=true
python=python3
check_updates=true
dependency=requests;django>=1.8 # separated by semicolon
There is a little difference in how fades handle these settings: "dependency", "pip-options" and
"virtualenv-options". In these cases you have to use a semicolon separated list.
The most important thing is that these options will be merged. So if you configure in
`/etc/fades/fades.ini` "dependency=requests" you will have requests in all the virtualenvs
created by fades.
How to clean up old virtualenvs?
--------------------------------
When using *fades* virtual environments are something you should not have to think about.
*fades* will do the right thing and create a new virtualenv that matches the required
dependencies. There are cases however when you'll want to do some clean up to remove
unnecessary virtual environments from disk.
By running *fades* with the ``--rm`` argument, *fades* will remove the virtualenv
matching the provided uuid if such a virtualenv exists.
Some command line examples
--------------------------
``fades foo.py --bar``
Executes ``foo.py`` under *fades*, passing the ``--bar`` parameter to the child program, in a virtualenv with the dependencies indicated in the source code.
``fades -v foo.py``
Executes ``foo.py`` under *fades*, showing all the *fades* messages (verbose mode).
``fades -d dependency1 -d dependency2>3.2 foo.py --bar``
Executes ``foo.py`` under *fades* (passing the ``--bar`` parameter to it), in a virtualenv with the dependencies indicated in the source code and also ``dependency1`` and ``dependency2`` (any version > 3.2).
``fades -d dependency1``
Executes the Python interactive interpreter in a virtualenv with ``dependency1`` installed.
``fades -r requirements.txt``
Executes the Python interactive interpreter in a virtualenv after installing there all dependencies taken from the ``requirements.txt`` file.
``fades -d django -x django-admin.py startproject foo``
Uses the ``django-admin.py`` script to start a new project named ``foo``, without having to have django previously installed.
``fades --rm 89a2bf83-c280-4918-a78d-c35506efd69d``
Removes a virtualenv matching the given uuid from disk and cache index.
How to install it
=================
Several instructions to install ``fades`` in different platforms.
Simplest way
------------
In some systems you can install ``fades`` directly, no needing to
install previously any dependency.
If you are in debian unstable or testing, just do:
sudo apt-get install fades
For Arch linux:
yaourt -S fades
Else, keep reading to know how to install the dependencies first, and
``fades`` in your system next.
Dependencies
------------
Fades depends on the ``pkg_resources`` package, that comes in with
``setuptools``. It's installed almost everywhere, but in any case,
you can install it in Ubuntu/Debian with::
apt-get install python3-setuptools
And on Archlinux with::
pacman -S python-setuptools
It also depends on ``python-xdg`` package. This package should be
installed on any GNU/Linux OS wiht a freedesktop.org GUI. However it
is an **optional** dependency.
You can install it in Ubuntu/Debian with::
apt-get install python3-xdg
And on Archlinux with::
pacman -S python-xdg
Fades also needs the `virtualenv ` package to
support different Python versions for child execution. (see `--python` argument.)
For others debian and ubuntu
----------------------------
If you are NOT in debian unstable or testing (if you are, see
above for better instructions), you can use this
`.deb `_.
Download it and install doing::
sudo dpkg -i fades-latest.deb
Using pip if you want
----------------------
::
pip3 install fades
Multiplatform tarball
---------------------
Finally you can always get the multiplatform tarball and install
it in the old fashion way::
wget http://taniquetil.com.ar/fades/fades-latest.tar.gz
tar -xf fades-latest.tar.gz
cd fades-*
sudo ./setup.py install
Can I try it without installing it?
-----------------------------------
Yes! Branch the project and use the executable::
git clone https://github.com/PyAr/fades.git
cd fades
bin/fades your_script.py
Get some help, give some feedback
=================================
You can ask any question or send any recommendation or request to
the `mailing list `_.
Come chat with us on IRC. The #fades channel is located at the `Freenode `_ network.
Also, you can open an issue
`here `_ (please do if you
find any problem!).
Thanks in advance for your time.
Development
===========
See the documentation for detailed instructions about `how to setup everything and
develop fades `_.
Platform: UNKNOWN
fades-5/man/ 0000775 0001750 0001750 00000000000 12660652702 014145 5 ustar facundo facundo 0000000 0000000 fades-5/man/fades.1 0000664 0001750 0001750 00000013717 12660636607 015330 0 ustar facundo facundo 0000000 0000000 .TH FADES 1
.SH NAME
fades - A system that automatically handles the virtualenvs in the cases normally found when writing scripts and simple programs, and even helps to administer big projects.
.SH SYNOPSYS
.B fades
[\fB-h\fR][\fB--help\fR]
[\fB-V\fR][\fB--version\fR]
[\fB-v\fR][\fB--verbose\fR]
[\fB-q\fR][\fB--quiet\fR]
[\fB-i\fR][\fB--ipython\fR]
[\fB-d\fR][\fB--dependency\fR]
[\fB-r\fR][\fB--requirement\fR]
[\fB-x\fR][\fB--exec\fR]
[\fB-p\fR \fIversion\fR][\fB--python\fR=\fIversion\fR]
[\fB--rm\fR=\fIuuid\fR]
[\fB--system-site-packages\fR]
[\fB--virtualenv-options\fR=\fIoptions\fR]
[\fB--pip-options\fR=\fIoptions\fR]
[\fB--check-updates\fR]
[child_program [child_options]]
\fBfades\fR can be used to execute directly your script, or put it with a #! at your script's beginning.
.SH DESCRIPTION
\fBfades\fR will automagically create a new virtualenv (or reuse a previous created one), installing the necessary dependencies, and execute your script inside that virtualenv, with the only requirement of executing the script with \fBfades\fR and also marking the required dependencies.
The first non-option parameter (if any) would be then the child program to execute, and any other parameters after that are passed as is to that child script.
\fBfades\fR can also be executed without passing a child script to execute: in this mode it will open a Python interactive interpreter inside the created/reused virtualenv (taking dependencies from \fI--dependency\fR or \fI--requirement\fR options).
.SH OPTIONS
.TP
.BR -h ", "--help
Show help about all the parameters and options, and quit.
.TP
.BR -V ", "--version
Show the program version and info about the system, and quit.
.TP
.BR -v ", "--verbose
Send all internal debugging lines to stderr, which may be very useful if any problem arises.
.TP
.BR -q ", " --quiet
Don't show anything (unless it has a real problem), so the original script stderr is not polluted at all.
.TP
.BR -i ", " --ipython
Runs IPython shell instead of python ones.
.TP
.BR -d ", " --dependency
Specify dependencies through command line. This option can be specified multiple times (once per dependency), and each time the format is \fBrepository::dependency\fR. The dependency may have versions specifications, and the repository is optional (defaults to 'pypi'). Examples:
requests
pypi::requests > 2.3
requests<=3
See more examples below for real command line usage explanations.
.TP
.BR -r ", " --requirement
Read the dependencies from a file. Format in each line is the same than dependencies specified with \fI--dependency\fR.
.TP
.BR -p " " \fIversion\fR ", " --python=\fIversion\fR
Select which Python version to be used; the argument can be just the number (2.7), the whole name (python2.7) or the whole path (/usr/bin/python2.7). Of course, the corresponding version of Python needs to be installed in your system.
The dependencies can be indicated in multiple places (in the Python source file, with a comment besides the import, in a \fIrequirements\fRfile, and/or through command line. In case of multiple definitions of the same dependency, command line overrides everything else, and requirements file overrides what is specified in the source code.
.TP
.BR -x ", " --exec
Execute the \fIchild_program\fR inside the virtualenv.
The \fIchild_program\fR \fBmust\fR be found in the virtualenv's \fIbin\fR directory.
.TP
.BR --rm " " \fIuuid\fR
Remove a virtualenv by uuid.
.TP
.BR --system-site-packages ""
Give the virtual environment access to thesystem site-packages dir
.TP
.BR --virtualenv-options=\fIVIRTUALENV_OPTION\fR
Extra options to be supplied to virtualenv. (this option can beused multiple times)
.TP
.BR --pip-options=\fIPIP_OPTION\fR
Extra options to be supplied to pip. (this option can beused multiple times)
.TP
.BR --check-updates
Will check for updates in PyPI to verify if there are new versions for the requested dependencies. If a new version is available for a dependency, it will use it (if the dependency was requested without version) or just inform which new version is available (if the dependency was requested with a specific version).
.SH EXAMPLES
.TP
fades foo.py --bar
Executes foo.py under fades, passing the --bar parameter to the child program, in a virtualenv with the dependencies indicated in the source code.
.TP
fades -v foo.py
Executes foo.py under fades, showing all the fades messages (verbose mode).
.TP
fades -d dependency1 -d dependency2>3.2 foo.py --bar
Executes foo.py under fades (passing the --bar parameter to it), in a virtualenv with the dependencies indicated in the source code and also dependency1 and dependency2 (any version > 3.2).
.TP
fades -d dependency1
Executes the Python interactive interpreter in a virtualenv with dependency1 installed.
.TP
fades -r requirements.txt
Executes the Python interactive interpreter in a virtualenv after installing there all dependencies taken from the requirements.txt file.
.SH USING CONFIGURATION FILES
You can also configure fades using \fB.ini\fR config files. fades will search config files in
\fB/etc/fades/fades.ini\fR, the path indicated by \fBxdg\fR for your system
(for example ~/config/fades/fades.ini) and .fades.ini.
So you can have different settings at system, user and project level.
The config files are in .ini format. (configparser) and fades will search for a [fades] section.
You have to use the same configurations that in the CLI. The only difference is with the config
options with a dash, it has to be replaced with a underscore.
Check http://fades.readthedocs.org/en/latest/readme.html#setting-options-using-config-files for full examples.
.SH SEE ALSO
Development is centralized in https://github.com/PyAr/fades
Check that site for a better explanation of \fBfades\fR usage.
.SH AUTHORS
Facundo Batista, Nicolás Demarchi (see development page for contact info).
.SH LICENSING
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation.
fades-5/fades.egg-info/ 0000775 0001750 0001750 00000000000 12660652702 016146 5 ustar facundo facundo 0000000 0000000 fades-5/fades.egg-info/SOURCES.txt 0000664 0001750 0001750 00000000654 12660652702 020037 0 ustar facundo facundo 0000000 0000000 AUTHORS
COPYING
MANIFEST.in
README.rst
setup.py
bin/fades
fades/__init__.py
fades/__main__.py
fades/_version.py
fades/cache.py
fades/envbuilder.py
fades/file_options.py
fades/helpers.py
fades/logger.py
fades/main.py
fades/parsing.py
fades/pipmanager.py
fades/pkgnamesdb.py
fades.egg-info/PKG-INFO
fades.egg-info/SOURCES.txt
fades.egg-info/dependency_links.txt
fades.egg-info/requires.txt
fades.egg-info/top_level.txt
man/fades.1 fades-5/fades.egg-info/dependency_links.txt 0000664 0001750 0001750 00000000001 12660652702 022214 0 ustar facundo facundo 0000000 0000000
fades-5/fades.egg-info/requires.txt 0000664 0001750 0001750 00000000114 12660652702 020542 0 ustar facundo facundo 0000000 0000000 setuptools
[pyxdg]
pyxdg
[setuptools]
setuptools
[virtualenv]
virtualenv
fades-5/fades.egg-info/top_level.txt 0000664 0001750 0001750 00000000006 12660652702 020674 0 ustar facundo facundo 0000000 0000000 fades
fades-5/fades.egg-info/PKG-INFO 0000664 0001750 0001750 00000041565 12660652702 017256 0 ustar facundo facundo 0000000 0000000 Metadata-Version: 1.0
Name: fades
Version: 5
Summary: A system that automatically handles the virtualenvs in the cases normally found when writing scripts and simple programs, and even helps to administer big projects.
Home-page: https://github.com/PyAr/fades
Author: Facundo Batista, Nicolás Demarchi
Author-email: facundo@taniquetil.com.ar, mail@gilgamezh.me
License: GPL-3
Description: fades
=====
.. image:: https://travis-ci.org/PyAr/fades.svg?branch=master
:target: https://travis-ci.org/PyAr/fades
.. image:: https://readthedocs.org/projects/fades/badge/?version=latest
:target: http://fades.readthedocs.org/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://badge.fury.io/py/fades.svg
:target: https://badge.fury.io/py/fades
.. image:: https://coveralls.io/repos/PyAr/fades/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/PyAr/fades?branch=master
fades is a system that automatically handles the virtualenvs in the
cases normally found when writing scripts and simple programs, and
even helps to administer big projects.
.. image:: https://raw.githubusercontent.com/PyAr/fades/master/resources/logo256.png
What does it do?
----------------
*fades* will automagically create a new virtualenv (or reuse a previous
created one), installing the necessary dependencies, and execute
your script inside that virtualenv, with the only requirement
of executing the script with *fades* and also marking the required
dependencies.
*(If you don't have a clue why this is necessary or useful, I'd recommend you
to read this small text about* `Python and the Management of Dependencies
`_ *.)*
The first non-option parameter (if any) would be then the child program
to execute, and any other parameters after that are passed as is to that
child script.
*fades* can also be executed without passing a child script to execute:
in this mode it will open a Python interactive interpreter inside the
created/reused virtualenv (taking dependencies from ``--dependency`` or
``--requirement`` options).
How to use it?
==============
When you write an script, you have to take two special measures:
- need to execute it with *fades* (not *python*)
- need to mark those dependencies
At the moment you execute the script, fades will search a
virtualenv with the marked dependencies, if it doesn't exists
fades will create it, and execute the script in that environment.
How to execute the script with fades?
-------------------------------------
You can always call your script directly with fades::
fades myscript.py
However, for you to not forget about fades and to not execute it
directly with python, it's better if you put at the beggining of
the script the indication for the operating system that it should
be executed with fades... ::
#!/usr/bin/fades
...and also set the executable bit in the script::
chmod +x yourscript.py
How to mark the dependencies to be installed?
---------------------------------------------
The procedure to mark a module imported by the script as a *dependency
to be installed by fades* is by using a comment.
This comment will normally be in the same line of the import (recommended,
less confusing and less error prone in the future), but it also can be in
the previous one.
The simplest comment is like::
import somemodule # fades.pypi
from somepackage import othermodule # fades.pypi
The ``fades.pypi`` is mandatory, it may allow more options in the future.
With that comment, *fades* will install automatically in the virtualenv the
``somemodule`` or ``somepackage`` from PyPI.
Also, you can indicate a particular version condition, examples::
import somemodule # fades.pypi == 3
import somemodule # fades.pypi >= 2.1
import somemodule # fades.pypi >=2.1,<2.8,!=2.6.5
Sometimes, the project itself doesn't match the name of the module; in
these cases you can specify the project name (optionally, before the
version)::
import bs4 # fades.pypi beautifulsoup4
import bs4 # fades.pypi beautifulsoup4 == 4.2
Other ways to specify dependencies
----------------------------------
Apart of marking the imports in the source file, there are other ways
to tell *fades* which dependencies to install in the virtualenv.
One way is through command line, passing the ``--dependency`` parameter.
This option can be specified multiple times (once per dependency), and
each time the format is ``repository::dependency``. The dependency may
have versions specifications, and the repository is optional (defaults
to 'pypi').
Other way is to specify the dependencies in a text file, one dependency
per line, with each line having the format previously described for
the ``--dependency`` parameter. This file is then indicated to fades
through the ``--requirement`` parameter.
In case of multiple definitions of the same dependency, command line
overrides everything else, and requirements file overrides what is
specified in the source code.
How to control the virtualenv creation and usage?
-------------------------------------------------
You can influence several details of all the virtualenv related process.
The most important detail is which version of Python will be used in
the virtualenv. Of course, the corresponding version of Python needs to
be installed in your system, but you can control exactly which one to use.
No matter which way you're executing the script (see above), you can
pass a ``-p`` or ``--python`` argument, indicating the Python version to
be used just with the number (``2.7``), the whole name (``python2.7``) or
the whole path (``/usr/bin/python2.7``).
Other detail is the verbosity of *fades* when telling what is doing. By
default, *fades* only will use stderr to tell if a virtualenv is being
created, and to let the user know that is doing an operation that
requires an active network connection (e.g. installing a new dependency).
If you call *fades* with ``-v`` or ``--verbose``, it will send all internal
debugging lines to stderr, which may be very useful if any problem arises.
On the other hand if you pass the ``-q`` or ``--quiet`` parameter, *fades*
will not show anything (unless it has a real problem), so the original
script stderr is not polluted at all.
Sometimes, you want to run a script provided by one of the dependencies
installed into the virtualenv. *fades* supports this via the ``-x`` (
or ``--exec`` argument).
If you want to use IPython shell you need to call *fades* with ``-i`` or
``--ipython`` option. This option will add IPython as a dependency to *fades*
and it will launch this shell instead of the python one.
You can also use ``--system-site-packages`` to create a venv with access to the system libs.
How to deal with packages that are upgraded in PyPI
---------------------------------------------------
When you tell *fades* to create a virtualenv using one dependency and
don't specify a version, it will install the latest one from PyPI.
For example, you do ``fades -d foobar`` and it installs foobar in
version 7. At some point, there is a new version of foobar in PyPI,
version 8, but if do ``fades -d foobar`` it will just reuse previously
created virtualenv, with version 7, not using the new one!
You can tell fades to do otherwise, just do::
fades -d foobar --check-updates
...and *fades* will search updates for the package on PyPI, and as it will
found version 8, will create a new virtualenv using the latest version.
You can even use this parameter when specifying the package version. Say
you call ``fades -d foobar==7``, *fades* will install version 7 no matter
which one is the latest. But if you do::
fades -d foobar==7 --check-updates
...it will still use version 7, but will inform you that a new version
is available!
Under the hood options
----------------------
For particular use cases you can send specifics arguments to ``virtualenv`` or ``pip``. using the
``--virtuaenv-options`` and ``--pip-options``. You have to use that argument for each argument
sent.
Examples:
``fades -d requests --virtualenv-options="--always-copy" --virtualenv-options="--extra-search-dir=/tmp"``
``fades -d requests --pip-options="--index-url="http://example.com"``
Setting options using config files
----------------------------------
You can also configure fades using `.ini` config files. fades will search config files in
`/etc/fades/fades.ini`, the path indicated by `xdg` for your system
(for example `~/config/fades/fades.ini`) and `.fades.ini`.
So you can have different settings at system, user and project level.
With fades installed you can get your config dir running::
python -c "from fades.helpers import get_confdir; print(get_confdir())"
The config files are in `.ini` format. (configparser) and fades will search for a `[fades]` section.
You have to use the same configurations that in the CLI. The only difference is with the config
options with a dash, it has to be replaced with a underscore.::
[fades]
ipython=true
verbose=true
python=python3
check_updates=true
dependency=requests;django>=1.8 # separated by semicolon
There is a little difference in how fades handle these settings: "dependency", "pip-options" and
"virtualenv-options". In these cases you have to use a semicolon separated list.
The most important thing is that these options will be merged. So if you configure in
`/etc/fades/fades.ini` "dependency=requests" you will have requests in all the virtualenvs
created by fades.
How to clean up old virtualenvs?
--------------------------------
When using *fades* virtual environments are something you should not have to think about.
*fades* will do the right thing and create a new virtualenv that matches the required
dependencies. There are cases however when you'll want to do some clean up to remove
unnecessary virtual environments from disk.
By running *fades* with the ``--rm`` argument, *fades* will remove the virtualenv
matching the provided uuid if such a virtualenv exists.
Some command line examples
--------------------------
``fades foo.py --bar``
Executes ``foo.py`` under *fades*, passing the ``--bar`` parameter to the child program, in a virtualenv with the dependencies indicated in the source code.
``fades -v foo.py``
Executes ``foo.py`` under *fades*, showing all the *fades* messages (verbose mode).
``fades -d dependency1 -d dependency2>3.2 foo.py --bar``
Executes ``foo.py`` under *fades* (passing the ``--bar`` parameter to it), in a virtualenv with the dependencies indicated in the source code and also ``dependency1`` and ``dependency2`` (any version > 3.2).
``fades -d dependency1``
Executes the Python interactive interpreter in a virtualenv with ``dependency1`` installed.
``fades -r requirements.txt``
Executes the Python interactive interpreter in a virtualenv after installing there all dependencies taken from the ``requirements.txt`` file.
``fades -d django -x django-admin.py startproject foo``
Uses the ``django-admin.py`` script to start a new project named ``foo``, without having to have django previously installed.
``fades --rm 89a2bf83-c280-4918-a78d-c35506efd69d``
Removes a virtualenv matching the given uuid from disk and cache index.
How to install it
=================
Several instructions to install ``fades`` in different platforms.
Simplest way
------------
In some systems you can install ``fades`` directly, no needing to
install previously any dependency.
If you are in debian unstable or testing, just do:
sudo apt-get install fades
For Arch linux:
yaourt -S fades
Else, keep reading to know how to install the dependencies first, and
``fades`` in your system next.
Dependencies
------------
Fades depends on the ``pkg_resources`` package, that comes in with
``setuptools``. It's installed almost everywhere, but in any case,
you can install it in Ubuntu/Debian with::
apt-get install python3-setuptools
And on Archlinux with::
pacman -S python-setuptools
It also depends on ``python-xdg`` package. This package should be
installed on any GNU/Linux OS wiht a freedesktop.org GUI. However it
is an **optional** dependency.
You can install it in Ubuntu/Debian with::
apt-get install python3-xdg
And on Archlinux with::
pacman -S python-xdg
Fades also needs the `virtualenv ` package to
support different Python versions for child execution. (see `--python` argument.)
For others debian and ubuntu
----------------------------
If you are NOT in debian unstable or testing (if you are, see
above for better instructions), you can use this
`.deb `_.
Download it and install doing::
sudo dpkg -i fades-latest.deb
Using pip if you want
----------------------
::
pip3 install fades
Multiplatform tarball
---------------------
Finally you can always get the multiplatform tarball and install
it in the old fashion way::
wget http://taniquetil.com.ar/fades/fades-latest.tar.gz
tar -xf fades-latest.tar.gz
cd fades-*
sudo ./setup.py install
Can I try it without installing it?
-----------------------------------
Yes! Branch the project and use the executable::
git clone https://github.com/PyAr/fades.git
cd fades
bin/fades your_script.py
Get some help, give some feedback
=================================
You can ask any question or send any recommendation or request to
the `mailing list `_.
Come chat with us on IRC. The #fades channel is located at the `Freenode `_ network.
Also, you can open an issue
`here `_ (please do if you
find any problem!).
Thanks in advance for your time.
Development
===========
See the documentation for detailed instructions about `how to setup everything and
develop fades `_.
Platform: UNKNOWN