Skip to content

Commit

Permalink
Merge pull request #328 from arista-eosplus/RTD-fix
Browse files Browse the repository at this point in the history
Fix setup.py install paths when on ReadTheDocs
  • Loading branch information
phil-dileo committed Oct 5, 2015
2 parents c9e1632 + 4c2c529 commit 062ddec
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def install():
def join_url(x, y):
return '/' + '/'.join([z for z in x.split('/') + y.split('/') if z])

def ensure_dir(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)

conf_path = config.CONF_PATH
install_path = config.INSTALL_PATH

Expand All @@ -64,6 +69,7 @@ def join_url(x, y):
print 'Customizing install for ReadTheDocs.org build servers...'
conf_path = '.' + conf_path
install_path = '.' + install_path
os.environ['ZTPS_INSTALL_ROOT'] = '.'
from subprocess import call
call(['docs/setup_rtd_files.sh'])
packages.append('client')
Expand All @@ -75,7 +81,7 @@ def join_url(x, y):

install_requirements = open('requirements.txt').read().split('\n')
install_requirements = [x.strip() for x in install_requirements
if x.strip() and
if x.strip() and
'dev only' not in x]
version = open('VERSION').read().split()[0].strip()

Expand All @@ -89,8 +95,8 @@ def join_url(x, y):
os.remove(path)
data_files += [(path, [])]

for (filename, dst, src) in [('neighbordb',
install_path,
for (filename, dst, src) in [('neighbordb',
install_path,
'conf/neighbordb'),
('bootstrap.conf',
'%s/bootstrap' % install_path,
Expand All @@ -104,7 +110,7 @@ def join_url(x, y):
file_path = '%s/%s' % (dst, filename)
if install() and os.path.exists(file_path):
if os.path.isdir(file_path):
shutil.rmtree(file_path,
shutil.rmtree(file_path,
ignore_errors=True)
else:
# do this manually
Expand All @@ -115,7 +121,7 @@ def join_url(x, y):

# bootstrap file, libraries, VERSION, plugins and actions are
# always overwritten
file_list = [('bootstrap', '%s/bootstrap' % install_path,
file_list = [('bootstrap', '%s/bootstrap' % install_path,
'client/bootstrap')]
for filename in glob('actions/*'):
file_list += [(filename.split('/')[-1],
Expand All @@ -133,7 +139,7 @@ def join_url(x, y):
file_path = '%s/%s' % (dst, filename)
if install() and os.path.exists(file_path) and \
os.path.isdir(file_path):
shutil.rmtree(file_path,
shutil.rmtree(file_path,
ignore_errors=True)
data_files += [(dst, glob(src))]

Expand All @@ -157,6 +163,8 @@ def join_url(x, y):
if install():
custom_path = os.environ.get('ZTPS_INSTALL_ROOT')
if custom_path:
shutil.copy('VERSION', join_url(custom_path, config.VERSION_FILE_PATH))
else:
shutil.copy('VERSION', config.VERSION_FILE_PATH)
version_file = join_url(custom_path, config.VERSION_FILE_PATH)[1:]
else:
version_file = config.VERSION_FILE_PATH
ensure_dir(version_file)
shutil.copy('VERSION', version_file)

0 comments on commit 062ddec

Please sign in to comment.