Publishing packages are a great way for third party packages to integrate into Masonite. They are extremely easy to setup even on existing pip packages. Publishing packages allows any package to create configuration files, routes, controllers, and other integrations that make developing with your packages amazing. You can read about this in the Creating Packages documentation to learn more about how you can integrate your existing packages or future packages with Masonite.
If you are in a virtual environment,craft publish
will not have access to your virtual environment dependencies. In order to fix this, we can add our site packages to ourconfig/packages.py
config file
If you attempt to publish your package without your virtual environment's site_packages file being inside config/packages.py
, you will encounter a ModuleNotFound
error that says it cannot find the integrations file located with the package you are trying to install. This is because Masonite does not have knowledge of your virtual environments dependencies, only your system dependencies.
If you are in a virtual environment then go to yourconfig/packages.py
file and add your virtual environments site_packages folder to theSITE_PACKAGES
list. YourSITE_PACKAGES
list may look something like:
This will allowcraft publish
to find our dependencies installed on our virtual environment. Read the Publishing Packages documentation for more information.
Once done, all future packages that you pip install will be available through the publish command. This configuration should be done as soon as your virtual environment is created so you don't encounter any errors while trying to publish packages.