aws serverless python_Serverless pypi:在AWS上运行的大多数功能简单的pypi服务

elastic pypi

A fully functional, self-hosted simple pypi service running on AWS.

Caveats

Browse with a browser Browsers are currently limited by the removal of basic authentication for remote URLs via the URL (e.g. x:y@z). However, if you visit the URL directly, the browser will prompt you to either enter a username and password, or install this plugin for Chrome and setup the credentials accordingly.

Uploads through the api are limited to 6MB

Uploads are limited to 6MB through the API because Lambda limits the body size. https://docs.aws.amazon.com/lambda/latest/dg/limits.html#limits-list

Uploads directly to the S3 bucket are limited by whatever S3 does.

Only uploads through the API are checked for and discriminated by the overwrite configuration setting.

Downloads are limited to 10MB

Setup

Edit serverless.yml

Configuration

serverless.yml

service: elasticpypi

provider:

name: aws

runtime: python3.6

memorySize: 128

stage: dev

# profile: "some-local-aws-config-profile"

# region: us-east-1

environment:

SERVICE: ${self:service} # See above. Defaults to elasticpypi

STAGE: "/${self:provider.stage}" # See above. Defaults to dev

BUCKET: "elasticpypi" # CHANGE ME

TABLE: "elasticpypi" # You can change me if you want, but do you?

USERNAME: "elasticpypi" # You can change me if you want, but do you?

PASSWORD: "something-secretive" # CHANGE ME

OVERWRITE: false # Allow uploads to overwrite already existing packages

Deploy

npm/yarn and pip are required to install the necessary packages to deploy.

yarn or npm install

sls deploy

Note that when deploying do not have the virtualenv activated. The wsgi plugin for serverless will automatically fetch the python requirements.

Using

Based on the output of the deploy command or via the AWS console add the url to your pip conf.

The url should be something like https://blah.execute-api.region.amazonaws.com/dev/simple.

Make sure you add a trailing slash as required in the PEP.

Make sure you add your basic authentication credentials to your url.

Throttling

AWS resources could be throttled. As such, if you are intending to dump a bunch of packages into the S3 bucket, please check your service and account limits. Additionally, changing the read and write capacity of dynamodb may help. It is currently set to the lowest possible unit (1).

Testing

Requirements

Install testing requirements from test-requirements.txt

Run python -m pytest

Using Docker

The example below runs the full test suite. To debug, add /bin/bash to the end of the command.

$ sudo docker build -t elasticpypi-test .

$ sudo docker run -it \

-v $(pwd):/code \

elasticpypi-test

Changelog

2018-11-26 HTTP Basic Authentication works for in browser browsing

2018-01-04 Downloads up to 10 MB work without signed requests

2017-12-27 Uploads work. Manually tested with python setup.py upload and twine upload

2017-12-22 Use Python 3, downloads go through the API Gateway so pip's caching now works

2017-03-24 The configuration has moved from ./elasticpypi/config.json to ./serverless.yml and is consumed by elasticpypi as environment variables. If you are upgrading from an older version, you may need to migrate your configuration to serverless.yml.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值