Files
gitea-pages/services/user-guide/python.md
2024-08-08 17:16:50 +02:00

53 lines
1.8 KiB
Markdown

# Python
## Package Caching Proxy
Instead of accessing pypi.org directly PSI provides a caching proxy for pypi packages. There are several advantages in using this instead of directly accessing pypi.org:
1. Speed - the caching proxy might/will improve the dependency resolution and download speed for installing packages
2. Once downloaded/installed packages will still be available even if they are not accessible on the internet again.
3. Accessibility - pypi.psi.ch is accessible from all PSI networks (including the onces without internet access)
### Usage
The url to use the CachingProxy is: https://pypi.psi.ch/simple:
You can manually specify the url while using the `pip` command as follows:
pip install --index-url=https://pypi.psi.ch/simple pandas
To fix the default url for your user to the proxy you can create the following config file within your users home directory:
```bash
% cat ~/.config/pip/pip.conf
[global]
timeout = 60
index-url = https://pypi.psi.ch/simple
```
To change the default for the whole system edit: `/etc/pip.conf`
(also see: https://pip.pypa.io/en/stable/topics/configuration/#location)
To check whether your pip client is using this address you can simply issue a:
```
pip install -h
```
Check whats written in the descripiton of the option --index-url:
```
% pip install -h | grep -A5 index-url
-i, --index-url <url> Base URL of the Python Package Index (default
https://pypi.psi.ch/simple). This should point
to a repository compliant with PEP 503 (the
simple repository API) or a local directory laid
out in the same format.
...
```
or do a `pip config list`
```
% pip config list
global.index-url='https://pypi.psi.ch/simple'
global.timeout='60'
```