2025-05-29 update: the solution presented is incomplete and misleading. See the followup post: Fixing uv dependency locking in Cloudflare Pages.
The other day I was trying to deploy a static site using Pelican to Cloudflare Pages using the Pages’ GitHub integration (where it detects changes in the repository and rebuilds the site).
The project used uv for dependency management as it’s my go-to Python project management tool these day.s
All in all nothing fancy (--no-package
means we have no Python package to build and we only use uv to manage an environment with
some dependencies instealled):
uv init --no-package
uv add 'pelican[markdown]'
uv run pelican-quickstart
With that in place I added a test article and I ran uv run make devserver to test the
site locally – all was well there.
I then configured the Cloudflare Pages deployment using a dedicated Pelican preset, committed all my changes and pushed it to GH.
What I wasn’t expecting is that even with an uv-managed project CF Pages still attempts
to pip install . the project and the setup didn’t quite work with it:
Installing project dependencies: pip install .
Processing /opt/buildhome/repo
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [14 lines of output]
error: Multiple top-level modules discovered in a flat-layout: ['pelicanconf', 'publishconf'].
To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.
If you are trying to create a single distribution with multiple modules
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:
1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names
To find more information, look for "package discovery" on setuptools docs.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
which is incidentally the same error I get some time ago when I attempted to deploy a Sphinx-based, uv-managed project to Cloudflare Pages a few weeks back. I gave up then but I wasn’t giving up now.
I decided to use the knowledge that reading error messages is likely to help with resolving errors. See this suggestion?
consider the following options
...
3. explicitly set `py_modules` or `packages` with a list of names
We can use it to make pip not actually attempt to build any packages in the current project.
With a simple pyproject.toml addition (the tools.setuptools section) failing builds
became happy, non-failing builds:
name = "eng-blog"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"pelican[markdown]>=4.11.0",
]
# Add this section
[tool.setuptools]
packages = []
Now, ironically enough I ended up dropping Pelican for that particular project but that’s a whole separate subject, let that not stand in the way of sharing a solution to a problem.
2025-05-29 update: the solution presented is incomplete and misleading. See the followup post: Fixing uv dependency locking in Cloudflare Pages.