Skip to main content

Repackages apps to restrict installation into isolated env

Project description

📦 srepkg (Solo Repackage)

Python Versions PyPI codecov PyPI - Dependencies Docs License

srepkg is a Python package that wraps an isolation layer around other Python packages.

📖 Description

When a package wrapped in an isolation layer by srepkg is installed in an active, pre-existing Python environment:

  • The original package plus its dependencies are installed in a new, automatically created virtual environment.
  • A dependency-free "access" package installed in the pre-existing environment contains a controller module capable of making calls to the Python interpreter in the newly created environment.
  • This package structure ensures that none of the original package's dependencies conflict with packages in the pre-existing environment but still exposes the original package’s CL to the pre-existing environment.

🎯 Use Cases

For Package Distributors

  • srepkg can be useful if you are sharing a Python command line application, and you want to be certain that users can install and run it without worrying about dependency conflicts.
  • Wrapping a CL package with srepkg prior to sharing the package with other users will ensure that wherever the package is installed, it does not introduce dependency conflicts into a user's existing Python environment — even if the user knows nothing about managing Python environments.

For Package Users

  • Any existing CL package obtained from Python Packaging Index (PyPI) or GitHub can be wrapped with srepkg prior to installation.
  • If you want the original package commands to be accessible from a single environment (that is distinct from the isolated environment where the original package is installed), then srepkg is likely a good option.
  • However, if you want the isolated package's command interface to be available globally and/or want a much more mature isolation tool, then pipx is likely a better choice.

📘 Documentation

Full project documentation, including detailed examples, is available at: duanegoodner/github.io/srepkg

⚡ Quick Start

Requirements

  • Python version 3.9 or higher
  • For compatibility with srepkg, and existing package must:
    • Be installable via pip
    • Be compatible with the Python interpreter version that is running srepkg.
    • Have command line entry point(s) specified in either one the [project.scripts] section of a pyproject.toml (preferred), the [options.entry_points] section of a setup.cfg, or the entry_points arguments passed to setup() in a setupy.py file.
  • Optional: miniconda or conda if you want to exactly follow the examples below

Simple Demo

# Create and activate a new conda environment for testing
conda create -n srepkg_test python=3.11
conda activate srepkg_test

# Install srepkg from PyPI
pip install srepkg

# Re-package a version of black, obtained from PyPI
srepkg black -r 25.1.0  # creates re-package wheel and sdist under ./srepkg_dists

# install our re-packaged wheel
pip install ./srepkg_dists/blacksrepkg-25.1.0-py3-none-any.whl

# Confirm blacksrepkg is installed and that black is NOT installed in our conda env
conda list | grep black
# Output:
# blacksrepkg               25.1.0                   pypi_0    pypi

# Check if any of black's dependencies are installed in our conda environment
onda list | grep "click\|\
mypy_extensions\|\
packaging\|\
pathspec\|\
platformdirs\|\
tomli\|\
typing_extensions"

# Output:
# packaging                 24.2                     pypi_0    pypi

# Note: 'packaging' is installed because it is a dependency of 'srepkg'.
# No other package that black depends on is in our environment.

# Confirm that we have access to the black CLI
black -c "def foo():print('hello,world')"
# Output:
# def foo():
#    print("hello,world")

Command Line Help

For details on all srepkg command options, run:

srepkg --help

🧪 Testing

To run the project tests, we can clone a copy of the repo locally, and install in editable mode with:

$ git clone https://github.com/duanegoodner/srepkg
$ cd srepkg
$ pip install -e '.[test]'

Then run the test suite and generate a coverage report:

$ coverage run -m pytest
$ coverage report -m

🤝 Contributing

Issues, Pull Requests and/or Discussions are welcome and appreciated!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

srepkg-0.1.4.tar.gz (74.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

srepkg-0.1.4-py3-none-any.whl (97.2 kB view details)

Uploaded Python 3

File details

Details for the file srepkg-0.1.4.tar.gz.

File metadata

  • Download URL: srepkg-0.1.4.tar.gz
  • Upload date:
  • Size: 74.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for srepkg-0.1.4.tar.gz
Algorithm Hash digest
SHA256 91973467ed9b9af83c558737d23f6c58f73112e2d29a726262965c865c724b6b
MD5 a3fd17483a167cce84ca00411cf287bc
BLAKE2b-256 6f4e42294fd5e4d6c50c68ff6f88ba722ca5a1e11292e797ae9d2b5ba3965bb2

See more details on using hashes here.

File details

Details for the file srepkg-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: srepkg-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 97.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for srepkg-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 469f619a86e1781e781a88ee53958e9f4418f63f04e0dcba6fb51e7890f3e5cb
MD5 bffd3785e530df518d17c8b5fcb8e177
BLAKE2b-256 45bb187904f182981db3ee8aab99d257045569d8e5a9c4fce2ff9d836edd67dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page