Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Dec 13, 2023
1 parent 1b4b3d9 commit 3d20a43
Show file tree
Hide file tree
Showing 30 changed files with 2,595 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Check

env:
POETRY_VERSION: "1.6.1"

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main

permissions:
contents: read

jobs:
run-checks:
name: python-${{ matrix.python-version }}, ${{ matrix.os }}
timeout-minutes: 5

strategy:
matrix:
os:
- "ubuntu-latest"
python-version:
- "3.12"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"

- name: Set up Poetry
run: |
pip install poetry==${{ env.POETRY_VERSION }}
- name: Install packages
run: |
poetry install
- name: Check Python lint
run: |
poetry run -- ruff check . --config pyproject.toml
- name: Check Python formatting
run: |
poetry run -- ruff format --check . --config pyproject.toml
- name: Check packaging
run: |
poetry check
poetry lock --check
59 changes: 59 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test

env:
# Enable colored output for pytest
# https://github.com/pytest-dev/pytest/issues/7443
# https://github.com/actions/runner/issues/241
PY_COLORS: 1
POETRY_VERSION: "1.6.1"

on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main

permissions:
contents: read

# Limit concurrency by workflow/branch combination
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
python-tests:
name: python-${{ matrix.python-version }}, ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest
python-version:
- "3.12"

fail-fast: false

runs-on: ${{ matrix.os }}
timeout-minutes: 10

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Set up Poetry
run: |
pip install poetry==${{ env.POETRY_VERSION }}
- name: Install packages
run: |
poetry install
- name: Run tests
run: |
poetry run -- pytest tests
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__pycache__
.cache
*.pyc
.envrc
build/**/*
dist/**/*
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# packse

Python packaging scenarios.

## Installation

Only a local installation is supported at this time:

```bash
poetry install
```
Once installed, the `packse` command-line interface will be available.

Depending on your Poetry configuration, you may need to use `poetry run packse` instead or activate Poetry's
virtual environment.

## Usage

### Scenarios

A scenario is a JSON description of a dependency tree.

See [`scenarios/example.json`](./scenarios/example.json)

### Building scenarios

A scenario can be used to generate packages and build distributions:

```bash
packse build scenario/example.json
```

The `build/` directory will contain sources for all of the packages in the scenario.
The `dist/` directory will contain built distributions for all of the packages in the scenario.

When a scenario is built, it is given a unique identifier based on a hash of the scenario contents and the project
templates used to generate the packages. Each package in the scenario will include the unique identifier.

### Viewing scenarios

**Not yet implemented**

The dependency tree of a scenario can be previewed using the `view` command:

```
$ packse view scenarios/example.json
example-9e723676
└── a-1.0.0
└── requires b>=1.0.0
└── satisfied by b-1.0.0
└── b-1.0.0
```

### Publishing scenarios

Built scenarios can be published to a Python Package Index.

For example, to upload to the test PyPI:

```bash
twine upload -r testpypi dist/<scenario>/*
```

### Testing scenarios

Published scenarios can then be tested with your choice of package manager.

For example, with `pip`:

```bash
pip install -i https://test.pypi.org/simple/ <scenario>-<package>==1.0.0
```

### Writing new scenarios

**Not yet written**
1,146 changes: 1,146 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[project]
name = "packse"
version = "0.0.0"
dependencies = []
authors = [
{ name = "Zanie", email = "contact@zanie.dev" },
]
description = ''
readme = "README.md"
requires-python = ">=3.12"
license = "MIT"
keywords = []

[tool.poetry]
name = "packse"
version = "0.0.0"
description = ""
authors = ["Zanie <contact@zanie.dev>"]
license = "MIT"
readme = "README.md"

[tool.poetry.scripts]
packse = "packse.cli:entrypoint"

[tool.poetry.dependencies]
python = "^3.12"
msgspec = "^0.18.4"
hatch = "^1.7.0"
twine = "^4.0.2"

[tool.poetry.group.dev.dependencies]
syrupy = "^4.6.0"
pytest = "^7.4.3"
ruff = "^0.1.7"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff.lint]
extend-select = ["I", "W292"]
preview = true
exclude = ["src/packse/templates/**/*", "build/**/*", "dist/**/*"]
24 changes: 24 additions & 0 deletions scenarios/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "example",
"root": "a",
"packages": {
"a": {
"versions": {
"1.0.0": {
"requires_python": ">=3.7",
"requires": [
"b>=1.0.0"
]
}
}
},
"b": {
"versions": {
"1.0.0": {
"requires_python": ">=3.7",
"requires": []
}
}
}
}
}
9 changes: 9 additions & 0 deletions src/packse/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pathlib

# The absolute path to this module
__module_path__ = pathlib.Path(__file__).parent

# The absolute path to the root of the repository, only valid for use during development
__development_base_path__ = __module_path__.parents[1]

del pathlib
8 changes: 8 additions & 0 deletions src/packse/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Enables usage with `python -m packse`
"""

import packse.cli

if __name__ == "__main__":
packse.cli.entrypoint()
Loading

0 comments on commit 3d20a43

Please sign in to comment.