Comments (7)
i'd almost rather see us just look for it in root and if you want it somewhere else, we give you an env variable to tell us which manage.py file you want to use. how does that sound?
from s2i-python-container.
Rather than environment variable giving path to manage.py in sub directory, my current thinking is that you give it the directory name for the Django project if not in root. The scripts would then look for manage.py within that directory itself rather than user calling it out explicitly. Thus instead of:
DJANGO_MANAGE_SCRIPT=hello/manage.py
would use:
DJANGO_PROJECT_NAME=hello
or similar.
from s2i-python-container.
DJANGO_PROJECT_DIR ?
from s2i-python-container.
To match Django's own name for the directory in settings.py
, probably should use DJANGO_BASE_DIR
. The settings.py
file contains:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
where BASE_DIR
acts as the anchor point for any configuration to work out where stuff is inside of the project. The calculation should end up being the directory containing the manage.py
so matches the directory we want to have be referenced. Thus should use same name stem.
from s2i-python-container.
Rather than making this Django specific, one could generalise it. In that case have generic APP_ROOT
where the default currently is effectively /opt/app-root/src
. Setting it would mean that all checks would be done relative to the new directory. This way can also apply to checks for app.py
and wsgi.py
.
I chose APP_ROOT
here because other override variables are APP_FILE
and APP_MODULE
, so carrying through APP_
prefix. Using APP_ROOT
may be confusing though when one considers that everything is under /opt/app-root
, yet APP_ROOT
doesn't actually point to that by default, but the src
subdirectory.
As far as overriding APP_ROOT
, the simple solution would be that it causes the current working directory to be changed to that directory before anything else is done. The one complication this presents is PYTHONPATH
for Python module searches. The /opt/app-root/src
directory would be in the module search path due to the fact that command line execution of Python results in special empty string in sys.path
, which means look in current working directory. Change the working directory and it will no longer look in /opt/app-root/src
so if changing directory because APP_ROOT
is set, then should add /opt/app-root/src
to PYTHONPATH
explicitly. There is actually good argument to add new directory specified by APP_ROOT
to PYTHONPATH
explicitly as well anyway. This will protect against badly written user code which changes the current working directory itself causing modules then not to be found.
from s2i-python-container.
Alternate name for variable may be APP_HOME
. Using HOME
in name gives sense that the current working directory or home directory for the application will be changed.
from s2i-python-container.
Depending on where you change working directory may complicate working out name of WSGI module from setup.py
as need to be in the top level directory to run setup.py
, you cannot run it from within a different directory as not really guaranteed to work. I think I have separately questioned whether is a good idea to use name of module installed by setup.py
. Better to make it explicit by requiring use supply a wsgi.py
.
from s2i-python-container.
Related Issues (20)
- Streamlit Update HOT 1
- No Action Required !! Testing automation workflow HOT 1
- No Action Required !! Testing automation workflow HOT 4
- Remove verification of installed packages HOT 3
- 3.9 Readme Instructions unclear HOT 6
- Python 3.10 RHEL image missing in RHEL Container catalog? HOT 4
- Unable to build a Python image from scratch on MacOS HOT 1
- Python 3.9+ for Centos 7 docker images HOT 4
- tests: test case should fail early when the prepare function fails HOT 3
- Distgen errors HOT 11
- Incorrect py-3 image HOT 11
- Support gunicorn >=20.1.0 defaults (do not require APP_ environment variables) HOT 1
- Add RHEL images for Python 3.11 HOT 4
- ERROR: No matching distribution found for numpy==1.19.2 HOT 4
- Use PIP_INDEX_URL with pipenv HOT 1
- ubi9/python-311:latest is using python3.9-rpm HOT 2
- Publish arm64 images HOT 8
- rh-python38 failed on `'npm-virtualenv-uwsgi-test-app' run_s2i_build` & `'pin-pipenv-version-test-app' run_s2i_build` HOT 2
- python311-devel not found by microdnf in python 3.11 minimal EL8 and C9s variants HOT 1
- Documented pull example quay.io/sclorg/python-39-minimal isn't a valid URL HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s2i-python-container.