-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
2,595 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
__pycache__ | ||
.cache | ||
*.pyc | ||
.envrc | ||
build/**/* | ||
dist/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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** |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/**/*"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [] | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.