-
Notifications
You must be signed in to change notification settings - Fork 75
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
Remove --upgrade
from pip install
#1136
Remove --upgrade
from pip install
#1136
Conversation
Not sure we should change priority between PYDEPS and reqs.txt. |
This doesn't change priority, it just fixes that unpinned PYDEPS will not override pinned requirements.txt deps |
I think this is reasonable, but I'll have to check for edge cases this might break. (@cmatsuoka can you think of any?) If we make this change though, I'd like a behaviour test for this with a link to #1135 so we don't break this later. |
I'm not sure how to implement this—let me know if you'd like me to try to add a behavior test Here's a simple example: |
Any idea how this should interact with version pinning specified in |
@carlcsaposs-canonical A spread test something like this should do it: (Caveat: I haven't run this test) summary: pack a charm with a specific (old) dependency version
include:
- tests/
prepare: |
tests.pkgs install unzip
charmcraft init --project-dir=charm
cd charm
echo "ops==2.0.0" > requirements.txt
cat <<- EOF >> charmcraft.yaml
parts:
charm:
charm-requirements: [requirements.txt]
EOF
cat <<- EOF > lib/charms/charm/v0/my_lib.py
PYDEPS = ["ops"]
LIBID = "my_lib"
LIBAPI = 0
LIBPATCH = 1
EOF
restore: |
pushd charm
charmcraft clean
popd
rm -rf charm
execute: |
cd charm
charmcraft pack --verbose
test -f charm*.charm
unzip -p charm_*.charm venv/ops/version.py | MATCH "version = '2.0.0'" |
@sed-i (I could be wrong but) that it'll install necessary updates, but not update anything not necessary for the PYDEPS. One potential edge case here is if the first thing that requires a particular dependency is a charmlib. Take for example a requirements.txt file that says:
and a lib that requires
This would install the latest ops, bringing an updated websocket-client with it, which is probably not what's intended. If we had charmcraft run If the lib requires Feel free to weigh in about preferred behaviours and backwards compatibility — I'll reach out to a few others to consider options too. |
Good point! It looks like installing all the dependencies in one Except it seems like binary dependencies cannot be installed in the same command |
Charmcraft could run However, even if there aren't conflicts, later commands could still override binary dependencies Instead of using |
Also just want to mention that because of #1077, pip doesn't have access to the full dependency resolution i.e. during charmcraft's build, |
Nice to have: it'd be great if whatever solution is implemented is compatible with #1115 (feature request) |
@@ -239,26 +239,26 @@ def _install_dependencies(self, staging_venv_dir): | |||
with instrum.Timer("Installing all dependencies"): | |||
if self.binary_python_packages: | |||
# install python packages, allowing binary packages | |||
cmd = [pip_cmd, "install", "--upgrade"] # base command | |||
cmd = [pip_cmd, "install"] # base command |
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.
cmd.extend(self.binary_python_packages) # the python packages to install | ||
_process_run(cmd) | ||
|
||
if self.python_packages: | ||
# install python packages from source | ||
cmd = [pip_cmd, "install", "--upgrade", "--no-binary", ":all:"] # base command | ||
cmd = [pip_cmd, "install", "--no-binary", ":all:"] # base command |
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.
It looks like the Jupyter notebooks charm is failing because of this (see spread test.
Between this and the above, I'm wondering whether the right change for now might be to keep the --upgrade
here and above and merge the two commands below (given the edge case we discussed in the main conversation).
I believe that'll resolve #1135 with a fairly minimal change that we can put into a 2.4 release fairly quickly, with a bigger rethink of package handling for a future release. How's that sound?
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.
Or we can change the order of install requirement.txt
and PYDEPS
.
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.
So if a pinned version is installed, pip install
without --upgrade
will not try to get a new version. And if the package is not in requirement.txt
, it will install latest stable version.
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.
That was my original thought, but it could leave us with invalid PYDEPS that we won't discover until runtime.
Example:
PYDEPS includes pkg_a>=2.0
, and requirement.txt includes pkg_a==1.0
Ideal behaviour would probably be to error out during the charm build due to a dependency conflict. However:
- Current behaviour: we get
pkg_a>=2.0
and a maybe-working charm. - Alternative behaviour: we get
pkg_a==1.0
and an almost-guaranteed-broken charm.
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.
Then we need to check all deps in charmcraft without rely on pip
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.
Or maybe we can add PYDEPS
to a new requirement.txt
Superseded by #1157 |
Fixes #1135