Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
9 changes: 5 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate black
pyflakes pakages/utils/fileio.py
pyflakes pakages/utils/terminal.py
pyflakes pakages/*.py
pyflakes pakages/handlers/*.py
for filename in $(find pakages -name "*.py" -not -path "./docs/*" \
-not -path "pakages/oras.py" -not -path "pakages/cli/shell.py" \
-not -path "*__init__.py" -not -path "./env/*"); do
pyflakes $filename
done
22 changes: 22 additions & 0 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test-action

on:
pull_request: []

jobs:
test-action:
name: Test Build Action
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Pakages
run: pip install -e .[all]

- name: Test Pakages Build
uses: ./action/build
with:
user: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
target: ghcr.io/syspack/pakages/pakages-bundle:latest
49 changes: 49 additions & 0 deletions action/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "pakages build"
description: "Build oras pakages"
inputs:
builder:
description: the builder to use (defaults to auto-detect)
default: ""
user:
default: username to authenticate to GitHub packages
required: true
token:
default: token authenticate to GitHub packages
required: true
path:
description: path to root of package (defaults to PWD)
default: "."
target:
description: target to upload to (defaults to GitHub repository)
default: ""

runs:
using: "composite"
steps:
- name: Install Pakages
shell: bash
run: |
which pakages || (
git clone -b isolate-spack https://github.com/syspack/pakages
cd pakages
pip install -e .
)

- name: Build Package
env:
ORAS_USER: ${{ inputs.user }}
ORAS_PASS: ${{ inputs.token }}
builder: ${{ inputs.builder }}
path: ${{ inputs.path }}
target: ${{ inputs.target }}
run: |
cmd="pakages build"
if [[ "${builder}" != "" ]]; then
cmd="${cmd} -b ${builder}"
fi
cmd="pakages build ${path}"
if [[ "${target}" != "" ]]; then
cmd="${cmd} --push ${target}"
fi
$cmd
shell: bash
87 changes: 53 additions & 34 deletions docs/getting_started/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ If you are using a pre-built container, this will already be the case.
Commands
========

-----
Spack
-----

Pakages provides the following commands via the ``pakages`` command line client.

Install
Expand All @@ -51,14 +55,13 @@ and deploy your own packages, you should see :ref:`getting_started-developer-gui
Spack
^^^^^

Since pakages is a wrapper to spack, you can install any list of packages that you would
install with spack, just using pakages install (which is installable via pip so it can be on your path
Pakages can install from spack just using pakages install (which is installable via pip so it can be on your path
more easily or in a Python environment).


.. code-block:: console

$ pakages install zlib
$ pakages --builder spack install zlib
# equivalent to pakages -b spack install zlib
Preparing to install zlib
linux-ubuntu20.04-skylake
[+] /home/vanessa/Desktop/Code/syspack/pakages/pakages/spack/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.11-3kmnsdv36qxm3slmcyrb326gkghsp6px
Expand All @@ -72,7 +75,7 @@ this binary install or the SBOM, you could just install with spack. To change th

.. code-block:: console

$ pakages install zlib --registry ghcr.io/myorg
$ pakages -b spack install zlib --registry ghcr.io/myorg

Note that we use the manifest
of the artifact to validate the checksum before installing it.
Expand All @@ -97,7 +100,7 @@ Then you can install all packages via:

.. code-block:: console

$ pakages install .
$ pakages -b spack install .

Pakages will detect that you want to install from the present working directory,
and then install appropriately. The above ``.`` will install all packages in the present working directory.
Expand All @@ -107,7 +110,7 @@ If you don't want to install all packages in the local repository, you can also

.. code-block:: console

$ pakages install . zlib
$ pakages -b spack install . zlib


This install command is different from a traditional ``spack install zlib`` because we are providing an absolute
Expand All @@ -117,7 +120,7 @@ a repository with the same package structure but from a remote on GitHub:

.. code-block:: console

$ pakages install https://github.com/pakages/zlib
$ pakages -b spack install https://github.com/pakages/zlib

The above will create a temporary repository to use, and then clean up.

Expand All @@ -129,7 +132,7 @@ If you want a quick shell to interact with the Pak client and spack, you can do:

.. code-block:: console

$ pakages shell
$ pakages -b spack shell
Python 3.8.8 (default, Apr 13 2021, 19:58:26)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.30.1 -- An enhanced Interactive Python. Type '?' for help.
Expand All @@ -144,26 +147,43 @@ Build
-----

The main functionality of pakages is (drumroll) to build packages that are then easy to install
in a container, or again into the spack install that comes with Pakages. A basic build is going
to generate a build cache with one or more specs of interest. Any time you build and
in a container. A basic build is going to generate a build cache with one or more packages of interest. Any time you build and
push to a trusted Pakages registry (the one in your settings) then this registry will be used as a cache for future installs.
Here is how to build zlib:

Python Build
^^^^^^^^^^^^

If you have a repository with a setup.py, it is determined to be a Python package
and we will attempt to build with traditional approaches (e.g., setuptools).
Here is an example:

.. code-block:: console

$ git clone https://github.com/vsoch/citelang /tmp/citelang
$ cd /tmp/citelang
$ pakages build

TODO over weekend or similar

Spack Build
^^^^^^^^^^^

Here is how to build zlib (from spack):

.. code-block:: console

$ pakages build zlib
$ pakages -b spack build zlib

By default, a build cache will be created in a temporary directory and the Pakages
saved there. This is recommended, as each pak is intended to be modular. If you want
For spack, by default, a build cache will be created in a temporary directory and the Pakages
saved there. This is recommended, as each pakage is intended to be modular. If you want
to specify a custom cache (or one that is always used) you can add ``--cache-dir``.
You also might want to set a specific gpg key hash to sign with ``--key`` (otherwise
we will default to the first one we find that is commented to be intended for Spack).
When you do a build, it will show you the location of the build cache.


.. code-block:: console

$ pakages build zlib
$ pakages -b spack build zlib
Preparing to install zlib
linux-ubuntu20.04-skylake
[+] /home/vanessa/Desktop/Code/syspack/pakages/pakages/spack/opt/spack/linux-ubuntu20.04-skylake/gcc-9.3.0/zlib-1.2.11-3kmnsdv36qxm3slmcyrb326gkghsp6px
Expand All @@ -172,29 +192,28 @@ When you do a build, it will show you the location of the build cache.

Build also supports local and remote repositories, as outlined in install. For example:


.. code-block:: console

$ pakages build .
$ pakages -b spack build .

Or build a package by name:

.. code-block:: console

$ pakages build . zlib
$ pakages -b spack build . zlib

Or build from a remote:

.. code-block:: console

$ pakages build https://github.com/pakages/zlib
$ pakages -b spack build https://github.com/pakages/zlib

Akin to install, you can also specify a registry to add to look for build cache entries
to speed up the install:

.. code-block:: console

$ pakages build zlib --registry ghcr.io/myorg
$ pakages -b spack build zlib --registry ghcr.io/myorg


Build and Push
Expand All @@ -205,28 +224,28 @@ use a command line tool called oras to upload there:

.. code-block:: console

$ pakages build zlib --push ghcr.io/syspack/pakages
$ pakages -b spack build zlib --push ghcr.io/syspack/pakages

It's recommeded to `install oras <https://oras.land/cli/>`_ so it's faster, but if you don't it will be bootstrapped (and you
can go off and have a sandwich or sword fight!). By default, the above with ``--push``
will build, push, and cleanup. You can disable cleanup:

.. code-block:: console

$ pakages build zlib --no-cleanup --push ghcr.io/pakages
$ pakages -b spack build zlib --no-cleanup --push ghcr.io/pakages

If you customize the ``--cache-dir`` folder cleanup will be disabled, as it is assumed that you don't want to delete a non-temporary directory.
To force a cleanup of a custom cache directory, add ``--force``

.. code-block:: console

$ pakages build zlib --no-cleanup --force --push ghcr.io/pakages
$ pakages -b spack build zlib --no-cleanup --force --push ghcr.io/pakages

The above examples show a push using a custom GitHub unique resource identifier. To use the default trusted registry from your settings, just do:

.. code-block:: console

$ pakages build zlib --pushd
$ pakages -b spack build zlib --pushd


Push
Expand All @@ -236,32 +255,32 @@ If you have an existing build cache you want to push:

.. code-block:: console

$ pakages push /tmp/pakages-tmp.nudv7k0u/ ghcr.io/syspack/pakages
$ pakages -b spack push /tmp/pakages-tmp.nudv7k0u/ ghcr.io/syspack/pakages

Or push and cleanup:

.. code-block:: console

$ pakages push --cleanup /tmp/pakages-tmp.nudv7k0u/ ghcr.io/syspack/pakages
$ pakages -b spack push --cleanup /tmp/pakages-tmp.nudv7k0u/ ghcr.io/syspack/pakages

You can optionally define a default ``cache_dir`` in your settings, in which case you can leave it out:

.. code-block:: console

$ pakages push ghcr.io/syspack/pakages
$ pakages -b spack push ghcr.io/syspack/pakages

The registry will be detected since it starts with ``ghcr.io`` and the default cache directory used. Alternatively,
leave the registry out to use the default, and provide the cache directory:

.. code-block:: console

$ pakages push /tmp/pakages-tmp.nudv7k0u/
$ pakages -b spack push /tmp/pakages-tmp.nudv7k0u/

And finally, if you really want to streamline and use the default registry and cache directory, just push!

.. code-block:: console

$ pakages push
$ pakages -b spack push


Uninstall
Expand All @@ -271,7 +290,7 @@ You can also uninstall a package.

.. code-block:: console

$ pakages uninstall zlib
$ pakages -b spack uninstall zlib


List
Expand All @@ -281,7 +300,7 @@ List installed packages as follows:

.. code-block:: console

$ pakages list
$ pakages -b spack list
-- linux-ubuntu20.04-x86_64 / gcc@9.3.0 -------------------------
zlib@1.2.11

Expand Down Expand Up @@ -310,7 +329,7 @@ And then you can easily install.

.. code-block:: console

# pakages install zlib
# pakages -b spack install zlib
Preparing to install zlib
[+] /opt/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-3rlgy7ycxtoho44una6o3itgfjltkmpd

Expand Down
9 changes: 7 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if [ -z "${package}" ]; then
exit 1
fi

if [ -z "${builder}" ]; then
printf "No builder set! Assuming spack.\n"
export builder=spack
fi

# If deploy is set to true and we don't have a uri, this is an error
if [ "${deploy}" == "true" ] && [ -z "${uri}" ]; then
printf "If you want to deploy you must define a uri (unique resource identifier)\n"
Expand All @@ -29,7 +34,7 @@ fi

# Run pakages for the specs provided, with deploy or not
if [ "${deploy}" == "true" ]; then
pakages build "${package}" --push "${uri}"
pakages build --builder "${builder}" "${package}" --push "${uri}"
else
pakages build "${package}"
pakages build --builder "${builder}" "${package}"
fi
3 changes: 0 additions & 3 deletions pakages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from pakages.version import __version__

assert __version__
import pakages.utils as utils

utils.add_spack_to_path()
Loading