Skip to content

Commit

Permalink
2.0.4 - Better editable install handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Aug 4, 2024
1 parent 3a33f44 commit 1f6991b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=vmklib version=2.0.3
repo=vmklib version=2.0.4
if: |
matrix.python-version == '3.12'
&& 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.4
hash=c9f109357706db34fbe6c3c4b3b9d9a2
hash=43e9f25280d496418215c22cd0c49c7f
=====================================
-->

# vmklib ([2.0.3](https://pypi.org/project/vmklib/))
# vmklib ([2.0.4](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/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 2
minor: 0
patch: 3
patch: 4
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 = "2.0.3"
version = "2.0.4"
description = "Simplify project workflows by standardizing use of GNU Make."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
6 changes: 2 additions & 4 deletions tests/test_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ def test_entry_python_tasks():
"python-test-add",
"dz-sync",
]
fails = ["python-deps", "python-editable"]
fails = ["python-deps", "python-editable", f"python-install-{PKG_NAME}"]

with target_tests(
"python-tasks", passes, fails, {"python-deps", "python-editable"}
) as test_dir:
with target_tests("python-tasks", passes, fails, set(fails)) as test_dir:
for _ in range(2):
assert mk_main([PKG_NAME, "-C", test_dir, "-d", "venv"]) == 0

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.4
# hash=a5d53b6399d66ef76c6e395d072c6018
# hash=54451b981a0a3faef0b7641dd6877695
# =====================================

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

DESCRIPTION = "Simplify project workflows by standardizing use of GNU Make."
PKG_NAME = "vmklib"
VERSION = "2.0.3"
VERSION = "2.0.4"
3 changes: 2 additions & 1 deletion vmklib/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

# internal
from vmklib import PKG_NAME
from vmklib.util import to_slug

LOG = logging.getLogger(__name__)
DEFAULT_FILE = Path("Makefile")
Expand All @@ -36,7 +37,7 @@ def project(path: Path, name: str = None) -> str:
"""
path = path.resolve()
if name is None:
parent_slug = path.name.replace("-", "_")
parent_slug = to_slug(path.name)
if path.joinpath(parent_slug).is_dir():
name = parent_slug
else:
Expand Down
27 changes: 22 additions & 5 deletions vmklib/tasks/python/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# internal
from vmklib.tasks.mixins.concrete import ConcreteOnceMixin
from vmklib.tasks.python import PREFIX
from vmklib.util import to_slug


class PythonPackage(ConcreteOnceMixin, SubprocessLogMixin):
Expand All @@ -24,11 +25,22 @@ class PythonPackage(ConcreteOnceMixin, SubprocessLogMixin):
async def run(self, inbox: Inbox, outbox: Outbox, *args, **kwargs) -> bool:
"""Create or update a project's virtual environment."""

install_args = [*args]

to_install = kwargs["package"]
project = kwargs.get("project")

# Perform an editable install if we're the install target.
if project and to_slug(project) == to_slug(to_install):
install_args.append("-e")
to_install = "."

Check warning on line 36 in vmklib/tasks/python/package.py

View check run for this annotation

Codecov / codecov/patch

vmklib/tasks/python/package.py#L35-L36

Added lines #L35 - L36 were not covered by tests

install_args.append(to_install)

return await self.exec(
str(inbox["venv"]["venv{python_version}"]["pip"]),
"install",
*args,
kwargs["package"],
*install_args,
)


Expand All @@ -40,19 +52,24 @@ def register(
) -> bool:
"""Register Python package tasks to the manager."""

del project
del cwd
del substitutions

# A target that installs a package.
manager.register(
PythonPackage("python{python_version}-install-{package}"), []
PythonPackage(
"python{python_version}-install-{package}", project=project
),
[],
)

# A target that attempts to upgrade a package.
manager.register(
PythonPackage(
"python{python_version}-upgrade-{package}", "--upgrade", once=False
"python{python_version}-upgrade-{package}",
"--upgrade",
once=False,
project=project,
),
[],
)
Expand Down
8 changes: 8 additions & 0 deletions vmklib/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
An interface exposing miscellaneous utilities.
"""


def to_slug(data: str) -> str:
"""Convert a string to an import slug."""
return data.replace("-", "_")

0 comments on commit 1f6991b

Please sign in to comment.