Skip to content

Commit

Permalink
1.10.2 - Remove some vcorelib methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Jul 22, 2023
1 parent d6de130 commit e7b505a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=vmklib version=1.10.1
repo=vmklib version=1.10.2
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.2
hash=0c42310385e6f37f284556e25b419929
hash=c81b547f706d9871faa71c1694b4c9a0
=====================================
-->

# vmklib ([1.10.1](https://pypi.org/project/vmklib/))
# vmklib ([1.10.2](https://pypi.org/project/vmklib/))

[![python](https://img.shields.io/pypi/pyversions/vmklib.svg)](https://pypi.org/project/vmklib/)
![Build Status](https://github.com/vkottler/vmklib/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/configs/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "Simplify project workflows by standardizing use of GNU Make."
entry: {{entry}}

requirements:
- vcorelib>=2.3.1
- vcorelib>=2.4.0

dev_requirements:
- pytest-asyncio
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 1
minor: 10
patch: 1
patch: 2
entry: mk
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "vmklib"
version = "1.10.1"
version = "1.10.2"
description = "Simplify project workflows by standardizing use of GNU Make."
readme = "README.md"
requires-python = ">=3.8"
Expand Down
4 changes: 2 additions & 2 deletions vmklib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.2
# hash=089d813c9238c490a893adefbd7ad945
# hash=968ffb78bb91f14f331f14edd76f9321
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "Simplify project workflows by standardizing use of GNU Make."
PKG_NAME = "vmklib"
VERSION = "1.10.1"
VERSION = "1.10.2"
2 changes: 1 addition & 1 deletion vmklib/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vcorelib>=2.3.1
vcorelib>=2.4.0
73 changes: 15 additions & 58 deletions vmklib/tasks/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,21 @@
Utilities for working with Python.
"""

# built-in
from os import environ
from pathlib import Path
from shutil import which
from sys import executable, version_info

# third-party
from vcorelib.task.subprocess.run import is_windows
from vcorelib.python import (
python_entry,
python_version,
venv_bin,
venv_dir,
venv_name,
)

PREFIX = "python-"


def python_version() -> str:
"""Get the version of Python to use."""
return environ.get(
"PYTHON_VERSION", f"{version_info[0]}.{version_info[1]}"
)


def python_entry(version: str) -> str:
"""Attempt to get a Python entry-point as a string."""

result = None

options = [f"python{version}{'.exe' if is_windows() else ''}"]

# Use the current executable as a candidate if it's the right version.
if version.startswith(f"{version_info[0]}.{version_info[1]}"):
result = str(executable)
options.append(result)

for option in options:
if which(option) is not None:
result = option
break

assert result is not None, f"Couldn't find 'python{version}'!"
return result


def venv_name(version: str = None) -> str:
"""Get the name for a virtual environment to use."""
if version is None:
version = python_version()
return f"venv{version}"


def venv_dir(cwd: Path, version: str = None) -> Path:
"""Get the path for a virtual environment to use."""
return cwd.joinpath(venv_name(version))


def venv_bin(cwd: Path, program: str = None, version: str = None) -> Path:
"""Get the path to a virtual environment's script directory."""

path = venv_dir(cwd, version).joinpath(
"Scripts" if is_windows() else "bin"
)
if program is not None:
path = path.joinpath(f"{program}{'.exe' if is_windows() else ''}")
return path
__all__ = [
"PREFIX",
"python_version",
"python_entry",
"venv_name",
"venv_dir",
"venv_bin",
]

0 comments on commit e7b505a

Please sign in to comment.