Comments (8)
Thanks a lot for your kind words and detailed report, those are very appreciated!
I can try to update the assemble script to use pip install .
also for projects with pyproject.toml
that sounds reasonable. I'm a little bit afraid that the pip we have in UBI8 might be too old to support this but that's easily fixable by UPGRADE_PIP_TO_LATEST
env variable.
Do you know about any project I can test the change on? All projects I found so far have at least minimal setup.py files for compatibility.
FYI, I'll take a look at this next week because I'll be out of the office till the end of the week.
from s2i-python-container.
Hi @frenzymadness , thanks for the fast response.
Indeed, I guess in order to support the pyproject.toml the condition should be that ! -z "$UPGRADE_PIP_TO_LATEST" && -f pyproject.toml
.
So far, I do not have a public project for this. But I suppose I could make a public poetry project. Just not sure how to test the s2i build for it.
Would it be sufficient if I created a public repo that has a minimal poetry project in there? (With poetry project, I mean a project that uses pyproject.toml)
from s2i-python-container.
To be complete and for anyone else stumbling upon this issue.
As long as we import absolute and without modules, s2i works fine.
But as soon as you try to import from your root module, it will fail, since the pip install .
never happened.
As a current workaround we added an .s2i/bin/assemble
script with following content:
#!/bin/bash
echo "Before assembling"
/usr/libexec/s2i/assemble
rc=$?
if [ $rc -eq 0 ]; then
echo "After successful assembling"
pip install .
rc=$?
echo "Ran pip install ."
else
echo "After failed assembling"
fi
exit $rc
Ofcourse it would be great if we didn't have to ship our projects with a custom assemble script, but at least we are no longer blocked to deploy our images on openshift.
While writing this, we could likely also have used an empty setup.cfg file or something, but when debugging this did not seem to work, however, I think it was just my mind that was blurry and something went wrong with adding the setup.cfg :)
from s2i-python-container.
I have just created a minimal poetry project and made it public.
I added requests as a main dependency and black as a dev dependency.
I didn't use any proxy for the requirements, so this repo should be usable by anyone.
If there is anything else I could add to make the s2i usage more easy, let me know and I will (try to) add to this project.
The project: https://github.com/shifqu/minimal-poetry
from s2i-python-container.
Thanks for the example. I'm testing it now. Could you please help me understand what kind of import didn't work for you when the app itself is not installed? When I build a container image with the example project, I see it in the working directory so import minimal_poetry
should work.
What I've tried is to have these modules in the minimal_poetry package:
a.py with some content:
foo = 8
b.py with a relative import:
from .a import foo
c.py with absolute import:
from minimal_poetry.a import foo
And it seems that all of them works fine:
>>> from minimal_poetry import a
>>> from minimal_poetry import b
>>> from minimal_poetry import c
The reason is that CWD /opt/app-root/src
is in PYTHONPATH and therefore all packages from that path are importable.
from s2i-python-container.
Thanks for testing this!
So I checked again and apparently, I had left out an important detail of our setup, which is that we use a src
layout. I recreated the minimal_poetry package minimal-poetry-src-layout. This was done by running poetry new $ProjectPath --src
.
I also included the a, b and c files already and once again added requests as a regular dep and black as a dev-dep.
Could you try again with this set-up?
Maybe there is an ENV var that we can set? Like $APP_HOME? I have tried setting the APP_HOME, but then I still get the ModuleNotFound error. I suppose this is because in the run
script we add pwd
to the path before we cd into app_home. link to run relevant line in run script
I think maybe the title of this issue should become something along the lines of Cannot use absolute imports in poetry project with src-layout
Apologies for not mentioning the src layout earlier, I had thought it was merely a detail 🤦♂️
Also, since this is quite an exotic scenario (poetry in combination with src layout), I would understand if you'd lower the priority on this. We currently work around this by shipping our repos with an assemble script as I mentioned in an earlier comment.
from s2i-python-container.
I had the solution since the last week but I hoped I'll be able to test a new CI config on it. It seems that the new CI will take much longer so I've opened #575 to not block this. Would you mind taking a look at the proposed solution?
from s2i-python-container.
Thanks @frenzymadness! I reviewed and put my stamp of approval on the PR :)
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
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.