Python Dependencies¶
To prevent Git merge conflicts, the Python dependencies are split up into 3 files (note the .in
. instead of .txt
file extension):
requirements.in
: Your application-specific top-level dependencies. This is usually the only file you should edit.requirements-core.in
: Dependencies required by xlwings Server.requirements-dev.in
: Additional dependencies only required during development.
Here’s an example of requirements.in
:
-r requirements-core.txt # Don't delete this line
pandas
numpy==1.26.4
When you first clone xlwings Server, there will be a few dependencies in requirements.in
. They are there to make the examples work out of the box, but you should replace them with your own top-level dependencies. The .txt
version of the requirements files need to be compiled, as we’ll see next.
Prerequisities¶
You need the package manager uv, which you can install either via
pip install uv
or by following the uv docs.
Add/remove dependencies¶
Edit
requirements.in
(note.in
, not.txt
) to add your application-specific dependencies.Create the
.txt
versions of therequirements
files by running:python run.py deps compile
The
.txt
versions are the lock files where all dependencies incl. sub-dependencies are pinned.Update your local dev environment by running:
uv pip sync requirements-dev.txt
If you use Docker, you need to rebuild your container instead:
docker compose build
Commit and push the changed
requirements
files to Git.
Upgrade dependencies¶
Run the following command:
python run.py deps upgrade
Note, however, that this command upgrades all the packages, including core and dev dependencies.
Conda environments¶
If you’d like to use a Conda env because e.g., you have dependencies that are only available via Conda, do the following:
Create a new Conda env. Make sure to replace
myenv
with the desired name of your environment:conda create -n myenv python=3.12 -y
Activate the Conda env:
conda activate myenv
Install the
uv
package manager:pip install uv
Install
requirements-dev.txt
(for development) orrequirements.txt
otherwise:uv pip sync requirements-dev.txt
Install conda dependencies (instead of
blas
, provide your own packages):conda install blas
Export the environment into
environment.yml
(call itenvironment-dev.yml
if this is a development environment):conda env export > environment.yml
Commit environment.yml
to Git. You can now use it to recreate this specific Conda environment whenever you need it via conda env create -f environment.yml
.