Skip to content

Commit

Permalink
rought concept in fixing symlinks in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ccanepa committed May 26, 2014
1 parent 73d14f8 commit 662f04d
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 7 deletions.
117 changes: 117 additions & 0 deletions nikola/winutils.py
Expand Up @@ -97,3 +97,120 @@ def fix_git_symlinked(src, dst):

# copy original content to filename
shutil.copy(path, filename)


def fix_all_git_symlinked(topdir):
"""inplace conversion of git symlinks to real content
Needed in Windows for .zip downloads or git clones
"""
# list of symlinked files obtained in the git-bash console with
# cd nikola_checkout
# git ls-files -s | awk '/120000/{print $4}'
files_symlinked = """
docs/sphinx/creating-a-site.txt
docs/sphinx/creating-a-theme.txt
docs/sphinx/extending.txt
docs/sphinx/internals.txt
docs/sphinx/manual.txt
docs/sphinx/social_buttons.txt
docs/sphinx/theming.txt
docs/sphinx/upgrading-to-v6.txt
nikola/data/samplesite/stories/creating-a-theme.rst
nikola/data/samplesite/stories/extending.txt
nikola/data/samplesite/stories/internals.txt
nikola/data/samplesite/stories/manual.rst
nikola/data/samplesite/stories/social_buttons.txt
nikola/data/samplesite/stories/theming.rst
nikola/data/samplesite/stories/upgrading-to-v6.txt
nikola/data/themes/base/messages/messages_cz.py
nikola/data/themes/bootstrap-jinja/assets
nikola/data/themes/bootstrap-jinja/bundles
nikola/data/themes/bootstrap/assets/css/colorbox.css
nikola/data/themes/bootstrap/assets/css/images/controls.png
nikola/data/themes/bootstrap/assets/css/images/loading.gif
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-ar.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-bg.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-ca.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-cs.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-da.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-de.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-es.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-et.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-fa.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-fi.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-fr.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-gl.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-gr.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-he.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-hr.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-hu.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-id.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-it.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-ja.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-kr.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-lt.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-lv.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-my.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-nl.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-no.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-pl.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-pt-br.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-ro.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-ru.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-si.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-sk.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-sr.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-sv.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-tr.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-uk.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-zh-CN.js
nikola/data/themes/bootstrap/assets/js/colorbox-i18n/jquery.colorbox-zh-TW.js
nikola/data/themes/bootstrap/assets/js/jquery.colorbox-min.js
nikola/data/themes/bootstrap/assets/js/jquery.colorbox.js
nikola/data/themes/bootstrap/assets/js/jquery.min.js
nikola/data/themes/bootstrap/assets/js/jquery.min.map
nikola/data/themes/bootstrap3-jinja/assets
nikola/data/themes/bootstrap3-jinja/bundles
nikola/data/themes/bootstrap3/assets/css/bootstrap-theme.css
nikola/data/themes/bootstrap3/assets/css/bootstrap-theme.css.map
nikola/data/themes/bootstrap3/assets/css/bootstrap-theme.min.css
nikola/data/themes/bootstrap3/assets/css/bootstrap.css
nikola/data/themes/bootstrap3/assets/css/bootstrap.css.map
nikola/data/themes/bootstrap3/assets/css/bootstrap.min.css
nikola/data/themes/bootstrap3/assets/fonts/glyphicons-halflings-regular.eot
nikola/data/themes/bootstrap3/assets/fonts/glyphicons-halflings-regular.svg
nikola/data/themes/bootstrap3/assets/fonts/glyphicons-halflings-regular.ttf
nikola/data/themes/bootstrap3/assets/fonts/glyphicons-halflings-regular.woff
nikola/data/themes/bootstrap3/assets/js/bootstrap.js
nikola/data/themes/bootstrap3/assets/js/bootstrap.min.js
"""
import time
relnames = files_symlinked.split('\n')
relnames = [ name.strip().replace('/', '\\') for name in relnames ]
relnames = [ name for name in relnames if name ]
for name in relnames:
dst = os.path.join(topdir, name)
print("name:", name)
print("dst:", dst)
with open(os.path.join(topdir, dst), 'r') as f:
text = f.read()
dst_dir = os.path.dirname(dst)
src = os.path.normpath(os.path.join(dst_dir, text))
print("src:", src)
# copied with retry because even with the AV disabled got
# a fail with "permission denied", usually first in
# nikola/data/themes/bootstrap3-jinja/assets
copied = False
for i in range(3):
try:
shutil.copy(src, dst)
copied = True
break
except Exception:
time.sleep(1)
if not copied:
print("*** copy failed for")
print("\t dst:", dst)
print("\t src:", src)

12 changes: 5 additions & 7 deletions setup.py
Expand Up @@ -12,7 +12,7 @@
import subprocess
import sys
import shutil

import time
from setuptools import setup
from setuptools.command.install import install
from setuptools.command.test import test as TestCommand
Expand Down Expand Up @@ -85,7 +85,6 @@ def copy_symlinked_for_windows():
After install the WC will be dirty (symlink markers rewroted with real
content)
"""

# essentially nikola.utils.should_fix_git_symlinked inlined, to not
# fiddle with sys.path / import unless really needed
if sys.platform != 'win32':
Expand All @@ -101,16 +100,15 @@ def copy_symlinked_for_windows():
return

# apply the fix
localdir = os.path.dirname(__file__)
dst = os.path.join(localdir, 'nikola', 'data', 'samplesite')
src = dst
localdir = os.path.dirname(os.path.abspath(__file__))
print("localdir:", localdir)
oldpath = sys.path[:]
sys.path.insert(0, os.path.join(localdir, 'nikola'))
winutils = __import__('winutils')
winutils.fix_git_symlinked(src, dst)
winutils.fix_all_git_symlinked(localdir)
sys.path = oldpath
del sys.modules['winutils']
print('WARNING: your working copy is now dirty by changes in samplesite')
print('WARNING: your working copy is now dirty by changes in samplesite, sphinx and themes')


def install_manpages(root, prefix):
Expand Down

0 comments on commit 662f04d

Please sign in to comment.