AWS S3 can be used as a pypi server with minimal configuration and no other additional dependencies.
Suppose you want to use the bucket mypackages
for hosting your private packages - awesomepy
and rattlesnake
.
After you have created the bucket in S3, go to its properties, click on Static website hosting card and enable the option Use this bucket to host a website. Note down the Endpoint mentioned above the radio button.
Below is how you have to arrange the folders and files (docs):
mypackages
|
|---awesomepy
| |---awesomepy-1.10.0-py27-none-any.whl
| |---awesomepy-1.10.3-py27-none-any.whl
| |---index.html
|
|---rattlepy
|---rattlesnake-0.1.1-py27-none-any.whl
|---index.html
The index.html
files in the package folders will have content like below
<html>
<head>
<title>Links</title>
</head>
<body>
<h1>Links</h1>
<a href='awesomepy-1.10.0-py27-none-any.whl'>awesomepy-1.10.0-py27-none-any.whl </a>
<br />
<a href='awesomepy-1.10.3-py27-none-any.whl'>awesomepy-1.10.3-py27-none-any.whl </a>
</body>
</html>
Wheel packages have to follow proper naming convention. Refer to PEP 427 for details. For the dummy package - awesomepy-1.10.3-py27-none-any.whl
, we are assuming,
- Language implementation is Python 2.7 -
py27
- ABI tag is none -
none
- Platform is any -
any
Finally you can install the packages using the below command. Ensure your packages have different names than that of pypi packages. Prefixing the package name with your company initials is one simple solution.
pip install awesomepy rattlesnake==0.1.1 --extra-index-url=<s3 Endpoint> --trusted-host=<s3 Endpoint without http>
Upgrading packages using pip install awesomepy --upgrade
will also work with this approach.
Also, modify your bucket permissions to restrict the packages to intended clients. One way to do this is:
Select Permissions tab in the bucket --> Edit Bucket Policy
Original Credit: My ex-manager, Adlon :)
pip
's--index-url
/--extra-index-url
parameters.