Coder Social home page Coder Social logo

pycontribs / rtox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dolph/rtox

7.0 4.0 3.0 149 KB

Develop locally, run tox remotely. This fork is the officially maintained version that is released on PYPI.

Home Page: https://pypi.org/project/rtox/

License: Apache License 2.0

Python 99.64% Makefile 0.36%
tox python untox ssh

rtox's Introduction

image

rtox

This project represents an experimental development workflow with the following considerations in mind:

  • tox is an excellent tool for managing test activities in a virtualenv.
  • Servers in the cloud are faster and far more powerful than my local development environment (usually a laptop).
  • Latency introduced to the command line by a remote connection, especially on bad WiFi, is painful.
  • Running huge test suites on a cloud server doesn't drain my laptop's battery (or spin up my desktop's fans) like running them locally would.
  • Your local development platform might not actually have the binary dependencies available that your project requires from your target platform (developing a Linux application on OS X, for example).
  • Running tests with tox is easy. Running tests with rtox on a remote host against the local codebase should be just as easy.

This project currently makes a few assumptions that you'd have to meet for it to be useful to you:

  • You're a Python developer (that's why you're interested in tox, right?).
  • You're using git.
  • You're working on a publicly available repository (I'd like to break this assumption).

Usage

Configure rtox with an .rtox.cfg file like the following:

[ssh]
user = root
hostname = localhost
port = 22

rtox will look for config file in current folder or its parents and use ~/.rtox.cfg as fallback. This allows user to have different configs for different projects or groups of projects.

rtox simply needs to be pointed at an SSH host with git, tox and virtualenv installed.

Once it's configured, just use rtox in place of tox. For example:

$ rtox -e py27 -e pep8

The state of your local codebase will be mirrored to the remote host, and tox will be executed there.

untox

Untox is a small script that obliterates any tox.ini commands that are installing python packages inside the virtualenv, removing sepctions like deps, pip install ..., truncating requirements.txt files and enabling sitepackages = True on all tox environments.

Its purpose is to enable testing of python code with only system packages, something that may be desired by those that are planning to ship these modules as RPMs, DEBs.

untox script is installed as a command alongside rtox and once called it expectes to find a tox.ini in current folder. Be warned that changes are made in-place without any backup.

You also have the option to call rtox --untox ... which will run untox on the remote system after doing the rsync and before running tox. This option is handy as it keeps the local repository untoched.

rtox's People

Contributors

dolph avatar ssbarnea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rtox's Issues

AttributeError: 'module' object has no attribute 'GSSException'

On some systems user may encounter this error:

Traceback (most recent call last):
File "/root/.rtox/35de9b7012c84f0cbd3609eac8891b4fe532b180/.tox/py36/bin/rtox", line 6, in <module>
from rtox.rtox import cli
File "/root/.rtox/35de9b7012c84f0cbd3609eac8891b4fe532b180/rtox/rtox.py", line 23, in <module>
import paramiko
File "/usr/lib/python2.7/site-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 38, in <module>
from paramiko.auth_handler import AuthHandler
File "/usr/lib/python2.7/site-packages/paramiko/auth_handler.py", line 48, in <module>
from paramiko.ssh_gss import GSSAuth, GSS_EXCEPTIONS
File "/usr/lib/python2.7/site-packages/paramiko/ssh_gss.py", line 54, in <module>
GSS_EXCEPTIONS = (gssapi.GSSException,)
AttributeError: 'module' object has no attribute 'GSSException'

It seems that the workaround for this is to install python-gssapi which is not installed by paramiko.

integrate bindep.txt support

When bindep.txt is detected, rtox should attempt to run bindep on remote machine in order to install binary dependencies before running tox command.

adopt use of fabric instead of ssh subprocess

Using Fabric instead of running ssh as a subprocess should make the tool usage more reliable, especially because this would allow a better control over the way stderr and stdin are used.

For example in current implementation stderr messages from remote machine endup in stdout.

