- 18 Sep 2023
- 2 Minutes to read
- Print
- DarkLight
- PDF
PyPI (Python)
- Updated on 18 Sep 2023
- 2 Minutes to read
- Print
- DarkLight
- PDF
PyPI Feeds in Proget
The Python Package Index (PyPI) is the main repository for software and libraries written in the Python programming language. Since version 5.2, ProGet supports the creation of PyPI feeds to host and deploy custom Python software packages.
Installing Packages
PyPI packages are installed using pip. To install a package from a ProGet feed, use the following command:
pip install {package-name}=={package-version} -i http://{proget-server}/pypi/{feed-name}/simple
Authenticated Feeds
If you've configured your feed to require authentication, there are two ways that pip can be configured to include authentication; basic authentication passed with the URL in the pip install
command or by configuing a pip config file.
Using pip install
With a URL Parameter
To pass basic authentication along with the URL in the pip install
command, you will need to add a --trusted-host
parameter containing your ProGet host and insert the username and password into the begining of your URL. The pip install command would look like this:
pip install {package-name}=={package-version} --trusted-host {proget-server} -i https://{user-name}:{password}@{proget-server}/pypi/{feed-name}/simple
For example, if you are installing Flask 2.3.3 from a ProGet feed with the endpoint https://myprogetserver.com/pypi/approved-pypi/simple
, your command would look like this:
pip install flask==2.3.3 --trusted-host myprogetserver.com -i https://MyUserName:MyPassword123!@{myprogetserver.com/pypi/approved-pypi/simple
If you are using an API key, you will need to use api
for the username:
pip install flask==2.3.3 --trusted-host myprogetserver.com -i https://api:MyApiKey123!@{myprogetserver.com/pypi/approved-pypi/simple
Using a pip Config
To configure pip to use a pip config file to store the authenticated feed, you will need use the pip config command.
pip config --global set global.index-url https://{user-name}:{password}@{proget-server}/pypi/{feed-name}/simple
pip config --global set global.trusted-host {proget-server}
These commands will generate a pip config file that looks like:
[global]
index-url = https://{user-name}:{password}@{proget-server}/pypi/{feed-name}/simple
trusted-host = {proget-server}
The pip config
can be scoped to global (--global), user (--user), and to the environment (--site). The commands above are scoped to the global scope.
Creating Packages
To learn how to create a package that can be hosted by ProGet, visit the Packaging Python Projects tutorial.
Publishing Packages
Twine
PyPI packages are pushed to ProGet using twine. To push a package to a ProGet feed, use the following command:
twine upload -u {user-name} -p {password} --repository-url http://{proget-server}/pypi/{feed-name}/legacy <dist>
To use an API key, you will need to use api
for the username and the API key as the password.
cURL
PyPI packages may be published to ProGet with cURL using the following syntax:
curl https://{proget-server}/pypi/{feed-name}/upload/<packageName-version.tar.gz> --user <user>:<password> --upload-file <packageName-version.tar.gz>
To use an API key, you will need to use api
for the username and the API key as the password.
Technical Limitations
- ProGet only supports searching package name and summary fields via the XML-RPC API (implemented by PyPI.org), other use cases of this API are not supported by ProGet
- Connectors to other PyPI feeds require the PyPI JSON API to be implemented (both ProGet and PyPI.org support this)
- Package names are generally normalized (as per the PEP503 specs), but packages where versions only differ by
-
and_
(e.g.my-package 1.0
andmy_package 1.1
) aren't properly listed undermy-package
. In addition, UI-based searching does not treat_
and-
the same
If these limitations are more than minor inconveniences, please let us know so we can figure out how to fix them.