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

How to exclude a certain package from pip-sync? #686

Closed
Midnighter opened this issue Sep 29, 2018 · 8 comments
Closed

How to exclude a certain package from pip-sync? #686

Midnighter opened this issue Sep 29, 2018 · 8 comments
Labels
question User question

Comments

@Midnighter
Copy link

This is a more broad question about how to approach a specific workflow.

My use case is the following: I want to layer multiple Docker images. In the easiest case I have one base image that uses pip-tools to install a number of packages. Subsequent images "inheriting" from that base image then need to specify all compiled requirements files in order to not remove packages with pip-sync. So far so good.

My problem is that the base image should also install a large package from a local source. I can simply specify this dependency with -e path/to/local/package and be done with it but that requires me to keep content of that directory around. Since I try to keep my Docker layers small I would ideally only install the package once and then remove the directory again. However, if I remove the directory pip-sync obviously fails. So is there an easy way for me to exclude that local package from being considered by pip-sync? That would make my life a lot easier.

@atugushev
Copy link
Member

atugushev commented Apr 24, 2019

Good question! Maybe we need to implement something like --no-uninstall or --safe option?

@atugushev atugushev added the question User question label Apr 24, 2019
@Midnighter
Copy link
Author

--no-uninstall for this kind of workflow would be stellar indeed!

@AndydeCleyre
Copy link
Contributor

Another thought, @Midnighter :

After you build your frozen .txts and start layering, is there any real advantage to using pip-sync at all, over plain old pip install -r? IMO one of the greatest strengths of this project is that it produces highly compatible, long-standard specification files, and doesn't generally need to be used during deployment operations.

If you have in your .in file:

file:PATH/TO/PKG#egg=PKGNAME==PKGVER

that line will be present in the .txt as well, and pip install -r should not mess with its installation if it detects the req is already satisfied.

@merwok
Copy link

merwok commented Jan 17, 2020

A big feature of pip-sync is uninstalling now-unneeded packages.
The presence of a package can change behaviour, if if was installed as a soft dependency of another project that uses package detection to enable optional features, so people wanting truly reproducible environments will use pip-sync.

@AndydeCleyre
Copy link
Contributor

@merwok pip-sync will not guarantee reproducible behavior if the packages are relying on package detection to determine dependencies anyway (#992).

In this context, though I can't see the build scripts, I'd imagine there's a lot of predictability ensured by the container build process.

@merwok
Copy link

merwok commented Jan 17, 2020

I was talking about runtime, not install-time 🙂

@AndydeCleyre
Copy link
Contributor

@merwok

Sorry, my mind might be elsewhere, but I don't know what you're getting at.

My understanding is that this issue is about deployment workflow.

@Midnighter
Copy link
Author

My understanding is that this issue is about deployment workflow.

Indeed, the context is about layering 2-3 container images and making them fully reproducible/deterministic.

After you build your frozen .txts and start layering, is there any real advantage to using pip-sync at all, over plain old pip install -r? IMO one of the greatest strengths of this project is that it produces highly compatible, long-standard specification files, and doesn't generally need to be used during deployment operations.

This is a fair point and that is actually what I have been doing to get around the issue. It just seems natural to use pip-sync when I use pip-compile to prepare the requirements, hence this issue. If I'm not missing out on anything else that pip-sync is doing then I'm happy to continue to use the following command (I do generate and want to check hashes):

pip install --require-hashes -r requirements.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User question
Projects
None yet
Development

No branches or pull requests

4 participants