Coder Social home page Coder Social logo

manage.py import error about django-ex HOT 12 CLOSED

sclorg avatar sclorg commented on May 27, 2024
manage.py import error

from django-ex.

Comments (12)

cjryan avatar cjryan commented on May 27, 2024

Seeing similar behavior when running the latest Vagrant install of origin, as well.

from django-ex.

csrwng avatar csrwng commented on May 27, 2024

@cjryan I can reproduce this on an aws RHEL machine with the latest origin ami

from django-ex.

rhcarvalho avatar rhcarvalho commented on May 27, 2024

@cjryan the problem is origin v1.1.3 + template@latest-master.

See openshift/origin#7379 (comment)

Unfortunately, unlike in origin's sample-app, this repo is not being tagged with every origin release.
Please use an older version of the template for now:

$ oc new-app https://raw.githubusercontent.com/openshift/django-ex/4706c39a7035/openshift/templates/django-postgresql.json

And for the next releases we'll have vendored copies of the templates in origin:
https://github.com/openshift/origin/tree/master/examples/quickstarts

Other than that we need to discuss if we want to make any changes here.
@bparees any opinion on the matter?

from django-ex.

cjryan avatar cjryan commented on May 27, 2024

@rhcarvalho thanks for taking a look at this. Unfortunately, that version of the the older template won't work, as we are explicitly testing the

"postCommit": {
     "script": "./manage.py test"
}

functionality. It looks like we'll have to hang tight until the vendored copies of the templates are available.

from django-ex.

rhcarvalho avatar rhcarvalho commented on May 27, 2024

@cjryan aha got it. You can use the command and/or args form:

"postCommit": {
     "args": ["./manage.py", "test"]
}

or

"postCommit": {
     "command": ["/bin/bash", "-c", "./manage.py", "test"]
}

or

"postCommit": {
     "command": ["/bin/bash", "-c"],
     "args": ["./manage.py", "test"]
}

and some other combinations of those ;)

The underlying problem here is that v1.1.3 runs the script form of the hook using /bin/sh -c, and that doesn't work with our automation to enable scl collections. After the release we changed it to /bin/sh -ic which will work with scl out-of-the-box.

If you still want to test the script form in v1.1.3, you will need to enable the Python collection explicitly in the script:

"postCommit": {
     "script": "scl_enable python[VERSION] ./manage.py test"
}

from django-ex.

rhcarvalho avatar rhcarvalho commented on May 27, 2024

FWIW, the error message ImportError: No module named django.core.management is coming from the system Python, not from the SCL Python version where django and all other dependencies were installed.

from django-ex.

GrahamDumpleton avatar GrahamDumpleton commented on May 27, 2024

This problem would be avoided if a Python virtual environment was being used in the image and the bin directory for that was in the PATH. SCL Python only then needs to be enabled during the build phase for the image. See sclorg/s2i-python-container#90 (comment)

from django-ex.

rhcarvalho avatar rhcarvalho commented on May 27, 2024

@GrahamDumpleton I'm not entirely sure, at least not for all apps.
If you run something that depends on a shared library, scl_enable is also setting LD_LIBRARY_PATH, among other things, that would not be correctly set in the virtualenv. Does that make sense? Or is that important only on build time?

I'm all in favor of having the Python image use virtualenv.

While it could alleviate the problem for Python, it's a non-solution for other languages. We still need to deal with enabling collections...

from django-ex.

GrahamDumpleton avatar GrahamDumpleton commented on May 27, 2024

Especially if the install location of SCL packages is fixed as being /opt/rh they should be compiling the Python binaries with a LD_RUN_PATH compiled into them of /opt/rh/python27/root/usr/lib64. That is what one would normally do if installing Python into a non standard location. That way LD_LIBRARY_PATH isn't needed at run time. Either way, simply set LD_LIBRARY_PATH in the Docker image.

from django-ex.

rhcarvalho avatar rhcarvalho commented on May 27, 2024

@GrahamDumpleton thanks for the explanation! I don't know how the SCL Python binaries are compiled. The LD_LIBRARY_PATH was one that came to mind because it tripped me up in the past ;)

Setting envs in the Dockerfile is something we have discussed though, but yet haven't gone that path because AFAIK we don't have a clean way to get what are the env changes after a "scl_enable some-collection" run.

If you have any trick on how to do that, I'd be interested to hear/read ;)
I believe if we had a script that we run and it spits out Dockerfile ENV instructions that are equivalent to enabling a collection, that would make our lives happier.

💡 Perhaps a Python script that captures the current environment, run scl_enable and then compare the new with the old environment interpreting diffs in a smart way (like additions to PATH instead of replacement).

from django-ex.

rhcarvalho avatar rhcarvalho commented on May 27, 2024

The problem has been explained and solutions listed in #34 (comment)

Closing this, @cjryan please let me know if you still have trouble and I can reopen.

from django-ex.

cjryan avatar cjryan commented on May 27, 2024

@rhcarvalho @GrahamDumpleton Apologies for the delayed response, thank you for the solutions to the issue at hand.

from django-ex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.