Skip to content
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

Don't install packages that could mess packaging up #397

Merged
merged 12 commits into from May 31, 2017
Merged

Conversation

kennethreitz
Copy link
Contributor

No description provided.

def main():
args = docopt(__doc__, version='pip-grep')
req_file = args['<req-file>']

Copy link

Choose a reason for hiding this comment

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

Could this be streamlined?

def good_package(line):
	package_name = line.split('=')[0].split('<')[0].split('>')[0]
	return package_name not in BAD_PACKAGES

lines = [line for line in f if good_package(line)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to do as little parsing as possible, for fear of breaking anything with crazy requirements files.

Copy link

Choose a reason for hiding this comment

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

Understood... see other package names that begin with but do not end with six for instance https://pypi.python.org/pypi?%3Aaction=search&term=Six&submit=search

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was planning to cross that bridge when I came to it, which I honestly doubt would happen any time soon. I'll see what I can do though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cclauss i updated the code; integrated what you suggested and made a few improvements

@hone
Copy link
Member

hone commented May 30, 2017

Should we have a message that tells people we're replacing stuff in their requirements.txt with things in the Python buildpack or overwriting their requirements.txt file at all.

Also, how does this affect pipenv?

@kennethreitz
Copy link
Contributor Author

Pipenv has this functionality built-in.

I don't think a message is needed, but I could add one saying "Removing packaging libraries from requirements.txt".

@kennethreitz
Copy link
Contributor Author

In my mind, if someone has any of these listed in their requirements.txt, it is accidental, not intentional.

@kennethreitz
Copy link
Contributor Author

e.g. they don't understand what's going on. so, i don't want to overload them with information.

@hone
Copy link
Member

hone commented May 30, 2017

@kennethreitz is there a place you could link them to that would help?

@kennethreitz
Copy link
Contributor Author

No.

@kennethreitz
Copy link
Contributor Author

kennethreitz commented May 30, 2017

This is a new problem, and one that is temporary and will go away soon (but we need to have this code for people using this version range of setuptools locally for the future).

It's not well-understood or documented anywhere that I know of.

@kennethreitz
Copy link
Contributor Author

Waiting, waiting, waiting... for CI to pass.

# Syntax sugar.
source $BIN_DIR/utils

pip-clean requirements.txt
Copy link

Choose a reason for hiding this comment

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

missing EOL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

return package_name not in BAD_PACKAGES

def main():
args = docopt(__doc__, version='pip-grep')
Copy link

Choose a reason for hiding this comment

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

version='pip-grep'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

@jayvdb
Copy link

jayvdb commented May 30, 2017

In my mind, if someone has any of these listed in their requirements.txt, it is accidental, not intentional.
e.g. they don't understand what's going on. so, i don't want to overload them with information.

The more usual explanation is they have put them in because they have minimum and maximum requirements.
setuptools installs pkg_resources which is the main mechanism people use for fetching plugins (implicit namespaces is the newer alternative).
And more importantly, because of the fact that pip doesnt have a proper resolver, sometimes it is necessary to mention one of these packages in requirements.txt so that pip follows a particular path in its resolution strategy. You remove one of them of requirements.txt, and pip behaves differently when resolving indirect dependencies many levels deep.
At the very least, there should be a note to say why the deploy is using different versions from the versions they see when they deploy the app somewhere else.

@kennethreitz
Copy link
Contributor Author

Related: #393



def good_package(line):
package_name = line.split('=')[0].split('<')[0].split('>')[0].split(' ')[0].split('#')[0].split('\n')[0]
Copy link

Choose a reason for hiding this comment

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

You can just do .split() with no parameters instead of .split(' ').split('\n') because it deals with all whitespaces. Given the for line in f, \n is not really an issue here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

\n is included in each line

Copy link

Choose a reason for hiding this comment

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

Buggy. c.f. #400

@kennethreitz kennethreitz merged commit 5496c02 into master May 31, 2017
@kennethreitz kennethreitz deleted the setuptools branch May 31, 2017 00:04
@edmorley
Copy link
Member

edmorley commented Jun 1, 2017

This is a new problem, and one that is temporary and will go away soon

Was this to work around setuptools unvendoring their dependencies in v34.0.0 (which they've then reverted in v36.0.0) and relying on install_requires instead? (Which presumably could cause issues if the versions they required conflicted with those in requirements.txt?)

@kennethreitz
Copy link
Contributor Author

@edmorley yes

kennethreitz added a commit that referenced this pull request Jun 3, 2017
kennethreitz added a commit that referenced this pull request Jun 3, 2017
* Revert "Fix pyyaml (#402)"

This reverts commit ff94908.

* Revert "Don't install packages that could mess packaging up (#397)"

This reverts commit 5496c02.
kennethreitz pushed a commit that referenced this pull request Jun 14, 2017
The pip-uninstall step stopped working when it was moved to after
the pip-install step in f27a84e.

This regression was temporarily fixed by part of #397, however that
PR was reverted in #404.

Adds a test to hopefully catch any future regressions :-)

Fixes #393.
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.

None yet

5 participants