Proper python package layout

This commit is contained in:
Marcin Kulik
2013-10-05 12:43:53 +02:00
parent 484408b48c
commit f6e9a056b6
38 changed files with 64 additions and 36 deletions

2
.gitignore vendored
View File

@@ -3,3 +3,5 @@ tmp
pkg/*.tar.gz
pkg/*.tar.bz2
pkg/*.zip
*.egg-info
/build

View File

@@ -72,7 +72,7 @@ tmp/asciinema.zip: src/* src/commands/*
test: test-unit test-integration
test-unit:
PYTHONPATH=tests nosetests `find tests -name "*_test.py"`
nosetests
test-integration:
tests/integration.sh

View File

@@ -1,7 +1,7 @@
import sys
from config import Config
from commands.builder import get_command
from .config import Config
from .commands.builder import get_command
def main():
get_command(sys.argv[1:], Config()).execute()

View File

View File

@@ -1,10 +1,10 @@
import getopt
from commands.error import ErrorCommand
from commands.record import RecordCommand
from commands.auth import AuthCommand
from commands.help import HelpCommand
from commands.version import VersionCommand
from .error import ErrorCommand
from .record import RecordCommand
from .auth import AuthCommand
from .help import HelpCommand
from .version import VersionCommand
def get_command(argv, config):

View File

@@ -1,8 +1,8 @@
import subprocess
from recorder import Recorder
from uploader import Uploader
from confirmator import Confirmator
from asciinema.recorder import Recorder
from asciinema.uploader import Uploader
from asciinema.confirmator import Confirmator
class RecordCommand(object):

View File

@@ -1,4 +1,4 @@
from common import VERSION
from asciinema.common import VERSION
class VersionCommand(object):

Binary file not shown.

2
setup.cfg Normal file
View File

@@ -0,0 +1,2 @@
[metadata]
description-file = README.md

24
setup.py Normal file
View File

@@ -0,0 +1,24 @@
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
config = {
'name': 'asciinema',
'version': '0.9.5',
'packages': ['asciinema', 'asciinema.commands'],
'license': 'MIT',
'description': 'Command line recorder for asciinema.org service',
'author': 'Marcin Kulik',
'author_email': 'm@ku1ik.com',
'url': 'http://asciinema.org',
'download_url': 'https://github.com/sickill/asciinema/archive/v0.9.5.tar.gz',
'install_requires': [],
'entry_points': {
'console_scripts': [
'asciinema = asciinema.__main__:main',
],
},
}
setup(**config)

0
tests/__init__.py Normal file
View File

View File

@@ -1,6 +1,6 @@
import re
from commands.auth import AuthCommand
from asciinema.commands.auth import AuthCommand
from test_helper import assert_printed, Test

View File

@@ -1,11 +1,11 @@
from nose.tools import assert_equal
from commands.builder import get_command
from commands.error import ErrorCommand
from commands.record import RecordCommand
from commands.auth import AuthCommand
from commands.help import HelpCommand
from commands.version import VersionCommand
from asciinema.commands.builder import get_command
from asciinema.commands.error import ErrorCommand
from asciinema.commands.record import RecordCommand
from asciinema.commands.auth import AuthCommand
from asciinema.commands.help import HelpCommand
from asciinema.commands.version import VersionCommand
class Config(object):

View File

@@ -4,7 +4,7 @@ import os
import tempfile
import re
from config import Config
from asciinema.config import Config
def create_config(content=None, overrides={}):

View File

@@ -1,6 +1,6 @@
import sys
from confirmator import Confirmator
from asciinema.confirmator import Confirmator
from test_helper import assert_printed, assert_not_printed, Test

View File

@@ -1,6 +1,6 @@
from nose.tools import assert_raises
from commands.error import ErrorCommand
from asciinema.commands.error import ErrorCommand
from test_helper import assert_printed, Test

View File

@@ -1,4 +1,4 @@
from commands.help import HelpCommand
from asciinema.commands.help import HelpCommand
from test_helper import assert_printed, Test

View File

@@ -4,7 +4,7 @@ set -e
test() {
echo "Test: $1"
eval "python2 src $2 >/dev/null || (echo 'failed' && exit 1)"
eval "PYTHONPATH=. python2 -m asciinema $2 >/dev/null || (echo 'failed' && exit 1)"
}
test "help" "-h"

View File

@@ -4,8 +4,8 @@ import pty
from nose.tools import assert_equal
from test_helper import Test
from stdout import Stdout
from pty_recorder import PtyRecorder
from asciinema.stdout import Stdout
from asciinema.pty_recorder import PtyRecorder
class FakeStdout(object):

View File

@@ -2,7 +2,7 @@ import sys
import subprocess
from nose.tools import assert_equal
from commands.record import RecordCommand
from asciinema.commands.record import RecordCommand
from test_helper import assert_printed, assert_not_printed, Test

View File

@@ -1,8 +1,8 @@
from nose.tools import assert_equal
from test_helper import Test
from recorder import Recorder
import timer
from asciinema.recorder import Recorder
import asciinema.timer
class FakePtyRecorder(object):
@@ -28,11 +28,11 @@ class TestRecorder(Test):
def setUp(self):
Test.setUp(self)
self.pty_recorder = FakePtyRecorder()
self.real_timeit = timer.timeit
timer.timeit = lambda c, *args: (123.45, c(*args))
self.real_timeit = asciinema.timer.timeit
asciinema.timer.timeit = lambda c, *args: (123.45, c(*args))
def tearDown(self):
timer.timeit = self.real_timeit
asciinema.timer.timeit = self.real_timeit
def test_record_when_title_and_command_given(self):
recorder = Recorder(self.pty_recorder)

View File

@@ -2,7 +2,7 @@ import time
from nose.tools import assert_equal, assert_raises
from test_helper import Test, FakeClock
from stdout import Stdout, StdoutTiming
from asciinema.stdout import Stdout, StdoutTiming
class TestStdoutTiming(Test):

View File

@@ -2,7 +2,7 @@ import time
from nose.tools import assert_equal
from test_helper import Test, FakeClock
from timer import timeit
from asciinema.timer import timeit
class TestTimer(Test):

View File

@@ -1,5 +1,5 @@
from commands.version import VersionCommand
from common import VERSION
from asciinema.commands.version import VersionCommand
from asciinema.common import VERSION
from test_helper import assert_printed, Test