gitless icon indicating copy to clipboard operation
gitless copied to clipboard

Windows support

Open spderosso opened this issue 11 years ago • 36 comments

spderosso avatar Jan 16 '14 23:01 spderosso

is windows support off the table or just pushed further back on the roadmap? while pygit2 is - at least for anaconda users through the binary release of the mlabs channel - quite simple to install in a Python 3.5 environment, sh seems not to be compatible with Windows at all.

Foucl avatar Oct 04 '16 07:10 Foucl

It doesn't, because dependencies fail to install, and Visual Studio build dependency is too huge. This is a roadblock https://github.com/libgit2/pygit2/issues/652 or https://mingwpy.github.io/ (for crosscompiler).

mingwpy in particular would be very useful project for the industry, but there is no entity that is interested to support the development.

techtonik avatar Oct 04 '16 12:10 techtonik

It will help if somebody could debug file descriptor leaks in pygit2 code - https://github.com/libgit2/pygit2/pull/656

techtonik avatar Oct 12 '16 04:10 techtonik

Descriptor leaks are fixed, the next issue is https://github.com/libgit2/pygit2/pull/657

techtonik avatar Oct 15 '16 17:10 techtonik

All tests are green. Next issue is to upload pygit2 wheels to PyPI https://github.com/libgit2/pygit2/issues/662

techtonik avatar Oct 21 '16 15:10 techtonik

Thanks @techtonik for keeping track of that. maybe I missed something, but I had no problem getting pygit2 to work through the builds uploaded to the anaconda m-labs channel. As I mentioned in my original post, the problem was rather the sh module gitless makes heavy use of and which is not compatible with Windows.

Foucl avatar Oct 21 '16 18:10 Foucl

I can't confirm or deny that, because pip install pygit2 still doesn't work for my system. But in any case, the problem with sh is not actionable without specific issues.

techtonik avatar Oct 22 '16 00:10 techtonik

Yes, this is the message I've got now that pygit2 is available from PyPI in wheels:

>pip install gitless
Collecting gitless
  Downloading gitless-0.8.4.tar.gz
Collecting pygit2>=0.23.0 (from gitless)
  Downloading pygit2-0.24.2-cp27-cp27m-win32.whl (569kB)
    100% |################################| 573kB 396kB/s
