#Deploy python package (using poetry)

52 messages · Page 1 of 1 (latest)

raven marsh
#

Hi, I'm trying to add python telegram bot to Railway, I'm using start command as "poetry run .. " and I'm getting error importing module itself, how can I debug it?

pallid nicheBOT
#

Project ID: 66db9613-0a35-482d-be9e-217c9a0b1a17

#

When you deploy, the Railway container will look for requirements.txt, pyproject.toml and/or poetry.lock files in the root directory. It should automatically detect and install any dependancies.

raven marsh
#

66db9613-0a35-482d-be9e-217c9a0b1a17

knotty crater
#

Please post your repo and full logs

raven marsh
#

It's seems to be poetry issue, there is a way to debug the env maybe?

#

Or reproduce it? I'm running locally: poetry install, then poetry run... (my command), and it's just work

knotty crater
#

No, it doesn’t look like a poetry issue

raven marsh
#

If I disable the venv it's almost works (detect the package)

knotty crater
#

it looks like you’re trying to import maccabipediabot which is the sole folder inside of src

raven marsh
#

Yea, it's the package that I install as part of poetry install

#

It seems that the installation process isn't using the venv of poetry but a general python

knotty crater
#

I know next to nothing about poetry, but to me it looks like you should get rid of your src folder and move maccabipediabot up a level

#

or instead of importing maccabipediabot, import src.maccabipediabot

raven marsh
#

That works locally, that something with the remote setup, do you know if I can debug the remote env?

#

if I disable the virtualenv creation I get to pass this failed import

frigid flare
#

looks like you dont have a requirments.txt

knotty crater
#

no, that’s not the issue

raven marsh
#

I have pyproject.toml (that include the requiremnts)

knotty crater
#

maccabipediabot is not a package they’re importing, it’s part of their code

frigid flare
#

gotcha

raven marsh
#

That the package itself yea

knotty crater
#

I’m not sure what you mean by debug the environment

raven marsh
#

By debug I mean connect to the shell that will allow me to execute commands on the failed env

#

something is wrong with the python setup over there

knotty crater
#

No, that’s not possible

#

once your deployment crashes you cannot gain access to it

raven marsh
#

If I'll change the start command to be sleep? I would be able to access it?

knotty crater
#

if your deployment is live you’re able to access a shell-like through the railway cli

raven marsh
#

I'm not sure if you are able to see the deploy logs (I connected the app to here), but if you don't I have this log line: #11 27.30 Installing the current project: maccabipediabot (0.14.4)

#

Which means that the package itself is being installed

#

But I think that everything is being created is a venv which is not poetry, can I override the installation command somehow?

knotty crater
#

I’m not part of the team so I’m not able to directly access your project

raven marsh
#

It should be just "poetry install"

knotty crater
#

Yes, you can create a nixpacks.toml to set all the parameters you should need

#

or create a dockerfile

raven marsh
#

I still see the old install command: #14 [stage-0 10/11] RUN --mount=type=cache,id=s/5eed4029-c51e-4192-8653-1a37570e9201-/root/cache/pip,target=/root/.cache/pip python -m venv /opt/venv && . /opt/venv/bin/activate && pip install poetry==1.3.1 && poetry install --no-dev --no-interaction --no-ansi

#

And yes it seems like it's opening a special venv (which is not needed)

knotty crater
#

Again, I’m really not familiar at all with poetry so I don’t know what environments are supposed to be opening or not

#

if you remove poetry from your project it should work fine, as that seems to be the problem

#

or do what I said above and shift maccabipediabot up a folder

raven marsh
#

I did it and got:
import _tkinter # If this fails your Python may not be configured for Tk

#

What will be the best approach to debug it? or to reproduce it locally

knotty crater
#

does tkinter require any external programs/packages to be installed? Either it’s not being pip installed correctly or you’re missing a requirement

#

if you’re missing a requirement, chances are there’s a nixpack for it. Add it to the setup section of your nixpacks.toml

#

you can search packages here

raven marsh
#

That a builtin module

knotty crater
#

Then it’s time to stackoverflow the error

raven marsh
#

It seems that the remote py is without gui, I'll hack that ty!

#

I'm on the free tier (verirified account 500 hours), that is maybe a good way to make my project shutdown by hours or similar? in order to have the free tier be avail for the entire month?