GhostBSD and FreeBSD ports such as py311-fastapi
and py311-sqlmodel
may require incompatible versions of Pydantic:
py311-fastapi
requires Pydantic v2
py311-sqlmodel
is currently only compatible with Pydantic v1
Because FreeBSD allows only one version of py311-pydantic
to be installed at a time, these ports conflict when installed simultaneously.
This script solves the problem by:
Creating a custom port, py-pydantic1
, pinned to Pydantic v1.10.12
Patching py-sqlmodel
to depend on py-pydantic1
Allowing py311-fastapi
to continue using the default py311-pydantic
(v2)
Prerequisites
Before running the script:
- Ensure the FreeBSD ports tree is available at
/usr/ports
- Run the script with root privileges
- Confirm that
py311-fastapi
and py311-sqlmodel
are not already installed with conflicting dependencies
- Have Internet access to fetch Pydantic v1 source from PyPI
Usage Instructions
Save the script as: setup_dual_pydantic_ports.sh
Make it executable: chmod +x setup_dual_pydantic_ports.sh
Run it as root: sudo ./setup_dual_pydantic_ports.sh
When prompted:
- Type
y
to create and install the custom py-pydantic1
port
- Type
y
to patch and rebuild py-sqlmodel
After the script completes:
- Install
py311-fastapi
normally using: sudo pkg install py311-fastapi
or
cd /usr/ports/www/py-fastapi && sudo make install clean
After Installation
py311-sqlmodel
will now link against your custom py311-pydantic1
py311-fastapi
will continue using the latest py311-pydantic
(v2)
They will coexist without conflicts, provided the installed files from both Pydantic versions do not collide.