Python and .Net together
awall
HOBBYOP

a year ago

I am deploying a Django site on railway. So far so good, it's using the Nixpacks and building everything in my requirements.txt file, and launching Django correctly.

My problem: I need to use a library that's implemented in .Net, so my deployment requires both .Net 6.0 SDK, and python, at the same time.

I added a .csproj file, so that the build would install the .Net SDK, but now... it no longer installs python! How do I get both python and .Net SDK included at the same time?

Here's my dummy foolrailway.csproj file:

```

net6.0

and here's my railway.json.

```

{

"$schema": "https://railway.app/railway.schema.json",

"build": {

"builder": "NIXPACKS"

},

"deploy": {

"startCommand": "python manage.py collectstatic && gunicorn www.wsgi",

"restartPolicyType": "ON_FAILURE",

"restartPolicyMaxRetries": 10

}

}

```

Solved$10 Bounty

Pinned Solution

awall
HOBBYOP

a year ago

Solved, two things required for this to work:

  1. As described in the Nixpacks docs, I added a nixpacks.toml with [phases.setup] nixPkgs = ['...', 'dotnet-sdk_6'] .
  2. Instead of importing import ironxl (the official package), I looked at their __init__.py, extracted the parts I need, and wrote my own wrapper for the .Net libraries. I will be posting a patch to the IronXL folks to get their official python module fixed for Linux.

4 Replies

a year ago

Hey, can you try adding the Python and C# providers directly by modifying your railway.json?

{

"build": {

"builder": "NIXPACKS",

"nixpacksPlan": {

"providers": [

"python",

"c#"

]

}

}

}


awall
HOBBYOP

a year ago

I ended up adding a nixpacks.toml , and got that working there. Now I have a harder problem to solve... the python library I'm using, IronXL, seems to think .net is not installed, even though it is. Looking at the python packages source code, it's non-Windows code seems a little flaky...

I may have to switch to Docker instead of Nixpacks to sort this out, thank you anyway.


awall
HOBBYOP

a year ago

Yeah this is lame. Installing the package places the dll in /opt/venv/IronXLNet/IronXL.dll , but when I import the package, its __init__.py is looking inside of /opt/venv/../../.. . I guess it's just a bug in their package and nobody tested that it actually works in Linux. sigh. I guess I need to fork it...


awall
HOBBYOP

a year ago

Solved, two things required for this to work:

  1. As described in the Nixpacks docs, I added a nixpacks.toml with [phases.setup] nixPkgs = ['...', 'dotnet-sdk_6'] .
  2. Instead of importing import ironxl (the official package), I looked at their __init__.py, extracted the parts I need, and wrote my own wrapper for the .Net libraries. I will be posting a patch to the IronXL folks to get their official python module fixed for Linux.

Status changed to Solved chandrika about 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...