Collecting sh>=1.11 (from gitless)
  Downloading sh-1.11.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\user\appdata\local\temp2\pip-build-4m6kkg\sh\setup.py", line 4, in <module>
        import sh
      File "sh.py", line 37, in <module>
        support." % __version__)
    ImportError: sh 1.11 is currently only supported on linux and osx. please install pbs 0.110 (http://pypi.python.org/pypi/pbs) for windows support.

techtonik avatar Nov 02 '16 13:11 techtonik

Thank you all for looking into this. We can stop using sh if that's causing problems. The refactor shouldn't be too hard assuming we can still find a way to execute the git command.

Old versions of Gitless used to run inside git bash. How are you running Gitless in Windows?

spderosso avatar Nov 03 '16 09:11 spderosso

Well, I run gitless from cmd session, and use python -m gitless for now.

techtonik avatar Nov 03 '16 10:11 techtonik

this is the issue I was refering to in my first post here. I tried replacing all calls to sh with pbs equivalents (guided by http://stackoverflow.com/a/36004813):

from pbs import Command, ErrorReturnCode
git = Command('git')

This allows me to at least install gitless. It is also importable then in a python session. A call to the command line (e.g. gl init or gl status) results in an encoding related error, at least in cmd:

  File "C:\Users\DDMitarbeiter\Anaconda2\Scripts\gl-script.py", line 11, in <mod
ule>
    load_entry_point('gitless', 'console_scripts', 'gl')()
  File "c:\users\ddmitarbeiter\christopher\gitless\gitless\cli\gl.py", line 80,
in main
    pprint.err(e)
  File "c:\users\ddmitarbeiter\christopher\gitless\gitless\cli\pprint.py", line
80, in err
    puts(colored.red('Ô£ÿ {0}'.format(text)), stream=sys.stderr.write)
  File "c:\users\ddmitarbeiter\christopher\gitless\gitless\cli\pprint.py", line
40, in puts
    s = s.encode(ENCODING)
  File "C:\Users\DDMitarbeiter\Anaconda2\lib\site-packages\clint\textui\colored.
py", line 54, in func_help
    result = getattr(self.s, att)(*args, **kwargs)
  File "C:\Users\DDMitarbeiter\Anaconda2\lib\encodings\cp1252.py", line 12, in e
ncode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2718' in position
 0: character maps to <undefined>

Foucl avatar Nov 03 '16 15:11 Foucl

@techtonik I think that running gl that way won't work until we replace all git calls with calls to the pygit2 library. You can't run git on the windows shell, right? My understanding is that you need to use git bash but I am not a windows user. If pygit2 is installing fine in Windows then maybe it's possible run Gitless from within git bash?

@Foucl The encoding error could be unrelated to windows. Are you running gl version 0.8.4? it fixed a few unicode related issues. Do you have the text encoding option in your shell set to "Unicode (UTF-8)"?

spderosso avatar Nov 06 '16 20:11 spderosso

@spderosso I can run git on the windows command line no problem. git on Windows comes with bash and wrapper that makes it possible. I am not sure that this bash works the same way as Linux, and the problem is in sh package for now, not in git.

>where git
C:\Program Files\Git\cmd\git.exe

techtonik avatar Nov 09 '16 13:11 techtonik

@techtonik good to know, it might work if we replace the calls to sh then (assuming the error @Foucl is getting is an encoding error unrelated to windows)

spderosso avatar Nov 09 '16 16:11 spderosso

@spderosso what is the requirement for sh calls replacement? Like stdout should be captured or redirected or ... ?

techtonik avatar Nov 09 '16 19:11 techtonik

@spderosso indeed, after applying my patches to 0.8.4, gitless seems to work on windows! Anybody who is interested can have a look at my fork. I basically just replaced imports like from sh import git with from pbs import Command; git = Command('git').

Foucl avatar Nov 18 '16 17:11 Foucl

@Foucl That's great news! Feel free to send me a pull request with your changes. Windows users will be happy :)

spderosso avatar Nov 18 '16 20:11 spderosso

I think it is better to use https://github.com/tomerfiliba/plumbum, it is matching in functionality and is actively maintained.

tmr232 avatar Nov 18 '16 20:11 tmr232

OK, I take it back, for now. Seems using Plumbum would require a bit of code changes that are otherwise unneeded.

tmr232 avatar Nov 18 '16 20:11 tmr232

Until there is a formalized install for Windows, I though that I'd record the steps that I used to get gitless going on Windows. The hard work was done by @Foucl .

Platform: Python 3.5, Windows 7

I like git bash so that was my target to work with gl.

1: Install pbs (https://pypi.python.org/pypi/pbs). This does not work properly with Python 3.5, so a minor modification (adding a__path__ variable) is needed:

diff --git a/pbs.py b/new_pbs/pbs.py
index c13a35d..fffadcf 100644
--- a/pbs.py
+++ b/new_pbs/pbs.py
@@ -568,6 +568,7 @@ class SelfWrapper(ModuleType):
         for attr in ["__builtins__", "__doc__", "__name__", "__package__"]:
             setattr(self, attr, getattr(self_module, attr))

+        self.__path__ = []
         self.self_module = self_module
         self.env = Environment(globals())

2: Clone https://github.com/Foucl/gitless, checkout the sh_to_pbs branch, and install (python setup.py install) .

3: Install pygit2 through the conda package manager or via Chris Gohlke's repository

4: To get the unicode messages from gl to display properly in git bash, add the following to ~/.minttyrc (on Windows 7, C:\Users\<username>\.minttyrc):

Locale=C
Charset=UTF-8

5: Add the following to ~/.bashrc

export PYTHONIOENCODING=utf-8

breisfeld avatar Nov 20 '16 14:11 breisfeld

Unfortunately, there appears to be something wrong with regard to commit; a 'bare' commit fails, but commit -o succeeds.

[/k/temp]
$ mkdir t_repo

[/k/temp]
$ cd t_repo/

[/k/temp/t_repo]
$ gl init
✔ Local repo created in K:\temp\t_repo

[/k/temp/t_repo] (master)
$ touch f1

[/k/temp/t_repo] (master)
$ touch f2

[/k/temp/t_repo] (master)
$ gl status
On branch master, repo-directory //

Tracked files with modifications:
  ➜ these will be automatically considered for commit
  ➜ use gl untrack f if you don't want to track changes to file f
  ➜ if file f was committed before, use gl checkout f to discard local changes

    There are no tracked files with modifications to list


Untracked files:
  ➜ these won't be considered for commit
  ➜ use gl track f if you want to track changes to file f

    f1
    f2

[/k/temp/t_repo] (master)
$ gl track f1 f2
✔ File f1 is now a tracked file
✔ File f2 is now a tracked file

[/k/temp/t_repo] (master)
$ gl status
On branch master, repo-directory //

Tracked files with modifications:
  ➜ these will be automatically considered for commit
  ➜ use gl untrack f if you don't want to track changes to file f
  ➜ if file f was committed before, use gl checkout f to discard local changes

    f1 (new file)
    f2 (new file)


Untracked files:
  ➜ these won't be considered for commit
  ➜ use gl track f if you want to track changes to file f

    There are no untracked files to list

[/k/temp/t_repo] (master)
$ gl commit -m "Add f1 and f2"
✘ No files to commit
  ➜ use gl track f if you want to track changes to file f

  [/k/temp/t_repo] (master)
$ gl commit -m "Add f1 and f2" -o f1 f2
✔ Commit succeeded

Commit Id: 97ff3fb621211d2fc55d493d04865fd9bfba0bd8
Author:    XXXXX
Date:      XXXXX

    Add f1 and f2

breisfeld avatar Nov 25 '16 18:11 breisfeld

@breisfeld The problem you are having was fixed in e011750bd2d80f5b982d90d7c6a31747978b84c8. The https://github.com/Foucl/gitless/commits/master branch needs to be updated

spderosso avatar Nov 26 '16 17:11 spderosso

d0aabff3cd0c7cf466d4fe67d11c3a1a156d57a9

spderosso avatar Dec 07 '16 01:12 spderosso

The new release v0.8.5 should work on windows

spderosso avatar Dec 22 '16 01:12 spderosso

ok. I have v.0.8.5 gitless and i have the same problem as @Foucl on windows 10 and python 3.6

when I try something with gl command like gl init or gl status cmd say that

Traceback (most recent call last):
  File "C:\Python36\Scripts\gl-script.py", line 11, in <module>
    load_entry_point('gitless==0.8.5', 'console_scripts', 'gl')()
  File "c:\python36\lib\site-packages\pkg_resources\__init__.py", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "c:\python36\lib\site-packages\pkg_resources\__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "c:\python36\lib\site-packages\pkg_resources\__init__.py", line 2291, in load
    return self.resolve()
  File "c:\python36\lib\site-packages\pkg_resources\__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\python36\lib\site-packages\gitless\cli\gl.py", line 18, in <module>
    from pbs import ErrorReturnCode
  File "<frozen importlib._bootstrap>", line 999, in _handle_fromlist
  File "c:\python36\lib\site-packages\pbs.py", line 575, in __getattr__
    return self.env[name]
  File "c:\python36\lib\site-packages\pbs.py", line 527, in __missing__
    return Command._create(k)
  File "c:\python36\lib\site-packages\pbs.py", line 265, in _create
    if not path: raise CommandNotFound(program)
pbs.CommandNotFound: __path__

so what can i resolve this problem?

metya avatar May 19 '17 22:05 metya

@metya can you try latest version from HEAD?

techtonik avatar May 19 '17 22:05 techtonik

I clone the repo and install gitless from source.

So I have the same error. Almost.

Traceback (most recent call last):
  File "C:\Python36\Scripts\gl-script.py", line 11, in <module>
    load_entry_point('gitless==0.8.5', 'console_scripts', 'gl')()
  File "C:\Python36\lib\site-packages\pkg_resources\__init__.py", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Python36\lib\site-packages\pkg_resources\__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "C:\Python36\lib\site-packages\pkg_resources\__init__.py", line 2291, in load
    return self.resolve()
  File "C:\Python36\lib\site-packages\pkg_resources\__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 616, in _load_backward_compatible
  File "C:\Python36\lib\site-packages\gitless-0.8.5-py3.6.egg\gitless\cli\gl.py", line 18, in <module>
  File "<frozen importlib._bootstrap>", line 999, in _handle_fromlist
  File "C:\Python36\lib\site-packages\pbs.py", line 575, in __getattr__
    return self.env[name]
  File "C:\Python36\lib\site-packages\pbs.py", line 527, in __missing__
    return Command._create(k)
  File "C:\Python36\lib\site-packages\pbs.py", line 265, in _create
    if not path: raise CommandNotFound(program)
pbs.CommandNotFound: __path__

metya avatar May 19 '17 22:05 metya

@metya running tox on my system produces a lot of errors including this one, so it certainly a bug. Run into https://github.com/tox-dev/tox/issues/523 while trying to read all tests that fail. Just a random guess, but maybe there is a directory with spaces in your path?

techtonik avatar May 20 '17 09:05 techtonik

Sorry for late answer. And probably for reopen this ticket, but nope. There are no spaces in my path to python or gitless.

metya avatar Jul 14 '17 11:07 metya

@metya problem with pbs, see https://github.com/sdg-mit/gitless/issues/146#issuecomment-317237600

techtonik avatar Jul 23 '17 08:07 techtonik