forked from python-poetry/poetry-plugin-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 70f4564
Showing
18 changed files
with
2,830 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,78 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: tests-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
jobs: | ||
tests: | ||
name: ${{ matrix.os }} / ${{ matrix.python-version }} ${{ matrix.suffix }} | ||
runs-on: ${{ matrix.image }} | ||
strategy: | ||
matrix: | ||
os: [Ubuntu, macOS, Windows] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
include: | ||
- os: Ubuntu | ||
image: ubuntu-latest | ||
- os: Windows | ||
image: windows-2022 | ||
- os: macOS | ||
image: macos-14 | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
allow-prereleases: true | ||
|
||
- name: Get full Python version | ||
id: full-python-version | ||
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT | ||
|
||
- name: Bootstrap poetry | ||
run: | | ||
curl -sL https://install.python-poetry.org | python - -y ${{ matrix.bootstrap-args }} | ||
- name: Update PATH | ||
if: ${{ matrix.os != 'Windows' }} | ||
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
||
- name: Update Path for Windows | ||
if: ${{ matrix.os == 'Windows' }} | ||
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH | ||
|
||
- name: Configure poetry | ||
run: poetry config virtualenvs.in-project true | ||
|
||
- name: Set up cache | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Ensure cache is healthy | ||
if: steps.cache.outputs.cache-hit == 'true' | ||
run: timeout 10s poetry run pip --version || rm -rf .venv | ||
|
||
- name: Install dependencies | ||
run: poetry install --with github-actions | ||
|
||
- name: Run mypy | ||
run: poetry run mypy | ||
|
||
- name: Run pytest | ||
run: poetry run pytest -v |
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,48 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*.*.*' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install Poetry | ||
run: | | ||
curl -sL https://install.python-poetry.org | python - -y ${{ matrix.bootstrap-args }} | ||
- name: Update PATH | ||
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
||
- name: Build project for distribution | ||
run: poetry build | ||
|
||
- name: Check Version | ||
id: check-version | ||
run: | | ||
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \ | ||
|| echo "prerelease=true" >> $GITHUB_OUTPUT | ||
- name: Create Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "dist/*" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: false | ||
prerelease: steps.check-version.outputs.prerelease == 'true' | ||
|
||
- name: Publish to PyPI | ||
env: | ||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | ||
run: poetry publish |
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,19 @@ | ||
*.pyc | ||
|
||
# Packages | ||
/dist/* | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.pytest_cache | ||
|
||
.DS_Store | ||
.idea/* | ||
.python-version | ||
.vscode/* | ||
|
||
/docs/site/* | ||
.mypy_cache | ||
|
||
.venv | ||
/poetry.toml |
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,33 @@ | ||
ci: | ||
autofix_prs: false | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
exclude: tests/repositories/fixtures/pypi.org/metadata/.*\.metadata | ||
- id: end-of-file-fixer | ||
exclude: ^.*\.egg-info/|tests/repositories/fixtures/pypi.org/metadata/.*\.metadata | ||
- id: check-merge-conflict | ||
- id: check-case-conflict | ||
- id: check-json | ||
- id: check-toml | ||
exclude: tests/fixtures/invalid_lock/poetry\.lock | ||
- id: check-yaml | ||
- id: pretty-format-json | ||
args: [--autofix, --no-ensure-ascii, --no-sort-keys] | ||
- id: check-ast | ||
- id: debug-statements | ||
- id: check-docstring-first | ||
|
||
- repo: https://github.com/pre-commit/pre-commit | ||
rev: v3.7.1 | ||
hooks: | ||
- id: validate_manifest | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.5.4 | ||
hooks: | ||
- id: ruff | ||
- id: ruff-format |
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,10 @@ | ||
# Change Log | ||
|
||
## [1.0.0] - 2024-09-29 | ||
|
||
- Initial release | ||
|
||
|
||
|
||
[Unreleased]: https://github.com/python-poetry/poetry-plugin-shell/compare/1.0.0...main | ||
[0.1.0]: https://github.com/python-poetry/poetry-plugin-shell/releases/tag/1.0.0 |
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,20 @@ | ||
Copyright (c) 2022 Sébastien Eustace | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,51 @@ | ||
# Poetry Plugin: Shell | ||
|
||
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/) | ||
|
||
This package is a plugin that runs a subshell with virtual environment activated. | ||
|
||
|
||
This plugin replaces the same feature as the `shell` command previously available in Poetry. | ||
|
||
|
||
## Installation | ||
|
||
The easiest way to install the `shell` plugin is via the `self add` command of Poetry. | ||
|
||
```bash | ||
poetry self add poetry-plugin-shell | ||
``` | ||
|
||
If you used `pipx` to install Poetry you can add the plugin via the `pipx inject` command. | ||
|
||
```bash | ||
pipx inject poetry poetry-plugin-shell | ||
``` | ||
|
||
Otherwise, if you used `pip` to install Poetry you can add the plugin packages via the `pip install` command. | ||
|
||
```bash | ||
pip install poetry-plugin-shell | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
The plugin provides a `shell` command to run a subshell with virtual environment activated. | ||
|
||
```bash | ||
poetry shell | ||
``` | ||
|
||
By default, the current active shell is detected and used. Failing that, | ||
the shell defined via the environment variable `SHELL` (on *nix) or | ||
`COMSPEC` (on Windows) is used. | ||
|
||
If a virtual environment does not exist, it will be created. | ||
|
||
Note that this command starts a new shell and activates the virtual environment. | ||
|
||
As such, `exit` should be used to properly exit the shell and the virtual environment instead of `deactivate`. | ||
|
||
> ![NOTE] | ||
> This plugin internally uses the [Shellingham](https://github.com/sarugaku/shellingham) project to detect current active shell. |
Oops, something went wrong.