FriendCode / gittle

Pythonic Git for Humans
Other
732 stars 90 forks source link

Python3 #63

Open Thor77 opened 9 years ago

Thor77 commented 9 years ago

Gittle doesn't work at all with Python3, it would be very nice to get it working because its the best-looking git-libary for python i found so far.

minhoryang commented 9 years ago

+1

hanbeibei commented 8 years ago

+1

eefret commented 8 years ago

+1

fusion44 commented 8 years ago

+1

forresthopkinsa commented 8 years ago

+1

If someone takes it upon themselves to upgrade this software, they should definitely update this thread. I know I'd be willing to lend a hand if someone got the project underway.

powellc commented 8 years ago

@forresthopkinsa opened pull request 84 with a few elementary steps undertaken. Mostly I just updated the setup.py to pull in up to date requirements and ran 2to3 over the project.

There's still some work to do, though as it stands it works in the project I use it for.

powellc commented 8 years ago

I'll also note, that until this project is updated properly, I've created gittle3 and pushed it to PyPI. So if your project needs gittle with Py3 support, try pip install gittle3.

I will happily demote that fork when this project is updated.

VeeeneX commented 8 years ago

I've tried to test it, but I ran to an error: TypeError: a bytes-like object is required, not 'str'

Code:

from gittle import Gittle

repo_path = '/tmp/1gittle_bare'
repo_url = 'git://github.com/FriendCode/gittle.git'

repo = Gittle.clone(repo_url, repo_path)

Error

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    repo = Gittle.clone(repo_url, repo_path)
  File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 457, in clone
    local_repo = cls.init(local_path)
  File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 312, in init
    repo = constructor(path)
  File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 885, in init
    cls._init_maybe_bare(controldir, False)
  File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 869, in _init_maybe_bare
    ret.refs.set_symbolic_ref("HEAD", "refs/heads/master")
  File "/usr/local/lib/python3.5/dist-packages/dulwich/refs.py", line 545, in set_symbolic_ref
    f.write(SYMREF + other + '\n')
TypeError: a bytes-like object is required, not 'str'
forresthopkinsa commented 8 years ago

@VeeeneX

Does it still throw that error when cloning from a local repo? The error doesn't quite make sense; it seems to be that something went wrong in the Gittle-Dulwich interface, because Gittle.clone certainly does require a string... Right?

But try changing the arguments and see if it still throws it.

On Wed, Aug 17, 2016, 3:59 PM VeeeneX notifications@github.com wrote:

I've tried to test it, but I ran to an error: TypeError: a bytes-like object is required, not 'str'

Code:

from gittle import Gittle

repo_path = '/tmp/1gittle_bare' repo_url = 'git://github.com/FriendCode/gittle.git'

repo = Gittle.clone(repo_url, repo_path)

Error

Traceback (most recent call last): File "test.py", line 6, in repo = Gittle.clone(repo_url, repo_path) File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 457, in clone local_repo = cls.init(local_path) File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 312, in init repo = constructor(path) File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 885, in init cls._init_maybe_bare(controldir, False) File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 869, in _init_maybe_bare ret.refs.set_symbolic_ref("HEAD", "refs/heads/master") File "/usr/local/lib/python3.5/dist-packages/dulwich/refs.py", line 545, in set_symbolic_ref f.write(SYMREF + other + '\n') TypeError: a bytes-like object is required, not 'str'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FriendCode/gittle/issues/63#issuecomment-240574923, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOlAcXxksBCfCvP4ek4QCFS4EEluwhBks5qg5JWgaJpZM4DzOkf .

VeeeneX commented 8 years ago

@forresthopkinsa Problem is with dependency gittle3 uses old Dulwich 0.9.7, which has 'wb' flag for opening files for python2

jelmer commented 8 years ago

Dulwich is expecting bytes for most arguments, including ref names. This is because Git is encoding-agnostic. Gittle is passing in a object, which in Python2 was a bytestring, but is a unicode string in Python 3.

On Thu, Aug 18, 2016 at 08:38:38AM -0700, Forrest Hopkins wrote:

@VeeeneX

Does it still throw that error when cloning from a local repo? The error doesn't quite make sense; it seems to be that something went wrong in the Gittle-Dulwich interface, because Gittle.clone certainly does require a string... Right?

But try changing the arguments and see if it still throws it.

On Wed, Aug 17, 2016, 3:59 PM VeeeneX notifications@github.com wrote:

