Metadata-Version: 2.4
Name: package-scripts
Version: 0.3.0
Summary: Scripts for frequently performed Python development tasks.
Author-email: Cam Ratchford <camratchford@gmail.com>
Project-URL: Homepage, https://github.com/camratchford/package-scripts
Project-URL: Source, https://github.com/camratchford/package-scripts
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer
Requires-Dist: ruff
Requires-Dist: isort
Requires-Dist: pytest
Requires-Dist: build
Requires-Dist: setuptools
Requires-Dist: packaging
Requires-Dist: twine
Dynamic: license-file

# Package Scripts

Scripts for frequently performed Python development tasks.

- build - Build and (optionally) publish a package to PyPI
- create-service - Generate and install a systemd unit file with the provided parameters
- format - Run isort, ruff format, and ruff check.
- bump-version - Update pyproject.toml with a new version, create git tag, push upstream

---
* [Installing](#installing)
   * [Create Virtual Environment](#create-virtual-environment)
   * [Set File Prefix](#set-file-prefix)
   * [Install PyPI Package](#install-pypi-package)
   * [Ensure Scripts are in PATH](#ensure-scripts-are-in-path)
   * [Install Shell Completion](#install-shell-completion)
---

## Installing

### Create Virtual Environment

> [!NOTE]
> Use whichever kind env you please, just make sure to use one to avoid clobbering your system pacakges.
```bash
mkdir -p ~/.local/opt/package-scripts
python3 -m venv ~/.local/opt/package-scripts
source ~/.local/opt/package-scripts/bin/activate
```

### Set File Prefix

- File prefixes should match the regex pattern `[\w-]+`.
- With a prefix of 'run', the resulting files will be: `run-build`, `run-format`, `run-bump-version`, `run-create-service`.

```shell
export SCRIPT_PREFIX="run"
```

### Install PyPI Package
```shell
 PACKAGE_SCRIPT_PREFIX="${SCRIPT_PREFIX:-run}" pip install --no-cache-dir package-scripts
```

### Ensure Scripts are in `PATH`

Do one of the following:
- Option 1 - Symlink the scripts from the virtual environment to any location already in `PATH`
```shell
for script in build format bump-version create-service; do
  ln -s "$HOME/.local/opt/package-scripts/bin/${PACKAGE_SCRIPT_PREFIX}-${script}" "$HOME/.local/bin/${PACKAGE_SCRIPT_PREFIX}-${script}"
done 
```

- Option 2 - Copy the generated script files to a location in `PATH`
```shell
cp "$HOME/.local/opt/package-scripts/bin/${PACKAGE_SCRIPT_PREFIX}-"* "$HOME/.local/bin/"
```

- Option 3 - Add the virtual environment's bin directory to `PATH`. This has the side effect of including every other executable file in that directory to the search path, so be warned.
```shell
# Append to PATH rather than prepend so that the executables we add will be used only if they don't exist elsewere.
echo "export PATH=$PATH:$HOME/.local/opt/package-scripts/bin" >> ~/.bashrc
```

### Install Shell Completion

This will generate a file in the local shell completion directory 

```shell
for script in build format bump-version create-service; do
  ${PACKAGE_SCRIPT_PREFIX}-${script} --install-completion
done
```

> [!TIP]
> If you want to place the completion scripts elsewhere, you can redirect the output of `${PACKAGE_SCRIPT_PREFIX}-${script} --show-completion`
> to your desired location instead of using `--install-completion`.





