Skip to content

Commit fa75d58

Browse files
Update project_publishing.md
1 parent 3676fc7 commit fa75d58

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

episodes/project_publishing.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exercises: 15
2525
Once we have created our project, defined all the necessary metadata in the toml file, its time to publish our project. Let see the tools and steps we need to acheive this.
2626

2727
We need to install the following tools i.e. `build` and `twine`
28-
28+
Before proceeding with the steps mentioned below, kidnly rename or delete the `pixi.toml` file as we will mainly focus on `pyproject.toml` for the steps mentioned below. You can also try the build with `pixi.toml` at a later point in time by deleting or renaming the `pyproject.toml` file.
2929
## Create your build
3030

3131
`build` :A tool to read the `pyproject.toml` file and build the package files
@@ -138,25 +138,29 @@ View at:
138138
https://test.pypi.org/project/po-greet-me/0.1.1/
139139
```
140140

141-
That's it! After the upload is successful, your package will be available on TestPyPI. E.g. : https://test.pypi.org/project/po-greet-me/0.1.1/
142-
141+
That's it! After the upload is successful, your package will be available on TestPyPI. E.g. : https://test.pypi.org/project/po-greet-me/0.1.1/
142+
143143
<img width="1619" height="854" alt="image" src="https://github.com/user-attachments/assets/980a83e1-dfce-4902-bb85-e44d47af9088" />
144144

145-
It is possible that the name of your project already exists or is simialr to an existing project. In that case you may end up in an error like this :
146-
```output
145+
It is possible that the name of your project already exists or is simialr to an existing project. In that case you may end up in an error like this :
146+
147+
```output
147148
twine upload --repository testpypi dist/*
148149
Uploading distributions to https://test.pypi.org/legacy/
149150
Enter your API token:
150151
Uploading greet_me-0.1.1-py3-none-any.whl
151152
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.6/2.6 kB • 00:00 • ?
152153
WARNING Error during upload. Retry with the --verbose option for more details.
153154
ERROR HTTPError: 403 Forbidden from https://test.pypi.org/legacy/
154-
Forbidden
155+
Forbidden
155156
```
157+
156158
This isnt always helpful and you should try this command as tipped in the error message above to know more.
159+
157160
```bash
158161
twine upload --repository testpypi dist/* --verbose
159162
```
163+
160164
```output
161165
Uploading distributions to https://test.pypi.org/legacy/
162166
INFO dist/greet_me-0.1.1-py3-none-any.whl (0.9 KB)
@@ -186,12 +190,15 @@ INFO <html>
186190
ERROR HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
187191
Bad Request
188192
```
193+
189194
To fix this, rename you project e.g. to `po_greet_me` , and add the following in `pyproject.toml` file.
190195
and try the steps below to upload it again.
196+
191197
```toml
192198
[tool.hatch.build.targets.wheel]
193199
packages = ["src/po_greet_me"]
194200
```
201+
195202
```bash
196203
# 1. (Recommended) Remove the old build directory
197204
rm -rf dist
@@ -204,10 +211,13 @@ twine upload --repository testpypi dist/*
204211
```
205212

206213
## Test your package
214+
207215
Install your package via this command :
216+
208217
```bash
209218
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple po-greet-me==0.1.1
210219
```
220+
211221
```output
212222
Looking in indexes: https://test.pypi.org/simple/, https://pypi.org/simple
213223
Collecting po-greet-me==0.1.1
@@ -216,6 +226,7 @@ Downloading https://test-files.pythonhosted.org/packages/52/85/dd6ebf4ee0a6ff766
216226
Installing collected packages: po-greet-me
217227
Successfully installed po-greet-me-0.1.1
218228
```
229+
219230
Create a Python file named test_package.py
220231

221232
```python
@@ -227,6 +238,7 @@ print(happy.greet_happy())
227238
```bash
228239
python test_package.py
229240
```
241+
230242
```output
231243
Yay! happy day! 😀
232244
```

0 commit comments

Comments
 (0)