I've tried to test it, but I ran to an error: TypeError: a bytes-like object is required, not 'str'

Code:

from gittle import Gittle

repo_path = '/tmp/1gittle_bare' repo_url = 'git://github.com/FriendCode/gittle.git'

repo = Gittle.clone(repo_url, repo_path)

Error

Traceback (most recent call last): File "test.py", line 6, in repo = Gittle.clone(repo_url, repo_path) File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 457, in clone local_repo = cls.init(local_path) File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 312, in init repo = constructor(path) File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 885, in init cls._init_maybe_bare(controldir, False) File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 869, in _init_maybe_bare ret.refs.set_symbolic_ref("HEAD", "refs/heads/master") File "/usr/local/lib/python3.5/dist-packages/dulwich/refs.py", line 545, in set_symbolic_ref f.write(SYMREF + other + '\n') TypeError: a bytes-like object is required, not 'str'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FriendCode/gittle/issues/63#issuecomment-240574923, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOlAcXxksBCfCvP4ek4QCFS4EEluwhBks5qg5JWgaJpZM4DzOkf .

You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/FriendCode/gittle/issues/63#issuecomment-240763505

forresthopkinsa commented 8 years ago

Ah, that makes sense. Thanks guys

On Thu, Aug 18, 2016, 9:06 AM Jelmer Vernooij notifications@github.com wrote:

Dulwich is expecting bytes for most arguments, including ref names. This is because Git is encoding-agnostic. Gittle is passing in a object, which in Python2 was a bytestring, but is a unicode string in Python 3.

On Thu, Aug 18, 2016 at 08:38:38AM -0700, Forrest Hopkins wrote:

@VeeeneX

Does it still throw that error when cloning from a local repo? The error doesn't quite make sense; it seems to be that something went wrong in the Gittle-Dulwich interface, because Gittle.clone certainly does require a string... Right?

But try changing the arguments and see if it still throws it.

On Wed, Aug 17, 2016, 3:59 PM VeeeneX notifications@github.com wrote:

I've tried to test it, but I ran to an error: TypeError: a bytes-like object is required, not 'str'

Code:

from gittle import Gittle

repo_path = '/tmp/1gittle_bare' repo_url = 'git://github.com/FriendCode/gittle.git'

repo = Gittle.clone(repo_url, repo_path)

Error

Traceback (most recent call last): File "test.py", line 6, in repo = Gittle.clone(repo_url, repo_path) File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 457, in clone local_repo = cls.init(local_path) File "/usr/local/lib/python3.5/dist-packages/gittle/gittle.py", line 312, in init repo = constructor(path) File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 885, in init cls._init_maybe_bare(controldir, False) File "/usr/local/lib/python3.5/dist-packages/dulwich/repo.py", line 869, in _init_maybe_bare ret.refs.set_symbolic_ref("HEAD", "refs/heads/master") File "/usr/local/lib/python3.5/dist-packages/dulwich/refs.py", line 545, in set_symbolic_ref f.write(SYMREF + other + '\n') TypeError: a bytes-like object is required, not 'str'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/FriendCode/gittle/issues/63#issuecomment-240574923 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AEOlAcXxksBCfCvP4ek4QCFS4EEluwhBks5qg5JWgaJpZM4DzOkf

.

You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/FriendCode/gittle/issues/63#issuecomment-240763505

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FriendCode/gittle/issues/63#issuecomment-240772279, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOlAcmAx8456WtEhc-7g4mfin4p1sF_ks5qhILngaJpZM4DzOkf .

VeeeneX commented 8 years ago

So, is there some workaround?

forresthopkinsa commented 8 years ago

Specify a bytestring rather than a normal string in the Dulwich interface? Is that it?

On Thu, Aug 18, 2016, 9:25 AM VeeeneX notifications@github.com wrote:

So, is there some workaround?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FriendCode/gittle/issues/63#issuecomment-240778034, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOlAVRHaOUAPsngVEh1E-35TmBnxEwiks5qhIdpgaJpZM4DzOkf .

jelmer commented 7 years ago

Yep, specifying a bytestring should be sufficient.

AaronO commented 7 years ago

I welcome and would happily merge a PR to add Python3 support.

Thor77 commented 7 years ago

Great, will start working on that, if noone else wants to take it 👍

forresthopkinsa commented 7 years ago

@Thor77 The last commit, based on @powellc 's PR, is the result of a 2to3 and some configuration. Start from there.