-
Notifications
You must be signed in to change notification settings - Fork 196
Support specifying which languages to install/skip #141
Comments
@edmorley I agree that specifying the desired language would be a good optimization to make. It would allow us to skip other language version switches/installs and caching of language-specific dependencies. It would definitely need to be an opt-in behavior, because we strive to make our build-image mostly automatic out-of-the-box. Since most of that behavior is contained in the I'll try and solicit the opinions of some of my colleagues and see where this falls on our roadmap. |
Thank you for the reply :-) I agree this would need to be opt in, and that it would be a nice optimisation for all that do so. Though just want to clarify that in our case it was less about the performance, and more that as-is Netlify is unusable on our monorepos due to the unavoidable build failures (the only workaround being to rearrange our repository layouts, and use I was thinking something like this might work (and also be a nice cleanup of the rather large # run-build-functions.sh
DIR="$(dirname "${BASH_SOURCE[0]}")"
# Default to all languages, for automatic detection out of the box
: "${NETLIFY_LANGUAGES:='node python ruby ...'}"
# non-language specific prep steps here (such as restoring home/cwd cache)
for lang in ${NETLIFY_LANGUAGES}; do
if [[ -f "${DIR}/languages/${lang}.sh" ]]; then
. "${DIR}/languages/${lang}.sh"
else
echo "Unrecognised language '${lang}' in NETLIFY_LANGUAGES, see <docs URL>"
exit 1
fi
done
# non-language specific teardown steps here (such as saving home/cwd cache) ...and then each language's script file contains the specific cache prep / binary install / dependency install / cache save steps. Or if separate files weren't desired, then inline functions and something like: for lang in ${NETLIFY_LANGUAGES}; do
if command -v "setup_${lang}" >/dev/null 2>&1; then
"setup_${lang}"
else
echo "Unrecognised language '${lang}' in NETLIFY_LANGUAGES, see <docs URL>"
exit 1
fi
done |
I did see that. Unfortunately, I don't see a quick way to fix that besides what you already did.
The one trick here is that we currently support multiple languages at the same time, so the function names couldn't overlap. |
I believe this is the way to implement the pre-build changes needed by many issues with the current build process. It allows a bit more flexibility for advanced users and does not break things for existing users. Here are some examples: ## Skipping unnecessary language installs (netlify#141) One can create `.netlify/remove_languages.sh` with contents: ```bash rm Pipfile rm Pipfile.lock rm requirements.txt rm runtime.txt ``` ## Specify Composer file (netlify#237) One can create `.netlify/patch_composer.sh` with contents: ```bash mv -f composer-netlify.json composer.json ``` ## Deploying multiple sites from the same repo (netlify#196) Add enviroment vairable $NETLIFY_SITE to project Create a `.netlify/netfily-site.sh` with contents: ```bash mv -f .netlify/$NETLIFY_SITE netlify.yaml ```
Just for the record, I ran into this today and it's preventing me from using the service. :( Our frontend is built with node and can be served as a static html/css. I'd like to build and host this with netlify. Both services are hard-fast fixed on their format, so we cannot have a Being able to use and override the info with an environment variable (like netlify does with node and ruby) would also solve this for us. Old post with the same use case: |
(Sorry previously commented on the wrong tab! I've moved that comment to: heroku/heroku-buildpack-python#913 (comment))
@sover02 Hi! Since I filed this issue I've now become the Python owner at Heroku, and as such am in a position to try and improve this from Heroku's side. We want to add "flexible versions" support to the Heroku Python buildpack (see heroku/heroku-buildpack-python/issues/913), which will bring the version specifications for Heroku and Netlify closer in line. However I did notice that in addition to the |
@edmorley, that's fantastic! I'm excited to possibly make use of both services :) For what it's worth, I think a simple solution is sight on the netlify side - we could just allow runtime.txt to be ignored. :) |
Did this ever get anywhere? I'm in the same boat where my repo has components on Netlify and others on Heroku. Can one or both please be fixed to be a little more tolerant? "Be liberal in what you accept" and all that... Thanks! :-) |
@edmorley Hi Ed, are you still in a position at Heroku to fix this? I know it's been over three years since you opened this, but it's still causing issues for folks today (like me!) In lieu of some complicated change to the way we specify our runtime versions, it seems like it should be straightforward to make the parser support either:
patterns in the runtime.txt without breaking any existing Heroku runtime.txt files. Here is the regexp, can we please get it in? 🙏
I tested this at regexr.com. Thanks! |
@cmdlinebeep Hi! I replied over in heroku/heroku-buildpack-python#1243 (comment) but to summarise here... Given the filename is called I think a better change would be to update this line: build-image/run-build-functions.sh Line 225 in fa439ad
With: PYTHON_VERSION=$(cat runtime.txt)
# Remove any `python-` prefix from the version string.
PYTHON_VERSION="${PYTHON_VERSION#python-}" With that change, Netlify will work with any of the thousands of repos that have the existing style |
Also, I think it would be worth splitting the |
Hi!
We have an app that is comprised of a webpack-built SPA and a django-rest-framework powered backend - with both parts existing in the same repository (monorepos have many advantages):
https://github.com/mozilla/treeherder
We would only want the SPA to be built by Netlify (so only want the nodejs env setup +
yarn install
steps to be run), howeverrun-build-functions.sh
also findsruntime.txt
andrequirements.txt
, resulting in unwanted (and failing) Python setup tasks being run:The "install specific Python version" step is giving a warning, since our
runtime.txt
is for use by heroku-buildpack-python and so uses theirpython-N.N.N
format rather than that used by Netlify (ie has the additionalpython-
prefix).The pip install step is failing since the
mysqlclient
package requires that thelibmysqlclient-dev
package be installed in the OS.However even if these two steps succeeded, they would only be unnecessarily increasing our build times, since our SPA has no need for the Python environment.
As such we would like a way to prevent them from being run.
Perhaps a new
language
option, like:...which would skip all steps other than those relating to node/js dependencies.
Or else a
LANGUAGES
environment variable would be fine too.Many thanks! :-)
The text was updated successfully, but these errors were encountered: