I have a Python package that renders Markdown files in a repo to a static html output directory. This works using Netlify, and GitHub or GitLab pages. I have read some of the documentation but I cannot find an example that seems to match how this PyPI package, currently named nxc works.
The basic steps are:
fetch the repo contents
cd to a working directory and
pip install -r requirements and then run this command:
`nxc build -i … -o ./output --lunr --commits
the result is a functional static website in the ./output/ directory
the current behavior fails with this error:
sh: line 1: python: command not found
Error: Command “cd .nxc && npm install && python -m pip install -r requirements.txt && nxc build -i … -o ./output --lunr --commits” exited with 127
I am pretty sure the vercel.json file I am using is at fault, and I am also sure that I do not have a good understanding about how to set things up here. my more or less trial and error vercel.json is here:
{
“version”: 2,
“buildCommand”: “cd .nxc && npm install && python3 -m pip install -r requirements.txt && nxc build -i … -o ./output --lunr --commits”,
“outputDirectory”: “.nxc/output”,
“routes”: [
{
“src”: “/(.*)”,
“dest”: “/$1”
}
],
“env”: {
“NODE_VERSION”: “16”
}
}
any help is appreciated, especially where to learn more about how to use Vercel.
thanks, Bill Anderson
Deployment URL or Custom Domain:
Environment (local, preview, production):
Project Framework:
Build Settings:
Framework Preset:
Build Command (if not default):
Output Directory (if not default):
Install Command (if not default):
Node/Runtime Version:
Package Manager:
Relevant Packages:
Hi, @band101! Welcome to the Vercel Community It’s great to have you here.
To deploy your Python-based static site generator on Vercel, we need to make some adjustments to your setup. You can modify your vercel.json file to properly handle your project:
We’re using the @vercel/static-build builder, which allows us to run custom build scripts.
The builds section points to our build.sh script.
The distDir config tells Vercel where to find the built static files.
You can also create build.sh file in the root of your project with the following content:
#!/bin/bash
# Rest of the script...
# Install Python
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -o miniforge.sh
bash miniforge.sh -b -p $HOME/miniforge
export PATH=$HOME/miniforge/bin:$PATH
# Install dependencies and run build
cd .nxc
pip install -r requirements.txt
nxc build -i ... -o ./output --lunr --commits
Make sure your requirements.txt file is in the .nxc directory and includes all necessary dependencies, including your nxc package. If you have any npm dependencies, you should create a package.json file in the .nxc directory and list them there.
To learn more about deploying Python projects on Vercel, you can refer to these resources:
thanks again for the reply.
i can not see anything helpful in the build log as it is now.
I will:
(1) run vercel-cli commands with ‘-d’ flag
(2) look at the 404 error page (again)
not really an error, but an observation.
when the build.sh runs it creates a miniforge.sh file, and after vercel build is runs the repository has package.json and the lock file. all 3 of these files show up as untracked to git.
Question: I guess I can add these files specifically to .gitignore, but can i force them to be generated in the .vercel/output directory?
My main objective is to keep the GitLab repo clean.
and many thanks for the recent help.