-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot execute "git fat init" on Windows #42
Comments
Yup, works with Python 2.7.x. Unfortunately I'm no Python programmer, but probably somebody should look into this issue :-) |
There are encoding issues on Windows due to conflicting choices made by Git and Python-3, so this is not currently supported. |
I have this problem in Linux too (Arch). Easy fix: #!/usr/bin/env python -> #!/usr/bin/env python2 |
The main stumbling block for Python-3 is unicode. Git stores paths unencoded and we can pass it directly to the file system on Linux, but Windows requires encoding to create a huge string that is later parsed. I'm not wild about an intrusive unicode change that won't work on Windows, so I've been delaying. I don't know what is recommended here because the Python community has chosen a convention distinctly different from Git. Being a Git tool that is only incidentally written in Python, I would rather use the Git conventions. |
I have to admit I don't see where unicode comes into play in the present issue, but wouldn't a comparison function similar to |
The unicode issue has to be resolved to support python3. The sorted call should just use key=lambda p,s: max(s), but it's just the tip of the iceberg. |
yeah, I just realized that, was hunting for the minimum supported python version of git-fat to find out if |
sorted appeared in python-2.4, including the key argument. |
yes, I know. the question was: what is the minimum python version that git-fat expects/needs? |
Python-3 requires careful handling of unicode to avoid breaking Git semantics (which manages strings unencoded) or Python (which insists on processing encoded strings on Windows). This is not done yet, so error cleanly for now. See discussion in issue #42. Suggested-by: Christoph Buchner
Christoph Buchner [email protected] writes:
Most of my testing is with 2.7. 2.6 has worked, but beware the Python
Done. |
As of Python 3.4.1, the win32/Python 3 branch is entirely and profoundly broken. I spent most of an hour playing whack-a-mole with issues before I gave up. In addition to the basic issues with 3.4.1, it also uses os.path.join to create Windows paths, but I'm using MSYS/MinGW, and so the backslashes actually break things. Would be better to use posixpath.join directly, since Windows has long supported using forward slashes in pretty much all paths. Giving up on git-fat for now. I like the idea of a simpler Python-based git-media, but I don't really want to install multiple versions of Python on my system. +1 to update to latest Python and actually support Windows. Until then, it doesn't work for me. |
Thanks for the update, Tim. I have not used MS products in 20 years and find the various failure modes and Python POSIX-Windows inconsistencies confusing. Is anyone aware of a best practices guide that does not involve reading the fine print for every function to learn which ones behaves subtly yet profoundly different on Windows, knowing Windows well enough to recognize when the side-effects will be a problem, and adding conditionals to the code?
|
Hmm.... I don't know of such a guide. The basics, as I'm familiar with them, include:
Aside from that, mostly things Just Work, at least when you're using Python. At least in my experience (I just wrote a huge git tool for my last employer that worked on OS X with only a couple of minor tweaks). There do exist a few tools (Perforce, maybe?) that have trouble with forward-slashes, and if you're trying to complete paths from the CMD prompt, only backslash works, but nothing that you're doing in git-fat should have a problem with forward slash. MOST of the problems I saw were buffer-vs-string issues in Python 3.4. Some places you were doing everything in buffers and then doing a string op on them, and it would error out. Other places you were sending a buffer AND a string to, for example, os.rename(), and it would complain that both parameters need to be the same. So updating to the latest 3.4.x version of Python and making it run there should get you 95% of the way past the problems I saw. One thing that did worry me is that sys.getfilesystemencoding() was returning "mbcs", i.e., multi-byte characters, which I think is the wrong thing. Looking at this link, Python 3 is supposed to support UTF-8 file names, even on Windows, so I think converting all path names to and from UTF-8 is a better practice than sys.getfilesystemencoding(). Internally Windows uses UTF-16 for path names; assuming Python is doing the "right thing", it should be taking any UTF-8 string and just converting straight to UTF-16, using the "Unicode" APIs (if you don't know, it's two encodings for the same set of code points, so the conversion between the two is trivial). In fact, this link implies that Python 3.2+ is doing the right thing, so you should always just hand it UTF-8 (or otherwise Unicode) file names. (On Windows, the APIs that end in "W" are the wide-char, i.e., Unicode APIs. The ones that end in "A" are ASCII or mbcs APIs.) So in short: Use UTF-8 encoding for file names and forward slash, and get it running on 3.4.x, and it should all Just Work. Looking at what I did accomplish, I'd forgotten that I actually got things to the point where I could try to PUSH files, but then then rsync command was failing for other reasons. I have no idea whether the "pull" side works at all, for obvious reasons. Here's what I had: https://gist.github.com/TimMensch/86064e34d8c901dbb5c3 I guess what it still needs is a different back-end than calling command-line rsync. Probably out of scope for your project, but if you ever did get s3 working, that would be awesome. |
Thanks for the run-down. With regard to file names, my first priority is to be exactly compatible with Git, which stores file names with unspecified encoding (the encoding must agree with ASCII for '.' and '/'). You can debate whether that was the best choice, but it's how Git works. This creates some impedance mismatch with Python (especially version 3, which wants to be strict about filename encodings).
|
UTF-8 agrees with ASCII for the full first 128 bytes, so it's safe to Tim On 6/3/2015 3:55 PM, Jed Brown wrote:
|
Right, but I get path names in unspecified encoding from Git and I want to hand those bytes directly to the operating system without insisting on guessing the encoding so that I can convert them to UTF-8 or whatever. Python makes that difficult and Windows cannot accept argv[] without encoding it (and concatenating into a massive escaped string), so I think the only solution is to insist that paths never appear in command line arguments. Fortunately, Git plumbing supports this, albeit slightly unnaturally at times (and with some complication due to close_fds=True having completely different behavior on Windows).
|
After following the installation guide, I've tried to execute "git fat init" on my repository, however, I only get the following error:
What's wrong? Do I have to use Python 2.x instead of 3.x?
The text was updated successfully, but these errors were encountered: