10000 Deploy py-compiled build by rth · Pull Request #3701 · pyodide/pyodide · GitHub
[go: up one dir, main page]

Skip to content

Deploy py-compiled build #3701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 29, 2023
Merged

Deploy py-compiled build #3701

merged 13 commits into from
Mar 29, 2023

Conversation

rth
Copy link
Member
@rth rth commented Mar 26, 2023

This enables deployment of a py-compiled build under,

https://cdn.jsdelivr.net/pyodide/<version>/pyc/

Here both the packages and the stdlib would be py-compiled.

With the stdlib being unvendored (thanks @ryanking13 ) it's actually relatively straightforward to do this as a post-processing step after the build.

This is built on top of #3700 so that PR should be merged first.

Closes #3269 Closes #3269

This also replaces the previous aws cli commands with a Python script, so that CI setup is less repetitive, and we can validate things better.

$ python tools/deploy_s3.py --help
                                                                                                                                                      
 Usage: deploy_s3.py [OPTIONS] LOCAL_FOLDER REMOTE_PREFIX                                                                                             
                                                                                                                                                      
 Deploy a dist folder with Pyodide packages to AWS S3                                                                                                 
                                                                                                                                                      
╭─ Arguments ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    local_folder       PATH  Path to the local folder [default: None] [required]                                                                  │
│ *    remote_prefix      PATH  Remote prefix [default: None] [required]                                                                             │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *  --bucket                                         TEXT  bucket name [default: None] [required]                                                   │
│    --cache-control                                  TEXT  Cache control header to set [default: max-age=30758400, immutable, public]               │
│    --pretend               --no-pretend                   Don't actually upload anything [default: no-pretend]                                     │
│    --overwrite             --no-overwrite                 Overwrite existing files [default: no-overwrite]                                         │
│    --rm-remote-prefix      --no-rm-remote-prefix          Remove existing files under the remote prefix [default: no-rm-remote-prefix]             │
│    --install-completion                                   Install completion for the current shell.                                                │
│    --show-completion                                      Show completion for the current shell, to copy it or customize the installation.         │
│    --help                                                 Show this message and exit.                                                              │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

TODO:

  • switch to a docker image in CI used for deployment where we can install pyodide-build (needs Python 3.11). As the cibuilds/github image we use is no longer maintainer.
  • manually check that the instructions in that docker image work.

@hoodmane
Copy link
Member

This also replaces the previous aws cli commands with a Python script, so that CI setup is less repetitive, and we can validate things better.

Maybe this should be a separate pr?

@rth
Copy link
Member Author
rth commented Mar 26, 2023

Well most of this PR is re-writing that deployment script. Once we have it, doing the pyc deployment is just a couple of lines in the CI setup since most of the work for it is done in #3700

@rth
Copy link
Member Author
rth commented Mar 28, 2023

OK the diff should be much smaller now that the other PR is merged. Though we would need to fix test-core-firefox on main as otherwise the dev deployment won't happen.

@rth rth mentioned this pull request Mar 29, 2023
find dist/ -type f -print0 | xargs -0 -n1 -I@ bash -c "echo \"Compressing @\"; gzip @; mv @.gz @;"
aws s3 sync dist/ "s3://pyodide-cdn2.iodide.io/v${CIRCLE_TAG}/full/" --exclude '*.zip' --exclude '*.whl' --exclude "*.tar" --cache-control 'max-age=30758400, immutable, public' --content-encoding 'gzip' # 1 year cache
aws s3 sync dist/ "s3://pyodide-cdn2.iodide.io/v${CIRCLE_TAG}/full/" --exclude '*' --include '*.zip' --include "*.whl" --include "*.tar" --cache-control 'max-age=30758400, immutable, public' --content-type 'application/wasm' --content-encoding 'gzip' # 1 year
python3 tools/deploy_s3.py dist/ "v${CIRCLE_TAG}/full/" --bucket "pyodide-cdn2.iodide.io" --cache-control 'max-age=30758400, immutable, public'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to see this deployment logic factored out and tested. In the future I think it would be good to move this whole recipe into a Python script that we can test (other than install requirements of course).

typer.echo(" - content-encoding: gzip")

if rm_remote_prefix:
_rm_s3_prefix(bucket, str(remote_prefix).lstrip("/"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to validate the prefix in some way to reduce chance of accidentally deleting everything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't pretend also apply to deleting stuff?

Copy link
Member Author
@rth rth Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't pretend also apply to deleting stuff?

Yes, good that someone is reviewing this code ^^ Fixed.

Maybe we want to validate the prefix in some way to reduce chance of accidentally deleting everything?

Indeed. Let's do more validation of it and only allow deletion of prefixes starting with "/dev/".

Comment on lines +87 to +91
elif file_path.suffix == ".ts":
# This will not be correctly detected by mimetypes.
# However, JsDelivr will currently not serve .ts file in the
# custom CDN configuration, so it does not really matter.
content_type = "text/x.typescript"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.d.ts files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the MIME type for .ts and .d.ts files is a bit unclear but it doesn't really matter, since both are currently not allowed to be served via JsDelivr

https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.ts (returns 403 forbidden)

So people get it from npm anyway.

@rth rth merged commit 7f4f66b into pyodide:main Mar 29, 2023
@rth rth deleted the deploy-s3 branch March 29, 2023 20:54
@rth
Copy link
Member Author
rth commented Mar 30, 2023

The dev deployment went through but the returned MIME types are not correct. Currently they are text/plain for both .js and .zip files which is wrong. Will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC Distribute bytecode compiled sources (.pyc)
3 participants
0