PS. Implementing this feature should not require any API changes, this being just an implementation detail.

travis gate

rtox project should gate a testing gate on travis, so we know that new changes are not breaking behavior

rtox.cfg file location should be flexible

At this moment .rtox.cfg can be loaded only from $HOME folder but the tools should look for it starting from current folder upwards and to fall back to $HOME as last resort, just like other similar tools (tox, ansible, ...)

This is an important feature that would allow user to configure prefered remote by project or group of projects instead of only a single one for the current user.

target_folder - TypeError: Unicode-objects must be encoded before hashing

~/python-cozify.git %> rtox -e py35 -e pep8
Traceback (most recent call last):
File "/usr/local/bin/rtox", line 11, in
sys.exit(cli())
File "/usr/local/lib/python3.5/dist-packages/rtox/rtox.py", line 199, in cli
target_folder = hashlib.sha1(repo).hexdigest()
TypeError: Unicode-objects must be encoded before hashing

%> python3 -V
Python 3.5.2

%> cat ~/.rtox.cfg
[ssh]
user = root
hostname = vps
port = 22

Repo in question: https://github.com/Artanicus/python-cozify/tree/devel

integrate untox into rtox

Untox is a small python script that removes any package installation commands from inside tox.ini files in order to run testing using python system packages, something that is needed by those preparing to repackage python packages for specific platforms (RPMs, DEBs,....).

As part of this ticket:

  • untox cli should be installed, so user can call it manually
  • a --untox argument should be added to rtox which will tell it to run untox on remote system before running the tox command.
  • assure that untox unittests are integrated into rtox test suite.

Untox source code can be found at https://github.com/ssbarnea/toolset

improve console output (logging)

Instead of using print() statements rtox should using python logging.

Also, we need to assure that rtox displays

  • remote machine name and user when connecting to it
  • full path to the config file that was loaded

random: ERROR: Error creating virtualenv. Note that some special characters

I observed that if the remote machine has pyenv installed, running rtox is likely to fail in a very weird mode.

This error seems to be flaky with ~ โ…“ chances of happening. Reproduced locally on MacOS host with CentOS remote but also on Travis.

$ rtox                                                                                                                                                                                          [21:27:35]
Syncing the local repository to the remote host...
docs recreate: /root/.rtox/e9c7053ae04d70450e64e7c4cb238a3a9c0e9796/.tox/docs
No handlers could be found for logger "tox_pyenv"
ERROR: invocation failed (exit code 1), logfile: /root/.rtox/e9c7053ae04d70450e64e7c4cb238a3a9c0e9796/.tox/docs/log/docs-0.log
ERROR: actionid: docs
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python', 'docs']

Already using interpreter /usr/bin/python
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 2328, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 713, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 925, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1132, in install_python
    copy_required_modules(home_dir, symlink)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1063, in copy_required_modules
    copyfile(filename, dst_filename, symlink)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 354, in copyfile
    copyfileordir(src, dest, symlink)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 331, in copyfileordir
    shutil.copy2(src, dest)
  File "/usr/lib64/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/usr/lib64/python2.7/shutil.py", line 69, in copyfile
    raise Error("`%s` and `%s` are the same file" % (src, dst))
shutil.Error: `/usr/lib64/python2.7/UserDict.py` and `/root/.rtox/e9c7053ae04d70450e64e7c4cb238a3a9c0e9796/.tox/docs/lib64/python2.7/UserDict.py` are the same file

ERROR: Error creating virtualenv. Note that some special characters (e.g. ':' and unicode symbols) in paths are not supported by virtualenv. Error details: InvocationError('/usr/bin/python -m virtualenv --python /usr/bin/python docs (see /root/.rtox/e9c7053ae04d70450e64e7c4cb238a3a9c0e9796/.tox/docs/log/docs-0.log)', 1)

I mention that I did run tox manually on remote machine and it works well, even from the save folder as the one created by rtox.

Also, I was not able to reproduce when specifying the target environment instead of trying the entire envlist.

Related

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.