sclorg / s2i-python-container

Python container images based on Red Hat Software Collections and intended for OpenShift and general usage, that provide a platform for building and running Python applications. Users can choose between Red Hat Enterprise Linux, Fedora, and CentOS based images.
http://softwarecollections.org
Apache License 2.0
260 stars 324 forks source link

Support pip in off-line environments #216

Open hhorak opened 7 years ago

hhorak commented 7 years ago

More details in https://bugzilla.redhat.com/show_bug.cgi?id=1446978

I think this may be implemented by making the assemble scripts extensible; a simple approach would be to allow running some arbitrary script from the application sources during the assemble phase, for example we can say that s2i-assemble/*.sh will be sourced during the assemble process..

GrahamDumpleton commented 7 years ago

This is returning back to action hooks of V2. Since there has been little interest in adding back action hooks across S2I builders in the past, for Python at least you can direct people to:

GrahamDumpleton commented 7 years ago

FWIW, you likely could use this now to allow use of pipenv. I will try and get together a sample to show how.

hhorak commented 6 years ago

I went through the powershift and powershift-image docs, but using those to change the assembly and run scripts seems like quite big overhead to me. IIUIC, that basically forces users to use powershift instead of either oc or web console. Why something like that should be better solution than allowing users to influence the scripts by a file in the application?

GrahamDumpleton commented 6 years ago

Using powershift doesn't make people stop using oc or the web console.

Where the confusion probably arises is that powershift is a thing which has different optional parts under one command so you have one base command rather than many. What parts of that you install or use is up to a user.

The powershift-image part only works inside of a running container and doesn't work outside on your own computer, so it cannot replace oc or the web console.

Anyway, is a moot point. For the original issue which was supporting pip and easy_install in offline environments, you can see proof of concept of minimal changes to allow it at:

This was done as wrapper for now with intention of later creating PR with changes to be added to main S2I builder. All it needs to do is generate the configuration file for easy_install based off pip environment variables. That way you just need to set the environment variables to have pip work in offline mode and easy_install will follow.

The proof of concept was being tested by people who needed it but haven't heard back anything about it.

hhorak commented 6 years ago

@torsava @mcyprian FYI

hhorak commented 6 years ago

As this issue mentioned extensibility hooks in assemble script, this might be interesting to read, since there are many thoughts relevant to this issue: https://github.com/openshift/source-to-image/issues/573 https://github.com/getwarped/action-hooks

frenzymadness commented 5 years ago

Is this issue still relevant? I think that provided solutions might be easily applicable to any build and with the use of environment variables like PIP_FIND_LINKS and PIP_NO_INDEX it's pretty easy.

GrahamDumpleton commented 5 years ago

It isn't pip which is the main issue but when setup.py and easy_install is used. You cannot control what happens with a setup.py or easy_install install using environment variables. You have to create a ~/.pydistutils.cfg. This is messy to do as need to use a custom assemble script wrapper or use a build input secret defined in the build config and have that added to the container at build time. Both are non obvious. What needs to be done is have ~/.pydistutils.cfg be generated if it doesn't already existed, with it being configured based on the values of the pip environment variables. This can be done from the assemble script and would mean only have to set pip environment variables.

Note that one may also need to look at what requirements there are for having pipenv work in an offline mode as it may required its own special configuration.

So I believe this issue is still relevant and needs to be looked into at some point. It is known some customers are needing to do this and are currently relying on custom assemble scripts which had to be provided to them.