Skip to content

Commit

Permalink
- Fixed bug where package wouldn't run on windows with python 3 due t…
Browse files Browse the repository at this point in the history
…o unicode incompatability.
  • Loading branch information
rowanG077 committed Oct 10, 2019
1 parent 63802f5 commit ff76e73
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
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=[
Expand Down
8 changes: 8 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
with import <nixpkgs> {};
with python27Packages;

buildPythonPackage rec {
name = "mypackage";
src = ./sphinx_multibuild;
propagatedBuildInputs = [ setuptools wheel watchdog sphinx ];
}
12 changes: 10 additions & 2 deletions sphinx_multibuild/sphinx_multibuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()))

Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit ff76e73

Please sign in to comment.