alfred-python 0.0.1__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alfred_python-0.5.0/PKG-INFO +368 -0
- alfred_python-0.5.0/README.md +331 -0
- alfred_python-0.5.0/alfred/base/__init__.py +0 -0
- alfred_python-0.5.0/alfred/base/config.py +33 -0
- alfred_python-0.5.0/alfred/base/constants.py +94 -0
- alfred_python-0.5.0/alfred/base/exceptions.py +11 -0
- alfred_python-0.5.0/alfred/exceptions/__init__.py +7 -0
- alfred_python-0.5.0/alfred/http/__init__.py +0 -0
- alfred_python-0.5.0/alfred/http/http_client.py +520 -0
- alfred_python-0.5.0/alfred/http/typed.py +49 -0
- alfred_python-0.5.0/alfred/realtime/__init__.py +124 -0
- alfred_python-0.5.0/alfred/rest/__init__.py +86 -0
- alfred_python-0.5.0/alfred/rest/data_points/__init__.py +14 -0
- alfred_python-0.5.0/alfred/rest/data_points/base.py +14 -0
- alfred_python-0.5.0/alfred/rest/data_points/v1.py +21 -0
- alfred_python-0.5.0/alfred/rest/files/__init__.py +14 -0
- alfred_python-0.5.0/alfred/rest/files/base.py +51 -0
- alfred_python-0.5.0/alfred/rest/files/typed.py +71 -0
- alfred_python-0.5.0/alfred/rest/files/v1.py +83 -0
- alfred_python-0.5.0/alfred/rest/jobs/__init__.py +14 -0
- alfred_python-0.5.0/alfred/rest/jobs/base.py +24 -0
- alfred_python-0.5.0/alfred/rest/jobs/typed.py +15 -0
- alfred_python-0.5.0/alfred/rest/jobs/v1.py +32 -0
- alfred_python-0.5.0/alfred/rest/sessions/__init__.py +14 -0
- alfred_python-0.5.0/alfred/rest/sessions/base.py +20 -0
- alfred_python-0.5.0/alfred/rest/sessions/v1.py +28 -0
- alfred_python-0.5.0/alfred/typings/__init__.py +1 -0
- {alfred_python-0.0.1/app → alfred_python-0.5.0/alfred}/typings/misc.py +3 -3
- alfred_python-0.5.0/alfred/utils/__init__.py +1 -0
- {alfred_python-0.0.1/app → alfred_python-0.5.0/alfred}/utils/logging.py +29 -26
- alfred_python-0.5.0/alfred_python.egg-info/PKG-INFO +368 -0
- alfred_python-0.5.0/alfred_python.egg-info/SOURCES.txt +37 -0
- alfred_python-0.5.0/alfred_python.egg-info/dependency_links.txt +1 -0
- alfred_python-0.5.0/alfred_python.egg-info/requires.txt +5 -0
- alfred_python-0.5.0/alfred_python.egg-info/top_level.txt +1 -0
- alfred_python-0.5.0/pyproject.toml +30 -0
- alfred_python-0.0.1/PKG-INFO +0 -42
- alfred_python-0.0.1/README.md +0 -29
- alfred_python-0.0.1/alfred_python.egg-info/PKG-INFO +0 -42
- alfred_python-0.0.1/alfred_python.egg-info/SOURCES.txt +0 -14
- alfred_python-0.0.1/alfred_python.egg-info/top_level.txt +0 -1
- alfred_python-0.0.1/app/__init__.py +0 -24
- alfred_python-0.0.1/app/config/__init__.py +0 -1
- alfred_python-0.0.1/app/config/settings.py +0 -21
- alfred_python-0.0.1/app/typings/__init__.py +0 -1
- alfred_python-0.0.1/app/utils/__init__.py +0 -1
- alfred_python-0.0.1/pyproject.toml +0 -17
- {alfred_python-0.0.1 → alfred_python-0.5.0}/LICENSE +0 -0
- /alfred_python-0.0.1/alfred_python.egg-info/dependency_links.txt → /alfred_python-0.5.0/alfred/__init__.py +0 -0
- {alfred_python-0.0.1 → alfred_python-0.5.0}/setup.cfg +0 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: alfred-python
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Python library designed to simplify and streamline interactions with the Alfred API
|
|
5
|
+
Author-email: Tagshelf LLC <support@tagshelf.com>
|
|
6
|
+
License: Copyright (c) 2018 The Python Packaging Authority
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
25
|
+
Project-URL: homepage, https://github.com/tagshelfsrl/alfred-python
|
|
26
|
+
Classifier: Programming Language :: Python :: 3
|
|
27
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
28
|
+
Classifier: Operating System :: OS Independent
|
|
29
|
+
Requires-Python: >=3.8
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: pydantic>=2.0
|
|
33
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
34
|
+
Requires-Dist: requests>=2.30
|
|
35
|
+
Requires-Dist: python-socketio>=5.11
|
|
36
|
+
Requires-Dist: websocket-client>=1.8
|
|
37
|
+
|
|
38
|
+
# Overview
|
|
39
|
+
|
|
40
|
+
Welcome to the `alfred-python` SDK, the official Python library for interfacing with Alfred, your intelligent process automation platform. This SDK provides a simple and efficient way to integrate Alfred's capabilities into your Python applications.
|
|
41
|
+
|
|
42
|
+
## Prerequisites
|
|
43
|
+
|
|
44
|
+
- Python v3.8+
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
Check out this simple example to get up and running:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from alfred.rest import AlfredClient
|
|
52
|
+
from alfred.base import Configuration
|
|
53
|
+
|
|
54
|
+
config = Configuration.default()
|
|
55
|
+
auth_config = {"api_key": "AXXXXXXXXXXXXXXXXXXXXXX"}
|
|
56
|
+
|
|
57
|
+
client = AlfredClient(config, auth_config)
|
|
58
|
+
|
|
59
|
+
values = client.data_points.get_values("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
|
|
60
|
+
print(values)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Sessions
|
|
64
|
+
|
|
65
|
+
A Session is a mechanism designed for asynchronous file uploads. It serves as a container or grouping for files that are uploaded at different times or from various sources, but are all part of a single Job. To see more information visit our [official documentation](https://docs.tagshelf.dev/enpoints/deferred-session).
|
|
66
|
+
|
|
67
|
+
#### Get session by ID
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
# Get a session by ID
|
|
71
|
+
result = client.sessions.get("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
|
|
72
|
+
print(result)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Create session
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# Create a session
|
|
79
|
+
result = client.sessions.create()
|
|
80
|
+
print(result)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Jobs
|
|
84
|
+
|
|
85
|
+
A Job represents a single unit of work that group one or more Files within Alfred. To see more information visit our [official documentation](https://docs.tagshelf.dev/enpoints/job).
|
|
86
|
+
|
|
87
|
+
#### Get job by ID
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
# Get a job by ID
|
|
91
|
+
result = client.jobs.get("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
|
|
92
|
+
print(result)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Create job
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
job = {
|
|
99
|
+
"session_id": "session-id",
|
|
100
|
+
"propagate_metadata": True,
|
|
101
|
+
"merge": True,
|
|
102
|
+
"decompose": True,
|
|
103
|
+
"metadata": {
|
|
104
|
+
"key": "value",
|
|
105
|
+
},
|
|
106
|
+
"channel": "channel",
|
|
107
|
+
"parent_file_prefix": "prefix",
|
|
108
|
+
"page_rotation": 90,
|
|
109
|
+
"container": "container",
|
|
110
|
+
"file_name": "file-name",
|
|
111
|
+
"file_names": ["file-name-1", "file-name-2"],
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# Create a job
|
|
115
|
+
result = client.jobs.create(job)
|
|
116
|
+
print(result)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Here is a description for each valid argument when creating a job:
|
|
120
|
+
|
|
121
|
+
| Parameter | Type | Description |
|
|
122
|
+
| ------------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
123
|
+
| session_id | string | Session ID |
|
|
124
|
+
| metadata | any | Metadata of the job |
|
|
125
|
+
| propagate_metadata | boolean | If `true` ensures that the provided metadata at the Job level is attached to all the specified Files. |
|
|
126
|
+
| merge | boolean | If `true`, when all provided Files are either images or PDFs, the system combines them into a single file for the purpose of processing. |
|
|
127
|
+
| decompose | boolean | If `true`, when the provided File is a PDF, the system will decompose it into individual pages for processing. |
|
|
128
|
+
| channel | string | Channel |
|
|
129
|
+
| parent_file_prefix | string | The `parent_file_prefix` parameter is used to specify a virtual folder destination for the uploaded files. |
|
|
130
|
+
| page_rotation | number | Page rotation |
|
|
131
|
+
| container | string | Virtual container where the referenced remote file is located. |
|
|
132
|
+
| file_name | string | Unique name of the file within an object storage source. |
|
|
133
|
+
| file_names | string[] | Array of unique names of the files within an object storage source. |
|
|
134
|
+
|
|
135
|
+
### Files
|
|
136
|
+
|
|
137
|
+
File is an individual document or data unit undergoing specialized operations tailored for document analysis and management. To see more information visit our [official documentation](https://docs.tagshelf.dev/enpoints/file).
|
|
138
|
+
|
|
139
|
+
#### Get file by ID
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Get a file by ID
|
|
143
|
+
result = client.files.get("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
|
|
144
|
+
print(result)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Download file by ID
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
# Download a file by ID
|
|
151
|
+
result = client.files.download("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
|
|
152
|
+
|
|
153
|
+
with open(result.get("original_name"), "wb") as f:
|
|
154
|
+
f.write(result.get("file").getvalue())
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### Upload remote file
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
# Upload a remote file
|
|
161
|
+
result = client.files.upload({
|
|
162
|
+
"url": "<File URL>",
|
|
163
|
+
"metadata": {}
|
|
164
|
+
})
|
|
165
|
+
print(result)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### Upload a local file
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
with open("<Path to local file>", "rb") as upload_file:
|
|
172
|
+
result = client.files.upload_file({
|
|
173
|
+
"file": upload_file,
|
|
174
|
+
"session_id": "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX",
|
|
175
|
+
"metadata": {}
|
|
176
|
+
})
|
|
177
|
+
print(result)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Data Points
|
|
181
|
+
|
|
182
|
+
Data Points are the core of Alfred's platform and represent data that you want to extract. To see more information visit our [official documentation](https://docs.tagshelf.dev/enpoints/metadata).
|
|
183
|
+
|
|
184
|
+
> [!IMPORTANT]
|
|
185
|
+
> Data Points where previously known as Metadata.
|
|
186
|
+
|
|
187
|
+
#### Get Data Point by File ID
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
# Get a data point by file ID
|
|
191
|
+
result = client.data_points.get_values("XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX")
|
|
192
|
+
print(result)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Configuration
|
|
196
|
+
|
|
197
|
+
This section provides detailed instructions and guidelines for configuring the SDK to interface effectively with the target API.
|
|
198
|
+
|
|
199
|
+
### Retry Policy
|
|
200
|
+
|
|
201
|
+
In this SDK, we implement automatic retries to enhance the reliability of network requests. However, to maintain the integrity of data transactions, retries are only enabled for HTTP methods that are considered idempotent. Idempotent methods are those that can be called multiple times without different outcomes. Thus, retries are applied only to the following HTTP methods:
|
|
202
|
+
|
|
203
|
+
- `GET`: Retrieves data from the server without changing any state.
|
|
204
|
+
- `PUT`: Updates a resource in a way that it can be repeatedly updated without changing the outcome beyond the initial application.
|
|
205
|
+
- `DELETE`: Removes a resource and subsequent deletions of the same resource are redundant.
|
|
206
|
+
- `HEAD`: Fetches metadata about a resource without side-effects.
|
|
207
|
+
- `OPTIONS`: Retrieves supported communication options for a given URL or server without causing any side effects.
|
|
208
|
+
|
|
209
|
+
For non-idempotent methods like POST and PATCH, the SDK does not perform retries by default because doing so could potentially result in unwanted side effects or duplicate operations. If you need to enable retries for these methods under specific circumstances, please handle them cautiously in your application logic.
|
|
210
|
+
|
|
211
|
+
## Real-time Events
|
|
212
|
+
|
|
213
|
+
The `alfred-python` library provides a way to listen to events emitted by Alfred IPA in real-time through a websockets implementation. This feature is particularly useful when you need to monitor the progress of a Job, File, or any other event that occurs within the Alfred platform. To see more information visit our [official documentation](https://docs.tagshelf.dev).
|
|
214
|
+
|
|
215
|
+
### Getting started
|
|
216
|
+
|
|
217
|
+
To get started, you need to create an instance of the `AlfredRealTimeClient` class.
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
from alfred import AlfredRealTimeClient
|
|
221
|
+
from alfred.base import Configuration
|
|
222
|
+
from alfred import AuthConfiguration
|
|
223
|
+
|
|
224
|
+
config = Configuration.default()
|
|
225
|
+
|
|
226
|
+
auth_config = AuthConfiguration({
|
|
227
|
+
"api_key": "AXXXXXXXXXXXXXXXXXXXXXX"
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
client = AlfredRealTimeClient(config, auth_config, verbose=True)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### File Events
|
|
234
|
+
These events are specifically designed to respond to a variety of actions or status changes related to Files. To see more details about File events, visit our [official documentation](https://docs.tagshelf.dev/event-api/fileevents).
|
|
235
|
+
```python
|
|
236
|
+
# Listen to all File events
|
|
237
|
+
client.on_file_event(lambda data: print(data))
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Job Events
|
|
241
|
+
Alfred performs asynchronous document classification, extraction, and indexing on a variety of file types. The events detailed here offer insights into how a Job progresses, fails, retries, or completes its tasks. To see more details about Job events, visit our [official documentation](https://docs.tagshelf.dev/event-api/jobevents).
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
# Listen to all Job events
|
|
245
|
+
client.on_job_event(lambda data: print(data))
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Specific Events
|
|
249
|
+
|
|
250
|
+
This enables you to select a specific event you wish to monitor from the list of supported events.
|
|
251
|
+
It's particularly useful when you want to listen to a specific event instead of all events of a particular type.
|
|
252
|
+
|
|
253
|
+
Here's an example of how to listen to a specific event:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
from alfred.base import FileEvent, JobEvent
|
|
257
|
+
|
|
258
|
+
# Listen to the specific File Done event
|
|
259
|
+
client.on(FileEvent.FILE_DONE_EVENT.value, lambda data: print(data))
|
|
260
|
+
|
|
261
|
+
# Listen to the specific Job Finished event
|
|
262
|
+
client.on(JobEvent.JOB_FINISHED_EVENT.value, lambda data: print(data))
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Here is a list of all supported events:
|
|
266
|
+
|
|
267
|
+
| Event Type | Event Name | Description |
|
|
268
|
+
| --- | --- | --- |
|
|
269
|
+
| FileEvent | `FILE_ADD_TO_JOB_EVENT` | Triggered when a file is added to a job for processing. |
|
|
270
|
+
| FileEvent | `FILE_CATEGORY_CREATE_EVENT` | Occurs when a new category is created for a file. |
|
|
271
|
+
| FileEvent | `FILE_CATEGORY_DELETE_EVENT` | Signals the deletion of a file's category. |
|
|
272
|
+
| FileEvent | `FILE_CHANGE_TAG_EVENT` | Indicates a change in the tag associated with a file. |
|
|
273
|
+
| FileEvent | `FILE_DONE_EVENT` | Marks the completion of file processing. |
|
|
274
|
+
| FileEvent | `FILE_EXTRACTED_DATA_CREATE_EVENT` | Triggered when new data is extracted from a file. |
|
|
275
|
+
| FileEvent | `FILE_EXTRACTED_DATA_DELETE_EVENT` | Occurs when extracted data from a file is deleted. |
|
|
276
|
+
| FileEvent | `FILE_FAILED_EVENT` | Indicates a failure in file processing. |
|
|
277
|
+
| FileEvent | `FILE_MOVE_EVENT` | Signals the movement of a file within the system. |
|
|
278
|
+
| FileEvent | `FILE_MOVE_TO_PENDING_EVENT` | Triggered when a file is moved to a pending state. |
|
|
279
|
+
| FileEvent | `FILE_MOVE_TO_RECYCLE_BIN_EVENT` | Indicates movement of a file to the recycle bin. |
|
|
280
|
+
| FileEvent | `FILE_PROPERTY_CREATE_EVENT` | Reflects the creation of a file property. |
|
|
281
|
+
| FileEvent | `FILE_PROPERTY_DELETE_EVENT` | Signals the deletion of a file property. |
|
|
282
|
+
| FileEvent | `FILE_REMOVE_TAG_EVENT` | Signals the removal of a tag from a file. |
|
|
283
|
+
| FileEvent | `FILE_STATUS_UPDATE_EVENT` | Indicates an update in the file's status. |
|
|
284
|
+
| FileEvent | `FILE_UPDATE_EVENT` | Triggered when a file is updated in any manner. |
|
|
285
|
+
| JobEvent | `JOB_CREATE_EVENT` | Triggered when a new job is instantiated for file operations. |
|
|
286
|
+
| JobEvent | `JOB_EXCEEDED_RETRIES_EVENT` | Fires when job exceeds maximum retry attempts for a stage. |
|
|
287
|
+
| JobEvent | `JOB_FAILED_EVENT` | Occurs when a job halts due to an unrecoverable error. |
|
|
288
|
+
| JobEvent | `JOB_FINISHED_EVENT` | Triggered when job successfully completes all workflow stages. |
|
|
289
|
+
| JobEvent | `JOB_INVALID_EVENT` | Fires when job fails initial validation of input files or parameters. |
|
|
290
|
+
| JobEvent | `JOB_RETRY_EVENT` | Triggered when job retries a stage after a recoverable failure. |
|
|
291
|
+
| JobEvent | `JOB_STAGE_UPDATE_EVENT` | Occurs when job transitions from one workflow stage to another. |
|
|
292
|
+
| JobEvent | `JOB_START_EVENT` | Triggered when job begins its workflow and state machine. |
|
|
293
|
+
|
|
294
|
+
## Development Setup
|
|
295
|
+
|
|
296
|
+
### Setting up the development environment
|
|
297
|
+
|
|
298
|
+
To contribute to `alfred-python`, you'll need to set up a Python development environment. We recommend using Conda, a popular package and environment management system. Here’s how to set it up:
|
|
299
|
+
|
|
300
|
+
1. **Install Conda**: If you do not have Conda installed, you can download and install it from [Miniconda](https://docs.conda.io/en/latest/miniconda.html) (a minimal installer) or [Anaconda](https://www.anaconda.com/products/distribution) (a full-featured distribution).
|
|
301
|
+
|
|
302
|
+
2. **Create a new Conda environment**: Open your terminal and run the following command to create a new environment named `alfred-python`:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
conda create --name alfred-python python=3.8 -y
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
3. **Activate the environment**: Activate the newly created environment by running:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
conda activate alfred-python
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
4. **Install dependencies**: With the environment activated, install the required dependencies by running:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
pip install -r requirements.txt
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
This sets up a basic Python environment tailored for development purposes.
|
|
321
|
+
|
|
322
|
+
### Optional: Setting up a testing environment
|
|
323
|
+
|
|
324
|
+
For testing and development, it's often useful to install the package in a way that reflects changes in real-time. To do this, you can install the package in editable mode. Here’s how to create a separate environment for testing and install the SDK:
|
|
325
|
+
|
|
326
|
+
1. **Create a testing environment**: It's a good practice to separate testing and development environments to avoid conflicts. Create a new environment named `alfred-python-test`:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
conda create --name alfred-python-test python=3.8 -y
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
2. **Activate the testing environment**:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
conda activate alfred-python-test
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
3. **Install the SDK in editable mode**: Navigate to the root directory of the `alfred-python` project and run:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
pip install --editable .
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Building the Project
|
|
345
|
+
|
|
346
|
+
To package `alfred-python` into distributable formats such as source archives and wheels, you will need to use the `build` module, a modern tool for building packages that adheres to PEP 517. Follow these steps to build the project:
|
|
347
|
+
|
|
348
|
+
### Preparing the build environment
|
|
349
|
+
|
|
350
|
+
Before building the project, ensure that your development environment is activated and up-to-date. If you don’t have an environment set up, please refer to the [Development Setup](#development-setup) section to create and activate one.
|
|
351
|
+
|
|
352
|
+
### Installing the build Tool
|
|
353
|
+
|
|
354
|
+
With your environment ready, install the `build` package. This package provides a simple, reliable way to build your project. Install it using pip:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
pip install -U build
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Running the build process
|
|
361
|
+
|
|
362
|
+
Once `build` is installed, you can generate the build artifacts by running the following command from the root directory of your project:
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
python -m build
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
This command will produce a source distribution (`tar.gz`) and a wheel file (`whl`) in the `dist/` directory. These files are what you would upload to a package index like PyPI, or distribute to other developers.
|