From ff76e737d09f80fd4652a58996765492d1b5e3bc Mon Sep 17 00:00:00 2001 From: rowanG077 Date: Thu, 10 Oct 2019 12:31:28 +0200 Subject: [PATCH] - Fixed bug where package wouldn't run on windows with python 3 due to unicode incompatability. --- setup.py | 4 ++-- shell.nix | 8 ++++++++ sphinx_multibuild/sphinx_multibuild.py | 12 ++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 shell.nix diff --git a/setup.py b/setup.py index b8181ab..594d0ce 100644 --- a/setup.py +++ b/setup.py @@ -13,14 +13,14 @@ setup( name='sphinx-multibuild', packages=['sphinx_multibuild'], - version='1.2.0', + version='1.2.1', description='Allow sphinx to build with multiple source directories and watch for changes.', long_description=long_description, long_description_content_type='text/x-rst', author='Rowan Goemans', author_email='goemansrowan@gmail.com', url='https://github.com/rowanG077/sphinx-multibuild', - download_url='https://github.com/rowanG077/sphinx-multibuild/archive/1.2.0.tar.gz', + download_url='https://github.com/rowanG077/sphinx-multibuild/archive/1.2.1.tar.gz', keywords=['sphinx', 'autobuild', 'multiple-directories'], license='MIT', classifiers=[ diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..99b8253 --- /dev/null +++ b/shell.nix @@ -0,0 +1,8 @@ +with import {}; +with python27Packages; + +buildPythonPackage rec { + name = "mypackage"; + src = ./sphinx_multibuild; + propagatedBuildInputs = [ setuptools wheel watchdog sphinx ]; +} diff --git a/sphinx_multibuild/sphinx_multibuild.py b/sphinx_multibuild/sphinx_multibuild.py index e23323c..2b8517e 100644 --- a/sphinx_multibuild/sphinx_multibuild.py +++ b/sphinx_multibuild/sphinx_multibuild.py @@ -55,6 +55,10 @@ def wait(self, **kwargs): class _SymlinkShim(object): def __init__(self): if os.name == 'nt': + # python3 doesn't have unicode function. + # It simple uses str + to_unicode = str if sys.version_info[0] == 3 else unicode + import ctypes win = ctypes.windll @@ -64,7 +68,7 @@ def win32_create_symlink(src, dst): flags = 1 if src is not None and os.path.isdir(src) else 0 flags = flags | 2 res = win.kernel32.CreateSymbolicLinkW( - unicode(dst), unicode(src), flags) + to_unicode(dst), to_unicode(src), flags) if not res: raise OSError(str(win.kernel32.GetLastError())) @@ -74,7 +78,7 @@ def win32_is_symlink(path): FILE_ATTRIBUTE_REPARSE_POINT = 0x0400 attributes = win.kernel32.GetFileAttributesW( - unicode(path)) + to_unicode(path)) return (attributes & FILE_ATTRIBUTE_REPARSE_POINT) > 0 def win32_unlink(path): @@ -237,6 +241,8 @@ def __init__(self, args, build_event, logger): else: self._args = [sys.executable, '-msphinx'] + args + print(self._args) + self._build_event = build_event self._logger = logger self._builder_thread = threading.Thread(target=self._builder) @@ -302,6 +308,7 @@ def __init__(self, input_paths[i] = os.path.normpath(os.path.abspath(e)) # create the sphinx builder and the directory observers. + print("1") self._changed_event = _BufferedEvent(1) self._builder = _SphinxBuilder(sphinx_args, self._changed_event, self._logger) @@ -313,6 +320,7 @@ def __init__(self, self._observer = Observer() for h in self._handlers: self._observer.schedule(h, h.source_dir, recursive=True) + print("2") def _mkdir_p(self, path): try: