Skip to content

Commit f7287b1

Browse files
committed
added migration command
1 parent d1591f7 commit f7287b1

3 files changed

Lines changed: 469 additions & 38 deletions

File tree

docs/azure_functions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ The following files are part of Azure functions setup and can be edited accordin
3434
- `function_app.py`
3535
- `.funcignore`
3636

37+
```{important}
38+
Azure functions require a traditional `requirements.txt` file in the root of your project. If you use `uv`, run the following command before deploying (ideally, this is done automatically as part of your build step): `uv export --format requirements.txt -o requirements.txt`.
39+
```
40+
3741
## Deployment
3842

3943
First, set the following environment variables to match your preferences:

docs/migration.md

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This guide is for existing users upgrading from pre-1.0 versions. If you're new to xlwings Server, follow the [Quickstart](quickstart.md) instead.
44

5-
Starting with v1.0, xlwingis Server is now distributed as a standard Python package instead of requiring you to work directly in the xlwings-server Git repository.
5+
Starting with v1.0, xlwings Server is distributed as a standard Python package instead of requiring you to work directly in the xlwings-server Git repository.
66

77
This leads to the following improvements:
88

@@ -15,32 +15,74 @@ Other key changes:
1515

1616
- Python 3.10 is now the minimal supported version
1717
- Run the server via `uv run xlwings-server` instead of `python run.py`
18-
- `pyproject.toml` can now be used to configure the application in addition to `.env` and environment variables, see [](server_config.md)
19-
20-
The migration requires one-time project restructuring. The changes below outline what's different in 1.0:
21-
22-
1. Follow the [](quickstart.md)
23-
2. Replace the content of `custom_functions/` and `custom_scripts/` with the content of your old `app/custom_functions/` and `app/custom_scripts/`, respectively.
24-
3. Copy over the certificates from `certs/` to the same folder.
25-
4. Overwrite the UUIDs in `pyproject.toml` under `[tools.xlwings_server]` with those from `app/config.py`.
26-
5. Replace the `.env` file with the `.env` from the old project
27-
6. Copy `app/templates/manifest.xml` to `templates/manifest.xml`
28-
7. Run the server: `uv run xlwings-server`.
29-
30-
Depending on how much you have customized, continue adding optional components:
31-
32-
- If your `app/static/css/style.css` isn't empty, copy it to `static/css/style.css`
33-
- If your `app/static/js/main.js` isn't empty, copy it to `static/js/main.js`
34-
- If you have other custom static files, copy them over from `app/static` to `static` into the respective subdirectory, e.g., `images`, `js`, `css`.
35-
- If you have custom templates, copy them over from `app/templates` to `templates`.
36-
- To support Azure functions: `uv run xlwings-server add azure functions`, then copy over `local.settings.json`
37-
- To implement your own `User` model: `uv run xlwings-server add model user`, then add back the logic from `app/models/user.py` to `models/user.py`. There's no need to inherit from `BaseUser` anymore and the model has been simplified.
38-
- If you want an empty task pane, you can simply delete `templates/taskpane.html`
39-
- If you were using custom configuration, run `uv run xlwings-server add config` and edit `config.py`.
18+
- `pyproject.toml` can now be used to configure the application in addition to `.env` and environment variables, see [](server_config.md). This is helpful for settings that are non-sensitive and the same across environments.
19+
20+
## Migration
21+
22+
To allow for a clean migration, we leave the legacy project untouched and work with a new project.
23+
24+
1. Install [uv](https://docs.astral.sh/uv/), Python's modern package manager. Run the following commands on a Terminal:
25+
26+
::::{tab-set}
27+
28+
:::{tab-item} Windows
29+
30+
```bash
31+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
32+
```
33+
34+
:::
35+
:::{tab-item} macOS and Linux
36+
37+
```bash
38+
curl -LsSf https://astral.sh/uv/install.sh | sh
39+
```
40+
41+
:::
42+
43+
::::
44+
45+
2. Create a new uv project (I'll be calling it `myproject` here) and change into the directory:
46+
47+
```text
48+
uv init myproject
49+
cd myproject
50+
```
51+
52+
3. Install `xlwings-server` and `watchfiles` (for hot-reloading), then initialize xlwings-server:
53+
54+
```bash
55+
uv add xlwings-server
56+
uv add watchfiles --dev
57+
uv run xlwings-server init .
58+
```
59+
60+
4. Run the migration command from your new project directory:
61+
62+
```text
63+
uv run xlwings-server migrate C:\path\to\old-project
64+
```
65+
66+
After migration, review the migrated files and update any import statements as needed.
67+
68+
Run the server to see if the server start correctly:
69+
70+
```
71+
uv run xlwings-server
72+
```
73+
74+
Stop the server again and go through the following list to migrate the additional items that affect you.
75+
76+
## Additional Migration Steps
77+
78+
- If you have custom static files other than `css/style.css`, `js/main.js`, and `images/`, copy them over from `app/static` to `static`.
79+
- If you use Azure functions for deployment, run: `uv run xlwings-server add azure functions`, then copy over `local.settings.json`. Note that Azure functions require a traditional `requirements.txt` file in the root of your project. If you use `uv`, run the following command before deploying (ideally, this is done automatically as part of your build step): `uv export --format requirements.txt -o requirements.txt`.
80+
- If you are using a custom `User` model: `uv run xlwings-server add model user`, then add back the logic from `app/models/user.py` to `models/user.py`. There's no need to inherit from `BaseUser` anymore and the model has been simplified (no more properties).
81+
- If you were using custom configuration in `app.config.py`, run `uv run xlwings-server add config` and edit `config.py`.
4082
- If you are using custom authentication, copy `app/auth/custom/__init__.py` to `/auth/custom/__init__.py` and `app/static/js/auth.js` to `static/js/auth.js`.
41-
- If you have custom FastAPI endpoints, run `uv run xlwings-server add router` and add them to `routers/custom.py`.
83+
- If you have custom FastAPI endpoints (e.g., added to `app/routers/taskpane.py`), run `uv run xlwings-server add router` and add them to `routers/custom.py`.
4284
- If you have customized `app/auth/entraid/jwks.py`, run `uv run xlwings-server add auth entraid` and replace the function in `auth/entraid/jwks.py` with that from `app/auth/entraid/jwks.py`.
43-
- You may need to update import statements as follows:
85+
- If you have custom User models, authentication, or other endpoints, make sure to change the imports into these:
4486
- `from xlwings_server.models import CurrentUser`
4587
- `from xlwings_server.dependencies import User`
4688
- `from xlwings_server.templates import TemplateResponse`

0 commit comments

Comments
 (0)