Browse Source

Adding support for installing and running from pip

pull/2/head
Ryan Reed 2 years ago
parent
commit
7892f50568
5 changed files with 30 additions and 23 deletions
  1. +7
    -1
      README.md
  2. +0
    -15
      config.py
  3. +5
    -2
      pyproject.toml
  4. +1
    -1
      tests/test_project.py
  5. +17
    -4
      transpose/console.py

+ 7
- 1
README.md View File

@ -14,7 +14,13 @@ This is the current result, although it still needs a lot of work as I'm sure I'
## Installation
TODO
Can be installed via pip. For instance, from within a virtualenv:
```
python -m venv .venv
. .venv/bin/activate
pip install .
```
## Configuration


+ 0
- 15
config.py View File

@ -1,15 +0,0 @@
from os import environ
from pydantic import BaseSettings
default_xdg_path = environ.get("XDG_DATA_HOME", f"{environ['HOME']}/.local/share")
class Config(BaseSettings):
store_path: str = f"{default_xdg_path}/transpose"
cache_filename: str = ".transpose.json"
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
env_nested_delimiter = "__"
env_prefix = "TRANSPOSE_"

+ 5
- 2
pyproject.toml View File

@ -6,15 +6,18 @@ authors = ["Ryan Reed"]
[tool.poetry.dependencies]
python = "^3.7"
pydantic = "*"
python-dotenv = "*"
[tool.poetry.dev-dependencies]
black = "==22.6"
flake8 = "==3.8.4"
pre-commit = "*"
pydantic = "*"
pytest = "*"
pytest-sugar = "*"
python-dotenv = "*"
[tool.poetry.scripts]
transpose = "transpose.console:entry_point"
[build-system]
requires = ["poetry>=0.12"]


+ 1
- 1
tests/test_project.py View File

@ -6,8 +6,8 @@ from pathlib import Path, PurePath
from contextlib import contextmanager
from tempfile import TemporaryDirectory
from config import Config
from transpose import Transpose, version
from transpose.console import Config
from transpose.utils import check_path, create_cache, get_cache, move, remove, symlink


main.py → transpose/console.py View File

@ -1,13 +1,26 @@
import argparse
import os
from config import Config
from pydantic import BaseSettings
from transpose import Transpose, version
config = Config()
default_xdg_path = os.environ.get("XDG_DATA_HOME", f"{os.environ['HOME']}/.local/share")
class Config(BaseSettings):
store_path: str = f"{default_xdg_path}/transpose"
cache_filename: str = ".transpose.json"
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
env_nested_delimiter = "__"
env_prefix = "TRANSPOSE_"
def main() -> None:
def entry_point() -> None:
config = Config()
args = parse_arguments()
t = Transpose(
@ -62,4 +75,4 @@ def parse_arguments():
if __name__ == "__main__":
main()
entry_point()

Loading…
Cancel
Save