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
97ac451a
Unverified
Commit
97ac451a
authored
Mar 06, 2018
by
Kenneth Reitz
Committed by
GitHub
Mar 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pipenv uninstall, and other improvements (#650)
parent
06fa6d23
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
50 deletions
+114
-50
CHANGELOG.md
CHANGELOG.md
+6
-0
compile
bin/compile
+8
-13
pip-uninstall
bin/steps/pip-uninstall
+13
-8
pipenv
bin/steps/pipenv
+60
-29
pip-diff
vendor/pip-pop/pip-diff
+1
-0
pipenv-to-pip
vendor/pipenv-to-pip
+26
-0
No files found.
CHANGELOG.md
View file @
97ac451a
# Python Buildpack Changelog
# 126
Skip installs if Pipfile.lock hasn't changed, and uninstall stale dependencies with Pipenv.
-
No longer warn if there is no
`Procfile`
.
# 125
Set
`PYTHONPATH`
during collectstatic runs, other updates.
...
...
bin/compile
View file @
97ac451a
...
...
@@ -100,12 +100,6 @@ export PKG_CONFIG_PATH=/app/.heroku/vendor/lib/pkg-config:/app/.heroku/python/li
# Switch to the repo's context.
cd
"
$BUILD_DIR
"
# Warn for lack of Procfile.
if
[[
!
-f
Procfile
]]
;
then
puts-warn
'Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.'
puts-warn
'Learn more: https://devcenter.heroku.com/articles/procfile'
fi
# Prepare the cache.
mkdir
-p
"
$CACHE_DIR
"
...
...
@@ -166,7 +160,14 @@ mtime "python.install.time" "${start}"
# Pipenv support.
# shellcheck source=bin/steps/pipenv
source
"
$BIN_DIR
/steps/pipenv"
sub_env
"
$BIN_DIR
/steps/pipenv"
# Uninstall removed dependencies with Pip.
let
start
=
$(
nowms
)
# shellcheck source=bin/steps/pip-uninstall
source
"
$BIN_DIR
/steps/pip-uninstall"
mtime
"pip.uninstall.time"
"
${
start
}
"
# If no requirements.txt file given, assume `setup.py develop` is intended.
if
[
!
-f
requirements.txt
]
&&
[
!
-f
Pipfile
]
;
then
...
...
@@ -197,12 +198,6 @@ sub_env "$BIN_DIR/steps/geo-libs"
# shellcheck source=bin/steps/gdal
source
"
$BIN_DIR
/steps/gdal"
# Uninstall removed dependencies with Pip.
let
start
=
$(
nowms
)
# shellcheck source=bin/steps/pip-uninstall
source
"
$BIN_DIR
/steps/pip-uninstall"
mtime
"pip.uninstall.time"
"
${
start
}
"
# Install dependencies with Pip (where the magic happens).
let
start
=
$(
nowms
)
# shellcheck source=bin/steps/pip-install
...
...
bin/steps/pip-uninstall
View file @
97ac451a
...
...
@@ -2,19 +2,24 @@
set
+e
# Install dependencies with Pip.
# shellcheck source=bin/utils
source
$BIN_DIR
/utils
if
[
[
-f
.heroku/python/requirements-declared.txt
]
]
;
then
if
[
!
"
$SKIP_PIP_INSTALL
"
]
;
then
cp
.heroku/python/requirements-declared.txt requirements-declared.txt
if
[[
-f
.heroku/python/requirements-declared.txt
]]
;
then
pip-diff
--stale
requirements-declared.txt requirements.txt
--exclude
setuptools pip wheel
>
.heroku/python/requirements-stale
.txt
cp
.heroku/python/requirements-declared.txt requirements-declared
.txt
rm
-fr
requirements-declared
.txt
pip-diff
--stale
requirements-declared.txt requirements.txt
--exclude
setuptools pip wheel
>
.heroku/python/requirements-stale
.txt
if
[[
-s
.heroku/python/requirements-stale.txt
]]
;
then
puts-step
"Uninstalling stale dependencies"
/app/.heroku/python/bin/pip uninstall
-r
.heroku/python/requirements-stale.txt
-y
--exists-action
=
w | cleanup | indent
rm
-fr
requirements-declared.txt
if
[[
-s
.heroku/python/requirements-stale.txt
]]
;
then
puts-step
"Uninstalling stale dependencies"
/app/.heroku/python/bin/pip uninstall
-r
.heroku/python/requirements-stale.txt
-y
--exists-action
=
w | cleanup | indent
fi
fi
fi
fi
set
-e
bin/steps/pipenv
100644 → 100755
View file @
97ac451a
...
...
@@ -5,41 +5,72 @@
# shellcheck source=bin/utils
source
$BIN_DIR
/utils
# Pipenv support (Generate requriements.txt with pipenv).
if
[[
-f
Pipfile
]]
;
then
if
[[
!
-f
requirements.txt
]]
;
then
puts-step
"Installing requirements with latest Pipenv…"
# Measure that we're using Pipenv.
mcount
"tool.pipenv"
# Set PIP_EXTRA_INDEX_URL
if
[[
-r
$ENV_DIR
/PIP_EXTRA_INDEX_URL
]]
;
then
PIP_EXTRA_INDEX_URL
=
"
$(
cat
"
$ENV_DIR
/PIP_EXTRA_INDEX_URL"
)
"
export
PIP_EXTRA_INDEX_URL
fi
# Install pipenv.
/app/.heroku/python/bin/pip
install
pipenv
--upgrade
&> /dev/null
if
[[
-f
Pipfile.lock
]]
;
then
if
[[
-f
.heroku/python/Pipfile.lock.sha256
]]
;
then
if
[[
$(
openssl dgst
-sha256
Pipfile.lock
)
==
$(
cat
.heroku/python/Pipfile.lock.sha256
)
]]
;
then
if
[[
!
"
$PIPENV_ALWAYS_INSTALL
"
]]
;
then
echo
"Skipping installation, as Pipfile.lock hasn't changed since last deploy."
| indent
echo
"To disable this functionality, run the following command:"
echo
""
echo
"
$
heroku config:set PIPENV_ALWAYS_INSTALL=1"
| indent
# Install the dependencies.
if
[[
!
-f
Pipfile.lock
]]
;
then
/app/.heroku/python/bin/pipenv
install
--system
--skip-lock
2>&1 | indent
else
/app/.heroku/python/bin/pipenv
install
--system
--deploy
2>&1 | indent
SKIP_PIPENV_INSTALL
=
1
fi
fi
fi
fi
# Install the test dependencies, for CI.
if
[
"
$INSTALL_TEST
"
]
;
then
puts-step
"Installing test dependencies…"
/app/.heroku/python/bin/pipenv
install
--dev
--system
--deploy
2>&1 | cleanup | indent
fi
# Skip pip install, later.
export
SKIP_PIP_INSTALL
=
1
if
[
!
"
$SKIP_PIPENV_INSTALL
"
]
;
then
# Pipenv support (Generate requriements.txt with pipenv).
if
[[
-f
Pipfile
]]
;
then
if
[[
!
-f
requirements.txt
]]
;
then
puts-step
"Installing requirements with latest Pipenv…"
# Measure that we're using Pipenv.
mcount
"tool.pipenv"
# Set PIP_EXTRA_INDEX_URL
if
[[
-r
$ENV_DIR
/PIP_EXTRA_INDEX_URL
]]
;
then
PIP_EXTRA_INDEX_URL
=
"
$(
cat
"
$ENV_DIR
/PIP_EXTRA_INDEX_URL"
)
"
export
PIP_EXTRA_INDEX_URL
fi
# Pip freeze, for compatibility.
/app/.heroku/python/bin/pip freeze
>
requirements.txt
# if [[ -f .heroku/python/requirements-declared.txt ]]; then
# cp .heroku/python/requirements-declared.txt requirements.txt
# fi
# Install pipenv.
/app/.heroku/python/bin/pip
install
pipenv
--upgrade
&> /dev/null
# Install the dependencies.
if
[[
!
-f
Pipfile.lock
]]
;
then
/app/.heroku/python/bin/pipenv
install
--system
--skip-lock
2>&1 | indent
else
pipenv-to-pip Pipfile.lock
>
requirements.txt
"
$BIN_DIR
/steps/pip-uninstall"
cp
requirements.txt .heroku/python/requirements-declared.txt
openssl dgst
-sha256
Pipfile.lock
>
.heroku/python/Pipfile.lock.sha256
/app/.heroku/python/bin/pipenv
install
--system
--deploy
2>&1 | indent
fi
# Install the test dependencies, for CI.
if
[
"
$INSTALL_TEST
"
]
;
then
puts-step
"Installing test dependencies…"
/app/.heroku/python/bin/pipenv
install
--dev
--system
--deploy
2>&1 | cleanup | indent
fi
# Skip pip install, later.
export
SKIP_PIP_INSTALL
=
1
# Pip freeze, for compatibility.
pip freeze
>
requirements.txt
fi
fi
else
pipenv-to-pip Pipfile.lock
>
requirements.txt
export
SKIP_PIP_INSTALL
=
1
fi
vendor/pip-pop/pip-diff
View file @
97ac451a
...
...
@@ -41,6 +41,7 @@ class Requirements(object):
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
requirement
.
req
.
name
=
requirement
.
req
.
name
.
lower
()
self
.
requirements
.
append
(
requirement
.
req
)
...
...
vendor/pipenv-to-pip
0 → 100755
View file @
97ac451a
#!/usr/bin/env python
import
json
import
sys
def
main
():
INFILE
=
sys
.
argv
[
1
]
with
open
(
INFILE
,
'rb'
)
as
f
:
lockfile
=
json
.
load
(
f
)
packages
=
[]
for
package
in
lockfile
.
get
(
'default'
,
{}):
try
:
packages
.
append
(
'{0}{1}'
.
format
(
package
,
lockfile
[
'default'
][
package
][
'version'
]))
except
KeyError
:
pass
print
(
'
\n
'
.
join
(
packages
))
try
:
main
()
except
Exception
:
pass
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