← 返回首页
Replace tar command with something that works by jwodder · Pull Request #552 · pypa/packaging.python.org · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Replace tar command with something that works#552

Merged
theacodes merged 2 commits into
pypa:masterfrom
jwodder:fix-tar-cmd
Sep 17, 2018
Merged

Replace tar command with something that works#552
theacodes merged 2 commits into
pypa:masterfrom
jwodder:fix-tar-cmd

Conversation

Copy link
Copy Markdown
Contributor

jwodder commented Sep 15, 2018

In the "Dropping support for older Python versions" guide, the tar command given for showing the sdist's metadata does not work (unless you happen to run it in your project directory without cleaning up your .egg-info dir first, in which case it only works by accident and the tar is pointless). This pull request changes the command to something that does work.

You can see the contents of the generated file like this::

tar xvfz dist/my-package-1.0.0.tar.gz -O | cat */PKG-INFO
tar xfz dist/my-package-1.0.0.tar.gz --wildcards --no-wildcards-match-slash -O '*/PKG-INFO'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Using tar xfO dist/my-package-1.0.0.tar.gz */PKG-INFO would be simpler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Is the omission of --wildcards in your command intentional? tar on Ubuntu Xenial requires that option in order to enable pattern matching.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Ah, nope, my tar must work differently (I'm using bsdtar 2.8.3). I get a tar: Option --wildcards is not supported trying to use that flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I believe the lowest common denominator command would be tar xfO dist/my-package-1.0.0.tar.gz my-package-1.0.0/PKG-INFO, with the user typing out the project name & version twice. Should we go with that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

For what it's worth, Windows 10 has tar available by default (at least the version I have does) - it's bsdtar 3.3.2 and that does support wildcards without needing an option. Specifically, tar xfO dist/my-package-1.0.0.tar.gz */PKG-INFO works.

Older versions of Windows almost certainly don't have tar, though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

One problem with using wildcards, though - building a sdist appears to create a .egg-info directory that contains a copy of the metadata, so tar output (with wildcards) gets duplicated.

>tar tvf .\dist\pip-18.1.dev0.tar.gz */PKG-INFO -rw-rw-rw- 0 0 0 3008 Sep 16 12:41 pip-18.1.dev0/PKG-INFO -rw-rw-rw- 0 0 0 3008 Sep 16 12:41 pip-18.1.dev0/src/pip.egg-info/PKG-INFO >tar xfO .\dist\pip-18.1.dev0.tar.gz */PKG-INFO | grep Name: Name: pip Name: pip

So the explicit version is probably better anyway.

theacodes merged commit afbe530 into pypa:master Sep 17, 2018
Copy link
Copy Markdown
Member

Thanks, @jwodder!

jwodder deleted the fix-tar-cmd branch September 24, 2018 16:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Footer

© 2026 GitHub, Inc.