Jun 01, 2015 Running your own PyPI Server on Cloud Foundry
I was recently asked if I could run a PIP server on Cloud Foundry. After a quick Google search I found PyPICloud and discovered that this is possible!
Deploying PyPI to Cloud Foundry
Start by cloning this repo:
git clone https://github.com/mathcamp/pypicloud cd pypicloud
There is a pending pull request here for one of the missing components (waitress). For now there is a workaround by modifying
setup.py and adding
diff --git a/setup.py b/setup.py index ae2568a..39d5db7 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ REQUIREMENTS = [ 'pyramid_tm', 'six', 'transaction', + 'waitress', 'zope.sqlalchemy', ]
Next we need to install PIP tools to run setup:
pip install pypicloud pypicloud-make-config -t server.ini
You will be prompted for the admin user and S3 bucket to store the Python packages. While it is possible to store these files in the local operating system instead of S3, you risk losing these files if the PyPI server is redeployed on Cloud Foundry.
Note: Storing the Python packages to the file system is a terrible idea, you will lose your package. Only use S3 to store the package files.
The port which PyPI server listens on needs to be configured for Cloud Foundry. In the
server.ini that is created the following lines need to be changed from:
[server:main] use = egg:waitress#main host = 0.0.0.0 port = 6543
[server:main] use = egg:waitress#main host = 0.0.0.0 port = %(http_port)s
Finally we need to create a
web: pserve server.ini http_port=$PORT
Now all we need to do is push to Cloud Foundry:
cf push pypicloud