Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-python
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-python
Commits
9b185f99
Commit
9b185f99
authored
May 30, 2017
by
David Lord
Committed by
Kenneth Reitz
May 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use pkg_resources to check for distributions (#395)
more accurate than parsing requirements.txt fixes #359
parent
e8a79bbd
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
51 deletions
+25
-51
CHANGELOG.md
CHANGELOG.md
+9
-0
collectstatic
bin/steps/collectstatic
+1
-1
cryptography
bin/steps/cryptography
+1
-1
gdal
bin/steps/gdal
+1
-1
pylibmc
bin/steps/pylibmc
+1
-1
setuptools
bin/steps/setuptools
+1
-1
pip-grep
vendor/pip-pop/pip-grep
+11
-46
No files found.
CHANGELOG.md
View file @
9b185f99
# Python Buildpack Changelog
# 104
unreleased
-
Use
`pkg_resources`
to check if a distribution is installed instead of
parsing
`requirements.txt`
. (
[
#395
][
395
]
)
[
395
]:
https://github.com/heroku/heroku-buildpack-python/pull/395
## 103
Bug fixes and improvements.
...
...
bin/steps/collectstatic
View file @
9b185f99
...
...
@@ -20,7 +20,7 @@ MANAGE_FILE=${MANAGE_FILE:-fakepath}
[
-f
.heroku/collectstatic_disabled
]
&&
DISABLE_COLLECTSTATIC
=
1
# Ensure that Django is explicitly specified in requirements.txt
pip-grep
-s
requirements.txt django
Django
&&
DJANGO_INSTALLED
=
1
pip-grep
-s
Django
&&
DJANGO_INSTALLED
=
1
if
[
!
"
$DISABLE_COLLECTSTATIC
"
]
&&
[
-f
"
$MANAGE_FILE
"
]
&&
[
"
$DJANGO_INSTALLED
"
]
;
then
...
...
bin/steps/cryptography
View file @
9b185f99
...
...
@@ -18,7 +18,7 @@ PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
source
$BIN_DIR
/utils
# If a package using cffi exists within requirements, use vendored libffi.
if
(
pip-grep
-s
requirements.txt argon2-cffi bcrypt cffi cryptography django[argon2] Django[argon2] django[bcrypt] Django[bcrypt] PyNaCl pyOpenSSL PyOpenSSL requests[security]
misaka &> /dev/null
)
then
if
(
pip-grep
-s
argon2-cffi bcrypt cffi cryptography PyNaCl pyOpenSSL PyOpenSSL
misaka &> /dev/null
)
then
if
[
!
-d
".heroku/vendor/lib/libffi-3.1"
]
;
then
echo
"-----> Noticed cffi. Bootstrapping libffi."
...
...
bin/steps/gdal
View file @
9b185f99
...
...
@@ -18,7 +18,7 @@ PKG_CONFIG_PATH="/app/.heroku/vendor/lib/pkgconfig:$PKG_CONFIG_PATH"
source
$BIN_DIR
/utils
# If GDAL exists within requirements, use vendored gdal.
if
(
pip-grep
-s
requirements.txt GDAL gdal
pygdal &> /dev/null
)
then
if
(
pip-grep
-s
GDAL
pygdal &> /dev/null
)
then
if
[
!
-f
".heroku/vendor/bin/gdalserver"
]
;
then
echo
"-----> Noticed GDAL. Bootstrapping gdal."
...
...
bin/steps/pylibmc
View file @
9b185f99
...
...
@@ -17,7 +17,7 @@ source $BIN_DIR/utils
# If pylibmc exists within requirements, use vendored libmemcached.
if
(
pip-grep
-s
requirements.txt
pylibmc &> /dev/null
)
then
if
(
pip-grep
-s
pylibmc &> /dev/null
)
then
if
[
!
-d
".heroku/vendor/lib/sasl2"
]
;
then
echo
"-----> Noticed pylibmc. Bootstrapping libmemcached."
...
...
bin/steps/setuptools
View file @
9b185f99
...
...
@@ -3,7 +3,7 @@
# Syntax sugar.
source
$BIN_DIR
/utils
if
(
pip-grep
-s
requirements.txt
setuptools distribute &> /dev/null
)
then
if
(
pip-grep
-s
setuptools distribute &> /dev/null
)
then
puts-warn
'The package setuptools/distribute is listed in requirements.txt.'
puts-warn
'Please remove to ensure expected behavior. '
...
...
vendor/pip-pop/pip-grep
View file @
9b185f99
...
...
@@ -2,57 +2,25 @@
# -*- coding: utf-8 -*-
"""Usage:
pip-grep [-s] <
reqfile> <
package>...
pip-grep [-s] <package>...
Options:
-h --help Show this screen.
"""
import
os
from
docopt
import
docopt
from
pip.req
import
parse_requirements
from
pip.index
import
PackageFinder
from
pip._vendor.requests
import
session
from
pkg_resources
import
DistributionNotFound
,
get_distribution
requests
=
session
()
class
Requirements
(
object
):
def
__init__
(
self
,
reqfile
=
None
):
super
(
Requirements
,
self
)
.
__init__
()
self
.
path
=
reqfile
self
.
requirements
=
[]
if
reqfile
:
self
.
load
(
reqfile
)
def
__repr__
(
self
):
return
'<Requirements
\'
{}
\'
>'
.
format
(
self
.
path
)
def
load
(
self
,
reqfile
):
if
not
os
.
path
.
exists
(
reqfile
):
raise
ValueError
(
'The given requirements file does not exist.'
)
finder
=
PackageFinder
([],
[],
session
=
requests
)
for
requirement
in
parse_requirements
(
reqfile
,
finder
=
finder
,
session
=
requests
):
if
requirement
.
req
:
if
not
getattr
(
requirement
.
req
,
'name'
,
None
):
# Prior to pip 8.1.2 the attribute `name` did not exist.
requirement
.
req
.
name
=
requirement
.
req
.
project_name
self
.
requirements
.
append
(
requirement
.
req
)
def
grep
(
reqfile
,
packages
,
silent
=
False
):
def
has_any_distribution
(
names
,
silent
=
False
):
for
name
in
names
:
try
:
r
=
Requirements
(
reqfile
)
except
ValueError
:
if
not
silent
:
print
(
'There was a problem loading the given requirement file.'
)
exit
(
os
.
EX_NOINPUT
)
get_distribution
(
name
)
except
DistributionNotFound
:
continue
for
req
in
r
.
requirements
:
if
req
.
name
in
packages
:
if
not
silent
:
print
(
'Package {} found!'
.
format
(
req
.
name
))
print
(
'Package {name} found!'
.
format
(
name
=
name
))
exit
(
0
)
if
not
silent
:
...
...
@@ -63,10 +31,7 @@ def grep(reqfile, packages, silent=False):
def
main
():
args
=
docopt
(
__doc__
,
version
=
'pip-grep'
)
kwargs
=
{
'reqfile'
:
args
[
'<reqfile>'
],
'packages'
:
args
[
'<package>'
],
'silent'
:
args
[
'-s'
]}
grep
(
**
kwargs
)
has_any_distribution
(
names
=
args
[
'<package>'
],
silent
=
args
[
'-s'
])
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment