You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# refer to https://packaging.python.org/en/latest/specifications/pypirc/
351
-
# <username> should be same as the one you used in keyring
354
+
# <username> should be same as the one you use in keyring
352
355
cat >~/.pypirc<<EOF
353
356
[distutils]
354
357
index-servers =
@@ -369,10 +372,81 @@ This repo provides an 𝐨𝐮𝐭-𝐨𝐟-𝐭𝐡𝐞-𝐛𝐨𝐱 𝐩𝐫
369
372
370
373
</details>
371
374
375
+
---
376
+
372
377
> 🥳 𝗖𝗼𝗻𝗴𝗿𝗮𝘁𝘂𝗹𝗮𝘁𝗶𝗼𝗻𝘀!
373
378
> • You have successfully published your package to `PyPI`.
374
379
> • Now everyone can install it via `pip install my-project -i https://pypi.org/simple`
375
-
> • To update your package to a new version, do `rm -r dist`, then repeat steps 5 to 8 above.
380
+
> • To update your package to a new version, repeat steps 5 to 8 above.
381
+
382
+
## 🧰 Tools Recommended
383
+
384
+
<details>
385
+
<summary>①. 𝚙𝚢𝚙𝚒-𝚜𝚎𝚛𝚟𝚎𝚛</summary>
386
+
387
+
> • A simple `PyPI` server for local use.
388
+
> • This is **highly recommended** if you are **testing your CI/CD workflow**.
389
+
390
+
You likely have many commits to `PyPI` or `TestPyPI` to familiarize yourself with publishing process. Then there exists two problems:
391
+
392
+
- [`TestPyPI` / `PyPI` project size limit](https://pypi.org/help/#project-size-limit): many commits can exceed project size limit.
393
+
- Using `TestPyPI` as the index of `pip install` is not always reliable: especially when your package depends on some packages that are only available on `PyPI` but not on `TestPyPI`.
394
+
For example, if your package `mp-project` depends on `ruff`, then `pip install mp-project -i https://test.pypi.org/simple` will fail with `ResolutionImpossible` or `Package not found` in the process of finding and downloading `ruff`, cause `ruff` is only available on `PyPI`.
395
+
396
+
To solve these problems and fully imitate the bahvior normal `pip install` using `PyPI` index. You can deploy a local `PyPI` server with `pypi-server`.
397
+
398
+
Here is a quick guide to get started, please check its [repo](https://github.com/pypiserver/pypiserver ) for more details.
399
+
400
+
401
+
```bash
402
+
403
+
pip install pypiserver
404
+
405
+
mkdir Path/to/store/packages # path to store distribution packages
406
+
407
+
pypi-server run \
408
+
-i 0.0.0.0 \
409
+
-p <port> \ # specify a port to listen
410
+
<path-to-store>/.pypiserver_pkgs\
411
+
-a . -P . & # disable authentication for intranet use
412
+
413
+
cat >~/.pypirc<<EOF # add local server to .pypirc
414
+
[distutils]
415
+
index-servers =
416
+
pypi
417
+
testpypi
418
+
local
419
+
420
+
[pypi]
421
+
repository: https://upload.pypi.org/legacy/
422
+
423
+
[testpypi]
424
+
repository: https://test.pypi.org/legacy/
425
+
426
+
[local]
427
+
repository: http://0.0.0.0:7418
428
+
username: none # random string, not important
429
+
password: none # random string, not important
430
+
EOF
431
+
```
432
+
433
+
OK, then we can use commands below to upload and install packages:
434
+
435
+
```bash
436
+
# pwd: .../package project dir
437
+
438
+
# upload package to local server
439
+
twine upload --repository local dist/*
440
+
441
+
# install package from local server
442
+
pip install <package> \
443
+
--trusted-host \
444
+
--extra-index-url http://0.0.0.0:<port>/simple/
445
+
```
446
+
447
+
If you want to close the server, using `kill -9 "$(pgrep pypi-server)"`.
0 commit comments