Package: raypack
raypackRaypack will create a package for AWS Glue, Ray.io tasks. This automates
thisdocumentation pagethat has
some handwavy descriptions of shell commands. AWS Lambdas also call for a similar type of packaging, but as far as I
know it is no sort of standard.Use this if you have private dependencies, native dependencies, or you want to package your own code as a python
package. AWS Glue can't handle anything without a binary wheel or private package repositories, gcc or other build tools
are not in Glue runtime images.See below for build options.raypack is not supported by Amazon, AWS, nor Anyscale, Inc the makers of ray.io. Some code generate with ChatGPT (OpenAI)InstallationYou are encouraged to install with pipx so that the CLI tools dependencies do not conflict with your project
dependencies.pipxinstallraypackUsageraypack[--verbose]python-mraypack[--verbose]Configuration. If none specified, defaults are as below.[tool.raypack]exclude_packaging_cruft=trueouter_folder_name="venv"source_venv=".venv"venv_tool="poetry"Build OptionsIf your dependencies are all pure python, the packaging will work on any machine. However, if your dependencies have any native code:Arm64 built on an Arm64 machineAn actual arm64 build runner with gcc - Best option, will allow compiling native code correctly.Docker e.g.FROM public.ecr.aws/lambda/python:3.9-arm64- Second best option, I haven't tried it, not sure if it
works on all build runners that are not actually arm64
CPUs.exampleMac BinariesAn arm64 machine e.g. mac - Next best option, not sure if it will work.Precompiled BinariesAny machine or an arm64 machine like a mac- Would work in limited situations, namely when there are precompiled
binaries (wheels) or all packages are pure python.The last option works by telling pip to just download and unzip the arm64 wheels. If there aren't wheels or if the wheels
weren't compiled for arm64, then you have to consider finding a different machine or convincing package maintainers to support wheels and more kinds of wheels.CapabilitiesTODO: Warn if not python 3.9 or other glue compatible versionTODO: create a venv for 3.9 if current venv is not 3.9Calls poetry to create a virtualenv without dev dependenciesTODO: support pip, pipenv to create virtualenv.Finds site-packagesZips virtualenv and zips own packageTODO: support single file modules, eg. mymodule.pySkips cruftRun as few subprocesses as possibleconfig using pyproject.toml or CLI argsTODO: Uploads to s3pipx installableworks on any OS as well as is possible (can't handle linux binaries on windows for example)Remove packages AWS includesAWS's documentation on packaging ray jobs[ray's documentation on dependencies](https://docs.ray.io/en/latest/ray-core/handling-dependencies.html.AWS's documentation on packaging spark jobsHow it worksOn native arm64 machineGather info from pyproject.toml or CLI args, but not both.Create a local .venv and .whl using poetry.Create a new zip file with an extra top level folder.Find the site-packages folder and copy to a new zipFind the module contents in .whl and copy to a new zipUpload to s3Use s3 py modules"--s3-py-modules", "s3://s3bucket/pythonPackage.zip"On non-arm64 machineUse poetry lock file to generate requirements.txtUse pip's download target with specified platform (arm64) to simulate creating a venvCombine with own code as aboveUpload to s3 as aboveContributingTo install and run tests and linting tools.poetryinstall--withdev
makecheckTo see if the app can package up other appspoetrybuild# exist poetry shell so that pipx can install with the right base pythonexitpipxinstall/e/github/raypack/dist/raypack-0.1.0-py3-none-any.whlAnd then in a different project with apyproject.tomlfile, runraypackPrior ArtRandom scripts in commentsSome make file scriptSimilar to PEX or other venv zip tools, which as far as I know are not AWS aware, or they don't include all the
dependencies, or they are more interested in making the archive file executable or self-extracting.AWS Lambdas also have to go through a similar ad hoc zip process.DocumentationTODOChange Log0.1.0 - Idea and reserve package name.