gitless-vcs / gitless

A simple version control system built on top of Git
https://gitless.com
MIT License
1.92k stars 107 forks source link

Windows support #13

Open spderosso opened 10 years ago

Foucl commented 7 years ago

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.

techtonik commented 7 years ago

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 commented 7 years ago

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

techtonik commented 7 years ago

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

techtonik commented 7 years ago

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

Foucl commented 7 years ago

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.

techtonik commented 7 years ago

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 commented 7 years ago

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.
spderosso commented 7 years ago

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?

techtonik commented 7 years ago

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

Foucl commented 7 years ago

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>
spderosso commented 7 years ago

@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)"?

techtonik commented 7 years ago

@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
spderosso commented 7 years ago

@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)

techtonik commented 7 years ago

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

Foucl commented 7 years ago

@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').

spderosso commented 7 years ago

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

tmr232 commented 7 years ago

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

tmr232 commented 7 years ago

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

breisfeld commented 7 years ago

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 commented 7 years ago

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
spderosso commented 7 years ago

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

spderosso commented 7 years ago

d0aabff3cd0c7cf466d4fe67d11c3a1a156d57a9

spderosso commented 7 years ago

The new release v0.8.5 should work on windows

metya commented 7 years ago

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?

techtonik commented 7 years ago

@metya can you try latest version from HEAD?

metya commented 7 years ago

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__
techtonik commented 7 years ago

@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?

metya commented 7 years ago

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

techtonik commented 7 years ago

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

cougarhawk commented 7 years ago

If you are running with Python3+ on Windows, I recommend that you manually make a modification to the pbs 0.110 Python package after backing it up (see comment link below). Otherwise, Gitless will throw exceptions every time it tries to output messages because the str type has no decode method.

See my comment: https://github.com/sdg-mit/gitless/pull/110#issuecomment-323201403

A request was made to add code to Gitless to address this but this is not a bug in Gitless. This is a compatibility problem with the pbs Python package and Python 3+. Development on pbs has since ceased in favor of sh so I don't see how we can move forward on Windows, unless Gitless distributes its own patched version of pbs for use with Python 3+ adopters.

Sincerely, Al

wooooooooooooooowastaken commented 6 years ago

Is this issue resolved? I got the same error on Win10. Gitless intallation via pip install gitless was successful but I could not execute gl init using commandline, powershell, git bash. I also tried using the python -m gitless command but that didn't work.

C:\Users\username\source\repos\gitless>gl init
Traceback (most recent call last):
  File "C:\Program Files\Python36\Scripts\gl-script.py", line 11, in <module>
    load_entry_point('gitless==0.8.6', 'console_scripts', 'gl')()
  File "c:\program files\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:\program files\python36\lib\site-packages\pkg_resources\__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "c:\program files\python36\lib\site-packages\pkg_resources\__init__.py", line 2291, in load
    return self.resolve()
  File "c:\program files\python36\lib\site-packages\pkg_resources\__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\program files\python36\lib\site-packages\gitless\cli\gl.py", line 18, in <module>
    from pbs import ErrorReturnCode
  File "<frozen importlib._bootstrap>", line 1007, in _handle_fromlist
  File "c:\program files\python36\lib\site-packages\pbs.py", line 575, in __getattr__
    return self.env[name]
  File "c:\program files\python36\lib\site-packages\pbs.py", line 527, in __missing__
    return Command._create(k)
  File "c:\program files\python36\lib\site-packages\pbs.py", line 265, in _create
    if not path: raise CommandNotFound(program)
pbs.CommandNotFound: __path__
breisfeld commented 6 years ago

Please see this comment about modifying the pbs code to add the __path__ variable.

wooooooooooooooowastaken commented 6 years ago

Gitbash

[user]@[pc-name] MINGW64 ~/source/repos/gitless

$ diff --git a/pbs.py b/new_pbs/pbs.py

diff: unknown option -- git
diff: Try 'diff --help' for more information.

$ diff --help

Usage: diff [OPTION]... FILES
Compare FILES line by line.

