Commit 5586cc2e authored by Denis Bilenko's avatar Denis Bilenko

update util/makedist.py to work with git

parent f9105889
......@@ -15,8 +15,7 @@ If --revert is provided, then copying is done and then changes are reverted.
import sys
import os
import glob
import optparse
from os.path import exists, join, dirname, abspath, basename
from os.path import exists, join, abspath, basename
from pipes import quote
......@@ -55,13 +54,10 @@ def makedist(*args, **kwargs):
os.chdir(cwd)
def _makedist(version='dev', fast=False, revert=False):
def _makedist(version='dev'):
assert exists('gevent/__init__.py'), 'Where am I?'
basedir = abspath(os.getcwd())
if revert:
fast = True
if version.lower() == 'dev':
set_version_command = 'util/set_version.py gevent/__init__.py'
else:
......@@ -72,39 +68,14 @@ def _makedist(version='dev', fast=False, revert=False):
os.mkdir(TMPDIR)
os.chdir(TMPDIR)
if fast:
# -l option is nice but does not work on mac
system('cp -a %s .' % basedir)
else:
system('hg clone %s gevent' % basedir)
system('git clone %s gevent' % basedir)
directory = os.listdir('.')
assert len(directory) == 1, directory
os.chdir(directory[0])
if fast:
system('rm -fr build doc/_build dist')
status_command = 'hg status --ignored'
if revert:
status_command += ' --modified --added --unknown'
for status, name in iter_status(status_command):
if name not in useful_files:
os.unlink(name)
if revert:
system('hg revert -a')
for root, dirs, files in os.walk('.', topdown=False):
if not dirs and not files:
print 'Removing empty directory %r' % root
os.rmdir(root)
system(set_version_command)
if revert or not fast:
system('hg diff', noisy=False)
system('git diff', noisy=False)
system('python setup.py -q sdist')
dist_filename = glob.glob('dist/gevent-*.tar.gz')
......@@ -112,11 +83,6 @@ def _makedist(version='dev', fast=False, revert=False):
dist_path = abspath(dist_filename[0])
dist_filename = basename(dist_path)
website_dist_dir = join(dirname(basedir), 'gevent-website', 'dist')
if exists(website_dist_dir):
copy(dist_path, join(website_dist_dir, dist_filename))
if not exists(join(basedir, 'dist')):
os.mkdir(join(basedir, 'dist'))
......@@ -125,34 +91,18 @@ def _makedist(version='dev', fast=False, revert=False):
def main():
parser = optparse.OptionParser()
parser.add_option('--fast', action='store_true', help='Rather than cloning the repo, hard link the files in it')
parser.add_option('--revert', action='store_true', help='Same as --fast, but also do "hg revert -a" before start')
options, args = parser.parse_args()
if options.revert:
options.fast = True
args = sys.argv[1:]
if len(args) != 1:
sys.exit('Expected one argument: version (could be "dev").')
return makedist(args[0], fast=options.fast, revert=options.revert)
return makedist(args[0])
def copy(source, dest):
system('cp -a %s %s' % (quote(source), quote(dest)))
def unlink(path):
try:
os.unlink(path)
except OSError, ex:
if ex.errno == 2: # No such file or directory
return False
raise
return True
def mkdir(path):
try:
os.mkdir(path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment