Package: poeblix
poeblixPoetry Plugin that adds various features that extend thepoetrycommand such as building wheel files with locked dependencies, and validations of wheel/docker containers.Supports poetry versions1.2+OverviewThese contain custom poetry plugins that enable functionality not available in the official distribution of poetry.  These include:Using the Lock file to build a wheel file with pinned dependenciesSupport for data_files (like with setup.py) such as jupyter extensions or font filesValidating a wheel file is consistent with dependencies specified in pyproject.toml/poetry.lockValidating a docker container'spip freezecontains dependencies as specified in pyproject.toml/poetry.lockThese are not supported in Poetry due to debate in the community:https://github.com/python-poetry/poetry/issues/890,https://github.com/python-poetry/poetry/issues/4013,https://github.com/python-poetry/poetry/issues/2778Deterministic builds and environmentsPoetry guarantees deterministic installations and environments thanks
to thepoetry.lockfile, which is where it stores the exact versions
of all the dependencies needed to install a package. However, this doesn't
occurs when wheel or package artifacts are build usingpoetry buildcommand.To build a package, poetry uses the direct dependencies set in thepyproject.tomland not all the other dependencies required to install
a package. For example, ifpyproject.tomldefinespandas = "1.4.2"as dependency butpoetry.lockalso says thatpandasrequires ofnumpy-1.22.4, poetry will build a package withpandasas dependency
but not withnumpy.Another problem that exists is thatpyproject.tomlcan contain dependencies
with ranges of versions whilepoetry.lockhas pinned versions. For instance,
ifpyproject.tomlhas as dependencypandas = ">=1.3"butpoetry.locksetspandas-1.4.2, poetry will build a package with the dependencyRequires-Dist: pandas (>=0.1.3,<0.2.0). When the package is installed,
the resolver will install the newest package ofpandaswhich its version
number is greater than or equal to0.1.3and lower than0.2.0.Summing this up, the same python package created withpoetry buildand
installed several times won't install the same dependencies, making impossible
to have deterministic installations.This plugin solves these problems building python packages that use the
dependencies defined in thepoetry.lock.How to UsePrerequisitePoetry Plugins are only supported in 1.2.0+ which, at the moment (5/29/22), can only be installed when using thenew poetry installer# You can update poetry using
poetry self updateInstallationYou can add the plugin via poetry's CLI:poetry self add poeblixFor <= 1.2:poetry plugin add poeblixOr install directly from source/wheel, then add with the same above command using the absolute path to the built distTo update the plugin:# Update to latest
poetry self add poeblix@latest

# Update to specific version
poetry self add poeblix==<version>You should now see the blix* commands if you runpoetry listUsageTo build a wheel from your package (pyproject.toml dependencies have precedence over poetry.lock ones, by default)poetry blixbuild

# Note: Options below are also available as part of the `blixvalidatewheel` and `blixvalidatedocker` commands

# To disable using lock file for building wheel and only use pyproject.toml
poetry blixbuild --no-lock

# Uses lock dependencies only which are pinned to exact versions, instead of pyproject.toml
poetry blixbuild --only-lock

# Specify additional dependency groups to include as Requires-Dist in the wheel
poetry blixbuild --with-groups=dev,integ,etc.Validate a wheel file has consistent dependencies and data_files as specified in pyproject.toml/poetry.lockpoetry blixvalidatewheel <path-to-wheel>

# Disable using lock file for validation
poetry blixvalidatewheel --no-lock <path-to-wheel>Note: this validates consistency in both directionsValidate a docker container contains dependencies in apip freezeas specified in pyproject.toml/poetry.lockpoetry blixvalidatedocker <docker-container-ID>

# Disable using lock file for validation
poetry blixvalidatedocker --no-lock <docker-container-ID>Note: this only validates the docker container contains dependencies in the project, but not the other directionHere's an example series of commands to start up a temporary docker container using its tag, validate it, then stop the temporary container# This will output the newly running container id
docker run --entrypoint=bash -it -d <docker-image-tag>

# Then validate the running docker container, and stop it when done
poetry blixvalidatedocker <container-id>
docker stop <container-id>Adding data_files to pyproject.toml to mimic data_files in setup.py:...[tool.blix.data]data_files = [{ destination = "share/data/", from = [ "data_files/test.txt", "data_files/anotherfile" ] },{ destination = "share/data/threes", from = [ "data_files/athirdfile" ] }]...data_files should be under the[tool.blix.data]category and is a list of objects, each containing thedestinationdata folder, and afromlist of files to add to the destination data folder.Note: the destination is a relative path that installs data to relative to theinstallation prefixExample:https://github.com/spoorn/poeblix/blob/main/test/positive_cases/happy_case_example/pyproject.tomlFor more help on each command, use the --help argumentpoetry blixbuild --help
poetry blixvalidatewheel --help
poetry blixvalidatedocker --helpDevelopment# Make a virtual environment on Python 3.9# If using virtualenvwrapper, run `mkvirtualenv -p python3.9 venv`virtualenv-ppython3.9venv# Or activate existing virtualenv# If using virtualenvwrapper, run `workon venv`sourcevenv/bin/activate# installs the plugin in editable mode for easier testing via `poetry install`./devtoolbootstrap# Lint checks./devtoollint# Tests./devtooltest# Run all checks and tests./devtoolallplugins.py: contains our plugin that adds thepoetry blixbuildcommand for building our wheel filevalidatewheel.py: adds apoetry blixvalidatewheelcommand that validates a wheel file contains the Required Dist as specified in pyproject.toml/poetry.lockvalidatedocker.py: adds a command that validates a docker file contains dependencies as specified in pyproject.toml and poetry.lock.  This doesNOTvalidate that they are exactly matching, but rather that all dependencies in pyproject.toml/poetry.lock exist in the docker container on the correct versions.  The docker image may contain more extra dependencies