Usage of sdistmaker
=======================

.. :doctest:
.. :setup: sdistmaker.tests.test_setup.setup
.. :teardown: sdistmaker.tests.test_setup.teardown

sdistmaker has two main uses:

- Make and store an sdist tarball of a single tag.

- Go through all tags and ensure they all have an sdist tarball.



Making sdist tarball of a single tag
------------------------------------

    >>> from sdistmaker import maker
    >>> tag = 'http://example.org/repo/project/tags/0.1'

The script makes an svn checkout of the tag and uses setuptools to grab the
name and version and to make an sdist.  This is then copied to the pypi dir in
a subdirectory named after the project.

    >>> output_results[:] = ['',
    ...                      'project',
    ...                      '0.1',
    ...                      '',
    ...                      ]
    >>> maker.main(tag=tag, destination=pypidir)
    Command: svn co http://example.org/repo/project/tags/0.1 ...
    Command: python setup.py --name
    Command: python setup.py --version
    Command: python setup.py sdist
    Mock copy dist/project-0.1.tar.gz -> PYPI/project/project-0.1.tar.gz

A new directory for the project is created:

    >>> import os
    >>> os.listdir(pypidir)
    ['project']

And the tarball is in there:

    >>> sorted(os.listdir(os.path.join(pypidir, 'project')))
    ['project-0.1.tar.gz']

A new release is placed alongside just fine:

    >>> tag = 'http://example.org/repo/project/tags/0.2'
    >>> output_results[:] = ['',
    ...                      'project',
    ...                      '0.2',
    ...                      '',
    ...                      ]
    >>> maker.main(tag=tag, destination=pypidir)
    Command: svn co http://example.org/repo/project/tags/0.2 ...
    Command: python setup.py --name
    Command: python setup.py --version
    Command: python setup.py sdist
    Mock copy dist/project-0.2.tar.gz -> PYPI/project/project-0.2.tar.gz
    >>> os.listdir(pypidir)
    ['project']
    >>> sorted(os.listdir(os.path.join(pypidir, 'project')))
    ['project-0.1.tar.gz', 'project-0.2.tar.gz']

And a second project:

    >>> tag = 'http://example.org/repo/another/tags/0.2'
    >>> output_results[:] = ['',
    ...                      'another',
    ...                      '0.2',
    ...                      '',
    ...                      ]
    >>> maker.main(tag=tag, destination=pypidir)
    Command: svn co http://example.org/repo/another/tags/0.2 ...
    Command: python setup.py --name
    Command: python setup.py --version
    Command: python setup.py sdist
    Mock copy dist/another-0.2.tar.gz -> PYPI/another/another-0.2.tar.gz
    >>> sorted(os.listdir(pypidir))
    ['another', 'project']
    >>> sorted(os.listdir(os.path.join(pypidir, 'project')))
    ['project-0.1.tar.gz', 'project-0.2.tar.gz']
    >>> sorted(os.listdir(os.path.join(pypidir, 'another')))
    ['another-0.2.tar.gz']
