Ignoring the requirements.txt

Hey folks,

very happy netlify user here so far however, now we have an issue. We’re hosting our project-documentation via netlify. Our project is built on python. Although the page-generation is also built in python, i’m keeping that separate as we might use different python-versions. It worked so far setting the Env-Var PYTHON_VERSION to 3.8 but now we’re migrating to python 3.10 and for some reason netlify has an issue installing the requirements.txt.

10:31:01 AM: Collecting backports.zoneinfo; python_version >= "3.6" and python_version < "3.9"
10:31:01 AM: ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
10:31:01 AM:     backports.zoneinfo; python_version >= "3.6" and python_version < "3.9" from https://files.pythonhosted.org/packages/1a/ab/3e941e3fcf1b7d3ab3d0233194d99d6a0ed6b24f8f956fc81e47edc8c079/backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl#sha256=7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9 (from pytz-deprecation-shim==0.1.0.post0->-r requirements.txt (line 400))

So i’d be very happy if netlify would simply ignore my requiements.txt. This seems to be possible if you use yarn by NETLIFY_USE_YARN. How can i make netlify ignore the requirements.txt?

I looked into the build-image and it doesn’t seem to be possible:

Or am i missing something?

thanks

k9ert

Hey @k9ert,

Netlify doesn’t support Python 3.10 yet. Python 3.8 is the max supported in the Focal build image. So, even if there was a way to ignore, which there isn’t (at least not without getting creative), I don’t think what you’re trying would work.

I think you missed the point here. I’m not trying to use netlify with python 3.10. I have a requirements.txt and i would love if netlify would not misinterpret it as this is relevant to it.
My repo is not mainly a netlify repo and i would like to simply continue to use it as before even as i’m migrating my application to python 3.10.

I’d be happy to get creative here, if you can give me some guidance on how to make that happen.

Hey @k9ert,

Sorry to miss your point, but even after discussing this with the team, it’s still not perfectly clear to us what you’re trying.

For instance, I first read this:

which made me think you’re trying to use Python 3.10 on Netlify.

Here, you said that you want us to ignore that file. But, if we ignore that, how do you expect your site to build? Do you not need the pip dependencies from that file?

Ignoring requirements.txt is not possible at the moment, but I’m unsure why you want to ignore that.

Are you having multiple projects in the same repo and trying to build one on Netlify, while trying to ignore others?

Sorry for the delay.

which made me think you’re trying to use Python 3.10 on Netlify.
No, i don’t want to use Python 3.10. I’m using 3.10 in my Software-project. And as i’m using a monorepo, i have content in there which is mainly about my project but mixed up with content (docs-folder) targeting netlify.

I would like to somehow seperate these two things.

Here, you said that you want us to ignore that file. But, if we ignore that, how do you expect your site to
build? Do you not need the pip dependencies from that file?

I don’t need these dependencies for the netlify stuff.

Are you having multiple projects in the same repo and trying to build one on Netlify,
while trying to ignore others?

Yes, i think it’s a common pattern for software-projects. You’re creating documentation pages which are editable in the same repo than your (software-) project and you want them to host nicely on some webpage with the help of netlify.

Does it make sense now?

OK. I think the news you need is that there is no way, today, to make us “ignore” requirements.txt when it exists; we will always use it if we find it. So, if you can’t build with it, you will need to build without it (not in our CI), or make sure our build doesn’t see it (perhaps not committing it to the repo or branch that we build). I understand that is not the news you were looking for!

We do have a feature request around limiting which languages are used during build: Support specifying which languages to install/skip · Issue #141 · netlify/build-image · GitHub - but don’t get many requests about python, so have not implemented it yet.

We might even accept a PR in case you wanted to implement a $NETLIFY_USE_PYTHON feature on the build image, since you found the relevant code already :wink:

I’ve found feat: allow to skip dependencies installation by sileht · Pull Request #486 · netlify/build-image · GitHub which would be the thing i’d implement as well.
The mentioned base-directory might help me as well. So i think we can close this and i’ll continue over there.
Monorepos | Netlify Docs
I’ll investigate and might mark that as a solution.

1 Like