Use .zip on Windows and .tar.gz on Linux/Mac #42

Closed
vbabiy opened this Issue Mar 15, 2011 · 9 comments

Projects

None yet

2 participants

@vbabiy
Contributor
vbabiy commented Mar 15, 2011

I just moved to using pip instead of easy_install, and started recommending it in my project's documentation.

However, here's one problem that came up in the transition:

When run from Linux, pip prefers zip files to tar.gz. This is a problem because I use zip files for Windows endlines, and tar.gz files for Linux endlines. This is especially important for my project because it gives the user a script that copies some files from the project to make a skeleton. (Similar to "django_admin startapp" or however it's called.) So if Windows users get a version of my project with LF, they get bad files generated for them.

I suggest then the pip will use .zip on Windows and .tar.gz on Linux/Mac. (I think that easy_install does this, but I'm not sure.)

What do you think?


@vbabiy
Contributor
vbabiy commented Mar 15, 2011

Is there any way to set the line endings during the file generation/copy?

Maybe have two versions of the file, detect the platform, then select the
correct file for the platform before the copy operation.


Original Comment By: Kelsey Hightower
@vbabiy
Contributor
vbabiy commented Mar 15, 2011

I've now fixed my own code to generate correct newlines for each platform.

But regardless of my file-generation script, I think that Windows users should
be getting CRLF files and Linux users should be getting LF files. I think it's
impolite to put LF files on a Windows user's computer.


Original Comment By: Ram Rachum
@vbabiy
Contributor
vbabiy commented Mar 15, 2011

I am glad you found a solution. Since python is cross platform, it will be
hard to know where an enduser will deploy your code or package. I would always
suggest detecting the platform and doing the right thing when possible.


Original Comment By: Kelsey Hightower
@vbabiy
Contributor
vbabiy commented Mar 15, 2011

So you agree that pip should prefer downloading a zip distribution over a
tar.gz one on Windows?


Original Comment By: Ram Rachum
@vbabiy
Contributor
vbabiy commented Mar 15, 2011

I would not think an installer should treat zip or tarballs differently, as
both could contain the same package/code. As a developer I would rather handle
that kind of logic myself. Just image the issues you would run into if you
left that up to the installer. You would have to make sure RPM, easy_install,
pip, and other installers all do the same thing.


Original Comment By: Kelsey Hightower
@vbabiy
Contributor
vbabiy commented Mar 15, 2011

I'm confused by your comment.

My suggestion is about the case where a package on PyPI has both a zip
source distribution and a tar.gz one available.

When you as a developer publish these two kinds of source distributions on
PyPI, it's your responsibility that both of the distributions work and that
users can use either of them randomly. Do you agree on this?

Since it's the developer's responsibility to make sure all the source
distributions work, it is the right of every installer (such as easy_install
or pip) to choose randomly which kind of source distribution it wants to use.

So if pip has a right to choose whichever source distribution it wants, why
not be polite to the OS and choose the one that is more likely to have newline
characters that are compatible with the OS's?

"As a developer I would rather handle that kind of logic myself"

I don't understand. Where would you handle that logic? Your package only gets
executed after pip installs it, so how could it have any control on which
distribution pip downloads? Possibly I've completely misunderstood your
statement.


Original Comment By: Ram Rachum
@vbabiy
Contributor
vbabiy commented Mar 15, 2011

In my personal projects I make sure both the zip and tar.gz versions work the
same.

"As a developer I would rather handle that kind of logic myself"

One way I would handle the logic myself would be to put OS specific stuff in
setup.py. For example, you can select a different set of files that get
installed depending on the OS platform. The same OS detection could occur
during execution as well.

Keep in mind I am only speaking for myself, not the core pip developers.


Original Comment By: Kelsey Hightower
@vbabiy
Contributor
vbabiy commented Mar 15, 2011

"So if pip has a right to choose whichever source distribution it wants, why
not be polite to the OS and choose the one that is more likely to have newline
characters that are compatible with the OS's?"

I tend to agree with this statement. I guess the question here is; What's
Pip's current policy on how it selects which distribution to install when the
only difference is the packaging format (zip vs tar.gz)?


Original Comment By: Kelsey Hightower
@dstufft
Member
dstufft commented Sep 11, 2014

I'm going to close this. I don't think picking different extensions on different OSs is a generally good idea.

@dstufft dstufft closed this Sep 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment