Coder Social home page Coder Social logo

khornberg / elasticpypi Goto Github PK

View Code? Open in Web Editor NEW
204.0 7.0 14.0 618 KB

Serverless pypi

Home Page: https://khornberg.github.io/elasticpypi/

License: Apache License 2.0

Python 97.80% HTML 1.41% Dockerfile 0.79%
python pypi aws serverless hacktoberfest

elasticpypi's Introduction

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

This again is a limitation of AWS; specifically API Gateway. https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html#api-gateway-limits

Setup

  1. Edit serverless.yml

Configuration

serverless.yml

service: elasticpypi

provider:
  name: aws
  runtime: python3.9
  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
    USERS: "my:blah,your:secret"      # OPTIONAL, default not present
    OVERWRITE: false                  # Allow uploads to overwrite already existing packages

Users

USERS may be a comma delimited string of username:password. If present it will be used instead of USERNAME and PASSWORD

Deploy

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

  1. yarn or npm install
  2. 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

  1. Install testing requirements from test-requirements.txt
  2. 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

  • 2022-05-19 Update serverless and serverless-wsgi versions

  • 2022-04-29 Support any cased Authorization header; drop python 3.6 support; updates to a bunch of dependencies

  • 2021-03-08 Add Cache-Control header so pip caches the package

  • 2020-10-12 Multiple users

  • 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.

elasticpypi's People

Contributors

chensjlv avatar conflate avatar dependabot-support avatar inhumantsar avatar khornberg avatar llonchj avatar pyup-bot avatar renovate-bot avatar renovate[bot] avatar rs-garrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

elasticpypi's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency serverless-wsgi to v3.0.4
  • chore(deps): update dependency serverless to v3.39.0
  • chore(deps): update dependency pytest to v8
  • chore(deps): update dependency pytest-cov to v5
  • chore(deps): update dependency serverless to v4
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
Dockerfile
  • python 3.12
github-actions
.github/workflows/push.yml
  • actions/checkout v3
  • actions/setup-python v4
npm
package.json
  • serverless 3.38.0
  • serverless-apigw-binary 0.4.4
  • serverless-python-requirements 5.4.0
  • serverless-wsgi 3.0.3
pip_requirements
requirements.txt
  • Flask ==2.2.3
  • basicauth ==0.4.1
  • markupsafe ==2.1.5
test-requirements.txt
  • Flask-Testing ==0.8.1
  • pytest ==7.4.4
  • moto ==3.1.19
  • boto ==2.49.0
  • boto3 ==1.33.8
  • pytest-env ==0.8.2
  • flake8 ==4.0.1
  • pytest-cov ==3.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Uploading .whl and pip search

Hey guys,

First, I want to say thanks for this great work.

I'm trying out elasticpypi but I have encountered some problems:

  1. If I upload a .whl with twine. It seems the name and version is totally correct on the dynamoDB table,
    but I cannot pip install it.

  2. pip search seems not working?
    I'm getting: pip._vendor.requests.exceptions.HTTPError: 400 Client Error: Bad Request for url

  3. from the output of the deploy, I get output for functions and endpoints, which corresponds to the lambda functions and api gateway created:
    Do i need to interact with them? or it's just for information purpose that
    when I upload or pip install, elasticpypi will itself figure out which function and api to call?

Overall, I think the documentation is somewhat lacking for this project.
But I guess it's because it's a relatively new project or lacking of manpower.

Cheers!

make use of custom authentication lambda

While this does not fix the basic auth in the browser, it would allow one to enable other kinds of authentication that browsers do allow e.g. token, cookie, etc.

move credentials to parameter store

One could use Secrets Manager, however, one goal of this project is to keep the cost of running this within the free tier (generally of course that depends on usage).

Add a License

Hi there,

Great work! Do you consider adding an open source license so that others can use your work?

Thanks.

quoted filenames fail

When a file is uploaded to S3 with quoted characters (i.e. +) gets stored quoted (as %2B) and quoted filenames can not be pulled by pip.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.