Python not installing with deployment

Hello, I have a python package that serves both the backend and the FE of a web app. I am trying to deploy it. The build succeeds, but Railway never installs Python. Nixpacks only shows npm commands. And the final start command fails because python was never installed. Details attached. In the main root directory, I've got all the files that hint Python is needed: pyproject.toml, poetry.lock and requirements.txt. The package does contain some node files, for tailwind.css and UI stuffs. Any ideas on how to fix this?
23 Replies
Railay
Railay2y ago
I just tried using the Heroku builder and it properly installed Python So it's Nixpacks that's not picking it up
Adam
Adam2y ago
create a runtime.txt file with your current python version inside in the format python-X.X.X Since you’re using two languages you may have to use a specific nixpack, i’m not 100% sure how those behave. Set the NIXPACK_PCKGS environment variable to change those using a package from here: https://search.nixos.org/packages
Railay
Railay2y ago
@A Dumb thanks for the help. I created the runtime.txt file, but it didn't help. This is the only text in the file, assuming it's correct: python-3.11.0
Adam
Adam2y ago
Yeah you’ll need to find a nixpack then, I don’t have any experience in that area, sorry
Railay
Railay2y ago
@A Dumb I don't even need the NPM stuff in production, it's just to pre-build the CSS stuff locally. So I don't want to remove it from Git, but is there an easy way to exclude the files/folders from build? Maybe that's easier
Adam
Adam2y ago
Setting NIXPACKS_PYTHON_VERSION may force nixpacks to use python. Setting a custom build command will let you exclude the files you don’t want otherwise, maybe move the npm stuff to a different repo and gitignore it in your current folder structure. that’s the easy fix
Railay
Railay2y ago
Unfortunately, none of these solutions worked (I haven't tried removing Node code yet, that's a last resort... ) Setting these env variables don't force Nix to install python: NIXPACKS_PYTHON_VERSION=3.10 NIXPACK_PCKGS=python310 And adding the runtime.txt file with python-3.11.0 didn't solve it either.
Adam
Adam2y ago
weird, I’m not sure then sorry don’t have too much experience with wrangling nixpacks
Railay
Railay2y ago
All good, I really appreciate the ideas! Hopefully someone else has ideas on how to solve it Seem strange that Nixpacks wouldn't install python if it found all the prerequisites
angelo
angelo2y ago
Messaging here so I have visibility, will answer you problem soon
Railay
Railay2y ago
Thanks @Angelo !
I'm sure you're swimming in support tickets. so the TL;DR of my problem: I'm able to successfully deploy and run my app with the Heroku buildpack, but Nix fails because it doesn't install Python or any dependancies. It treats my Python package like a Node package.
angelo
angelo2y ago
Swimming is an understatement lol- lets see what we can do here. Project Id?
Railay
Railay2y ago
34108dc5-7795-469f-b853-2863bbedfa6f
angelo
angelo2y ago
If you can, can ya share a GitHub repo? also, do you have a procfile?
Railay
Railay2y ago
The repo is private, but yes, I do have a procfile I’m using Starlite, which is an ASGI framework similar to FastAPI If that helps
angelo
angelo2y ago
Does indeed!
Railay
Railay2y ago
Here’s the main directory structure
angelo
angelo2y ago
Oh that package.json is sure going to throw us for a loop lemme talk with our engineers here
Railay
Railay2y ago
Thx! It’s just for tailwind CSS and some UI components. I don’t actually need NPM in prod. But either way… shouldn’t NIX install both node packages and Python? Not sure why it ignores Python. While heroku picks it up
angelo
angelo2y ago
Yep- just knocked out some other cases. Digging in, you may see some failed builds. Don't be alarmed, that is me. Okay @Railay - so apparently the heroku buildpacks would prioritize Python over Node in the install order. We do the opposite, hence the bug. the fix is making a nixpacks.toml with the following contents
providers = ["python"]
providers = ["python"]
This should solve your issues going forward
Railay
Railay2y ago
@Angelo thanks! That seems to solve it, much appreciated 🙏
angelo
angelo2y ago
Woo hoo!
Railay
Railay2y ago
Btw, I’ve been using railway for ~12 hours now and I love it. Amazing product so far, kudos to you and the railway teams!