Source

lukeplant_python / dist.py

Full commit
Luke Plant 0eebbdd 








Luke Plant 923f8c3 
Luke Plant 15abefa 

Luke Plant 923f8c3 
Luke Plant 0eebbdd 




Luke Plant 923f8c3 
Luke Plant 0eebbdd 






Luke Plant 15abefa 
Luke Plant 0eebbdd 

Luke Plant a3b3eaa 
Luke Plant 61f9b5e 

Luke Plant 0eebbdd 

Luke Plant 15abefa 
Luke Plant 923f8c3 


Luke Plant a3b3eaa 

Luke Plant 923f8c3 
Luke Plant 15abefa 
Luke Plant a3b3eaa 



Luke Plant 923f8c3 

Luke Plant 61f9b5e 
Luke Plant 15abefa 
Luke Plant 923f8c3 

Luke Plant a3b3eaa 
#!/usr/bin/python
"""
Creates a source distribution from a project in this tree
"""

import sys
import os
import shutil

THISDIR = os.path.dirname(os.path.abspath(__file__))
TOPDIR = os.path.join(THISDIR, "lukeplant_me_uk")
SETUPDIR = os.path.join(TOPDIR, 'setup')

if len(sys.argv) == 1:
    print """Usage:
    python dist.py <projectname>
    
    where <projectname> is one of:    """
    for d in os.listdir(SETUPDIR):
        if not d.startswith('.') and os.path.isdir(os.path.join(SETUPDIR,d)):
            print "        " + d
    
    print
else:
    d = os.path.join(SETUPDIR, sys.argv[1])
    if not os.path.isdir(d):
        print "'%s' is not a directory in the setup folder." % sys.argv[1]
        exit(1)
    
    manifest_exists = False
    setup_files = ['setup.py', 'MANIFEST.in', 'README', 'AUTHORS']
    for f in setup_files:
        fullpath = os.path.join(d, f)
        if os.path.isfile(fullpath):
            topfile = os.path.join(THISDIR, f)
            if os.path.isfile(topfile):
                os.unlink(topfile)
            shutil.copy(fullpath, topfile)
            if f == "MANIFEST.in":
              manifest_exists = True

    os.chdir(THISDIR)
    if manifest_exists:
        os.system('python setup.py sdist --force-manifest')
    else:
        os.system('python setup.py sdist')
        
    # Cleanup
    for f in setup_files:
        topfile = os.path.join(THISDIR, f)
        if os.path.isfile(topfile):
          os.unlink(topfile)
    if manifest_exists:
        os.unlink('MANIFEST') # created automatically by setup.py