Mandatory arguments to long options are mandatory for short options too.
      --normal                  output a normal diff (the default)
  -q, --brief                   report only when files differ
  -s, --report-identical-files  report when two files are the same
  -c, -C NUM, --context[=NUM]   output NUM (default 3) lines of copied context
  -u, -U NUM, --unified[=NUM]   output NUM (default 3) lines of unified context
  -e, --ed                      output an ed script
  -n, --rcs                     output an RCS format diff
  -y, --side-by-side            output in two columns
  -W, --width=NUM               output at most NUM (default 130) print columns
      --left-column             output only the left column of common lines
      --suppress-common-lines   do not output common lines

  -p, --show-c-function         show which C function each change is in
  -F, --show-function-line=RE   show the most recent line matching RE
      --label LABEL             use LABEL instead of file name and timestamp
                                  (can be repeated)

  -t, --expand-tabs             expand tabs to spaces in output
  -T, --initial-tab             make tabs line up by prepending a tab
      --tabsize=NUM             tab stops every NUM (default 8) print columns
      --suppress-blank-empty    suppress space or tab before empty output lines
  -l, --paginate                pass output through 'pr' to paginate it

  -r, --recursive                 recursively compare any subdirectories found
      --no-dereference            don't follow symbolic links
  -N, --new-file                  treat absent files as empty
      --unidirectional-new-file   treat absent first files as empty
      --ignore-file-name-case     ignore case when comparing file names
      --no-ignore-file-name-case  consider case when comparing file names
  -x, --exclude=PAT               exclude files that match PAT
  -X, --exclude-from=FILE         exclude files that match any pattern in FILE
  -S, --starting-file=FILE        start with FILE when comparing directories
      --from-file=FILE1           compare FILE1 to all operands;
                                    FILE1 can be a directory
      --to-file=FILE2             compare all operands to FILE2;
                                    FILE2 can be a directory

  -i, --ignore-case               ignore case differences in file contents
  -E, --ignore-tab-expansion      ignore changes due to tab expansion
  -Z, --ignore-trailing-space     ignore white space at line end
  -b, --ignore-space-change       ignore changes in the amount of white space
  -w, --ignore-all-space          ignore all white space
  -B, --ignore-blank-lines        ignore changes where lines are all blank
  -I, --ignore-matching-lines=RE  ignore changes where all lines match RE

  -a, --text                      treat all files as text
      --strip-trailing-cr         strip trailing carriage return on input
      --binary                    read and write data in binary mode

  -D, --ifdef=NAME                output merged file with '#ifdef NAME' diffs
      --GTYPE-group-format=GFMT   format GTYPE input groups with GFMT
      --line-format=LFMT          format all input lines with LFMT
      --LTYPE-line-format=LFMT    format LTYPE input lines with LFMT
    These format options provide fine-grained control over the output
      of diff, generalizing -D/--ifdef.
    LTYPE is 'old', 'new', or 'unchanged'.  GTYPE is LTYPE or 'changed'.
    GFMT (only) may contain:
      %<  lines from FILE1
      %>  lines from FILE2
      %=  lines common to FILE1 and FILE2
      %[-][WIDTH][.[PREC]]{doxX}LETTER  printf-style spec for LETTER
        LETTERs are as follows for new group, lower case for old group:
          F  first line number
          L  last line number
          N  number of lines = L-F+1
          E  F-1
          M  L+1
      %(A=B?T:E)  if A equals B then T else E
    LFMT (only) may contain:
      %L  contents of line
      %l  contents of line, excluding any trailing newline
      %[-][WIDTH][.[PREC]]{doxX}n  printf-style spec for input line number
    Both GFMT and LFMT may contain:
      %%  %
      %c'C'  the single character C
      %c'\OOO'  the character with octal code OOO
      C    the character C (other characters represent themselves)

  -d, --minimal            try hard to find a smaller set of changes
      --horizon-lines=NUM  keep NUM lines of the common prefix and suffix
      --speed-large-files  assume large files and many scattered small changes
      --color[=WHEN]       colorize the output; WHEN can be 'never', 'always',
                             or 'auto' (the default)
      --palette=PALETTE    specify the colors to use when --color is active
                             PALETTE is a colon-separated list terminfo capabili                                                                          ties

      --help               display this help and exit
  -v, --version            output version information and exit

FILES are 'FILE1 FILE2' or 'DIR1 DIR2' or 'DIR FILE' or 'FILE DIR'.
If --from-file or --to-file is given, there are no restrictions on FILE(s).
If a FILE is '-', read standard input.
Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.

Report bugs to: bug-diffutils@gnu.org
GNU diffutils home page: <http://www.gnu.org/software/diffutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Thad-BC commented 5 years ago

I have a problem trying to run on Windows. Following is the error after downloading and running in a non-repository directory:

  Downloading https://files.pythonhosted.org/packages/e5/1c/b701b3f4bd8d3667df8342f311b3efaeab86078a840fb826bd204118cc6b/args-0.1.0.tar.gz
Installing collected packages: args, clint, pbs, gitless
  Running setup.py install for args ... done
  Running setup.py install for clint ... done
  Running setup.py install for pbs ... done
  Running setup.py install for gitless ... done
Successfully installed args-0.1.0 clint-0.5.1 gitless-0.8.6 pbs-0.110

G:\>gl
Traceback (most recent call last):
  File "C:\Python27\Scripts\gl-script.py", line 11, in <module>
    load_entry_point('gitless==0.8.6', 'console_scripts', 'gl')()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 480, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2693, in load_entry_point
    return ep.load()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2324, in load
    return self.resolve()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\python27\lib\site-packages\gitless\cli\gl.py", line 43, in <module>
    repo = core.Repository()
  File "c:\python27\lib\site-packages\gitless\core.py", line 115, in __init__
    self.git_repo = pygit2.Repository(path)
  File "c:\python27\lib\site-packages\pygit2\repository.py", line 1235, in __init__
    path = path.decode('utf-8')
AttributeError: 'NoneType' object has no attribute 'decode'
techtonik commented 5 years ago

It is broken on Appveyor too, but for different reason - https://github.com/sdg-mit/gitless/pull/208