-
Notifications
You must be signed in to change notification settings - Fork 99
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
refactor: use pipenv to manage dependencies #150
Conversation
# Install certain utility packages like `nodeenv` and `wheel` that aid | ||
# in the installation of other build tools and dependencies | ||
# required by the other python packages. | ||
PIPENV_VERBOSITY=-1 PIPENV_PIPFILE="${script_dir}/../pulumi/python/Pipfile" pipenv install --dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotation:
Here we are:
- Silencing an informational message telling us that pipenv is going to use the current venv with
PIPENV_VERBOSITY=-1
- Pointing
pipenv
at ourPipfile
which is not in the current dir withPIPENV_PIPFILE
- Only installing
dev
depenencies which are currentlynodeenv
andwheel
@@ -195,12 +194,15 @@ else | |||
fi | |||
|
|||
# Install general package requirements | |||
pip3 install --requirement "${script_dir}/../pulumi/python/requirements.txt" | |||
PIPENV_VERBOSITY=-1 PIPENV_PIPFILE="${script_dir}/../pulumi/python/Pipfile" pipenv install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotation:
Here we are:
- Silencing an informational message telling us that pipenv is going to use the current venv with
PIPENV_VERBOSITY=-1
- Pointing
pipenv
at ourPipfile
which is not in the current dir withPIPENV_PIPFILE
- Installing all packages
pip3 install "${script_dir}/../pulumi/python/utility/kic-pulumi-utils" | ||
|
||
rm -rf "${script_dir}/../pulumi/python/utility/kic-pulumi-utils/.eggs" \ | ||
"${script_dir}/../pulumi/python/utility/kic-pulumi-utils/build" \ | ||
"${script_dir}/../pulumi/python/utility/kic-pulumi-utils/kic_pulumi_utils.egg-info" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotation:
Removing the &&
prevents an issue where if the pip install does not work the script would not fail. The rm
operation should not fail either way.
bin/setup_venv.sh
Outdated
echo "Downloading Pulumi CLI into virtual environment" | ||
PULUMI_VERSION="$(grep '^pulumi~=.*$' "${script_dir}/../pulumi/python/requirements.txt" | cut -d '=' -f2 || true)" | ||
PULUMI_VERSION="$(pip list | grep 'pulumi ' | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotation:
Here we read the pulumi version from pip to get the version that was actually installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great change! 🍥
bin/setup_venv.sh
Outdated
pip3 install --upgrade pip | ||
pip install pipenv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use pip3
here to bring it in harmony with the above line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me...
Using pip and `requirements.txt` led to issues where dependent library versions were unpredictable and led to errors in some deployment environments. This will also allow us to use semantic version properly without needing to explicitly pin dependencies at certain versions but perform updates to libraries intentionally.
What
Using pip and
requirements.txt
led to issues where dependent library versions wereunpredictable and led to errors in some deployment environments.
This will also allow us to use semantic version properly without needing to explicitly
pin dependencies at certain versions but perform updates to libraries intentionally.
Proposed changes
Pipenv
which will generate aPipfile.lock
detailing the exact versions of dependencies and their dependencies. This will help us have more reproducible builds since each dependency and subdependency will be installed at the exact version it was tested with.pip
rather than reading from the requirements file (since that's not an exact version).Pipenv Usage
pipenv
is compatible with any commands that can be given topip
. There are some niceties that are good to know too:graph
Prints the dependency graph with the
Pipfile
specs and the actual version resolved to.Figuring out updates
You can use
pipenv update --outdated
to display a list of packages that have newer versions in the upstream.From there, you can choose to update them one by one with
pipenv update <package name>
which will update the package according to the rules specified in thePipfile
. You may need to change the specification in thePipfile
to get the latest version.https://pipenv-fork.readthedocs.io/en/latest/basics.html#example-pipenv-upgrade-workflow
Checklist
Before creating a PR, run through this checklist and mark each as complete.