Running a pypiserver on AppEngine backend with Google Cloud Storage.
Disclaimer: This is not a library but an example of a way how to set it up.
- Pypiserver with this plugin runs on App Engine
- Package files are stored on the bucket
- Package files are syncronized between the service's local storage and the bucket
- Syncrhonization happens on pre- and post- hooks of handling the requests
- The plugin is configured on top of the pypiserver's underlying bottle web framework
- It checks for consistency between the files stored in local and remote storage (see
StorageClient
) - Different
ContentChangeEvent
s represent the change situations - Using different
_file_store_driver
s as strategies they are able to synchronize the content.
BUCKET_NAME
- used to specify the destination GCP Storage bucketLOCAL_PACKAGE_DIRECTORY
- used to specify the local directory for packages, make sure it is set to/tmp
when running on AppEngineREMOTE_PACKAGE_DIRECTORY
- used to indicate the directory on a remote bucket (or other destination)TIER
- a tier configuration, can be used to enable various default configurations (seeGlobalSettings
class)
Before running create a requirements.txt file with at least gunicorn
, pypiserver
, google-cloud-storage
Examle requirements.txt
:
```plaintext
pypiserver==1.3.1
gunicorn==20.0.4
google-cloud-storage==1.24.1
```
- Create
app.yaml
file for a Python 3.7+ runtime as described in https://cloud.google.com/appengine/docs/standard/python3/config/appref, note that you can specify environmental variables inapp.yaml
- Specify the
entrypoint: gunicorn -b :8081 -w 2 'main:get_app()'
attribute inapp.yaml
to connect to the wrapped pypiserver app - Make sure a bucket with <YOUR-BUCKET-NAME> exists and specify BUCKET_NAME and REMOTE_PACKAGE_DIRECTORY according to your setup
- Deploy the app as described in
https://cloud.google.com/appengine/docs/standard/python/getting-started/deploying-the-application,
i.e.
gcloud app deploy app.yaml
- Access your app using
gcloud app browse -s <YOUR-SERVICE-NAME>
where <YOUR-SERVICE-NAME> is the name of a service as specified inapp.yaml
- Make sure
gunicorn
is installed - Run
gunicorn --reload -b :8081 -w 2 'main:get_app()'
-
To add a password specification, simply include a
htpasswd.txt
as described in https://github.com/pypiserver/pypiserver#apache-like-authentication-htpasswd -
Create the
htpasswd.txt
file in the root of the application code (on the same level asmain.py
) -
Specify the password file when creating a pypiserver app:
```python ... pypiserver_app = app(root=[GlobalSettings.LOCAL_DIRECTORY], password_file="htpasswd.txt") .... ```
-
Deploy the app as described in "Deployment" section
This effort is also available as a gist:
https://gist.github.com/deemetree-at-satelligence/793ca96bd571bba40ce1f35e9951e73b.
And is an open issue in pypiserver
to include the functionality in the core of the package:
pypiserver/pypiserver#322.
P.S: code can be made cleaner.
P.P.S: if you run into troubles, please include your traces and std outputs in comments
P.P.P.S: this readme could be made better
P.P.P.P.S: this is not a library