Skip to content

Commit

Permalink
Changed MIRROR_INDEX_URL to UPSTREAM_INDEX_URL
Browse files Browse the repository at this point in the history
since this is more descriptive.
  • Loading branch information
Joseph Wortmann committed Aug 26, 2022
1 parent 857c114 commit ed92220
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Uploads using `twine` are still quite fast, but since these must be processed di

## Installation
`serverless-pypi` can be obtained from:
1. the `lambdalambdalambda` repo as a fully built Lamba package (https://lambdalambdalambda-repo-<region>.s3.<region>.amazonaws.com/quinovas/serverless-pypi/serverless-pypi-<version>.zip). Currently `lambdalambdalambda` supports the `us-east-1`, `us-east-2`, `us-west-1`, `us-west-2` and `eu-west-1`. For `us-east-1` simply use no region (e.g. - https://lambdalambdalambda-repo.s3.amazonaws.com/quinovas/serverless-pypi/serverless-pypi-0.0.5.zip).
1. the `lambdalambdalambda` repo as a fully built Lamba package (https://lambdalambdalambda-repo-<region>.s3.<region>.amazonaws.com/quinovas/serverless-pypi/serverless-pypi-<version>.zip). Currently `lambdalambdalambda` supports the `us-east-1`, `us-east-2`, `us-west-1`, `us-west-2` and `eu-west-1`. For `us-east-1` simply use no region (e.g. - https://lambdalambdalambda-repo.s3.amazonaws.com/quinovas/serverless-pypi/serverless-pypi-0.0.6.zip).
2. cloning and building via `python setup.py ldist` (note the build *must* be done on an `Amazon Linux 2` host).
3. installing into a folder using `pip install --target build_dir serverless-pypi`, and then zipping `build_dir` into a lambda package (note the build *must* be done on an `Amazon Linux 2` host).

Expand All @@ -45,7 +45,7 @@ If you are deploying `serverless-pypi` stand-alone, you will need to provision a
| API_GATEWAY_BASE_PATH | N | Sets the base path for the Lambda function. Only applicable if this is fronted by an AWS API Gateway. | / |
| BUCKET | Y | The AWS S3 bucket that is used to store the PyPI information. | |
| LOGGING_LEVEL | N | Sets the logging level for the Lambda function | INFO |
| MIRROR_INDEX_URL | N | The url underlying PyPI repository to mirror. This may contain credentialing information. | https://pypi.org/simple/ |
| UPSTREAM_INDEX_URL | N | The url underlying PyPI repository to mirror. This may contain credentialing information. | https://pypi.org/simple/ |
| REPO_BASE_PREFIX | N | The prefix to use in the S3 bucket. | "" |

### IAM Permissions
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
lambda_version = "0.0.5"
lambda_version = "0.0.6"

lambda_description = "An AWS Lambda implementation for the PyPI protocols"

Expand Down
14 changes: 7 additions & 7 deletions src/lambda_function/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
supported_platform="Supported-Platform",
version="Version",
)
MIRROR_INDEX_URL = environ.get("MIRROR_INDEX_URL") or "https://pypi.org/simple/"
if not MIRROR_INDEX_URL.endswith("/"):
MIRROR_INDEX_URL += "/"
REPO_PREFIX = environ.get("REPO_BASE_PREFIX") or ""
if REPO_PREFIX and not REPO_PREFIX.endswith("/"):
REPO_PREFIX += "/"
Expand All @@ -121,8 +118,11 @@
PYPI_SIMPLE_V1_HTML_INDEX_KEY = f"{REPO_PREFIX}index.html"
PYPI_SIMPLE_V1_JSON_INDEX_KEY = f"{REPO_PREFIX}{V1_JSON_KEY}"
PROJECTS_PREFIX = f"{REPO_PREFIX}projects/"
USERS_PREFIX = f"{REPO_PREFIX}users/"
S3_CLIENT: S3Client = None
USERS_PREFIX = f"{REPO_PREFIX}users/"
UPSTREAM_INDEX_URL = environ.get("UPSTREAM_INDEX_URL") or "https://pypi.org/simple/"
if not UPSTREAM_INDEX_URL.endswith("/"):
UPSTREAM_INDEX_URL += "/"

##############################
## MODELS ##
Expand Down Expand Up @@ -279,7 +279,7 @@ def get_remote_project_detail(cls, project: str) -> PyPIProjectDetail:
project,
requests.get(
headers=dict(Accept=ACCEPT_HEADER),
url=f"{MIRROR_INDEX_URL}{project}/",
url=f"{UPSTREAM_INDEX_URL}{project}/",
),
)
except requests.HTTPError as he:
Expand Down Expand Up @@ -380,11 +380,11 @@ def verify(self, password: str) -> bool:

def create_index(context: LambdaContext = None) -> None:
getLogger().info("Indexing")
getLogger().info(f"Retrieving remote index from {MIRROR_INDEX_URL}")
getLogger().info(f"Retrieving upstream index from {UPSTREAM_INDEX_URL}")
project_list = PyPIProjectList.parse_response(
requests.get(
headers=dict(Accept=ACCEPT_HEADER),
url=MIRROR_INDEX_URL,
url=UPSTREAM_INDEX_URL,
)
)
getLogger().info("Adding package repositories to the index")
Expand Down

0 comments on commit ed92220

Please sign in to comment.