apdev 0.2.2__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {apdev-0.2.2 → apdev-0.2.5}/PKG-INFO +9 -7
  2. {apdev-0.2.2 → apdev-0.2.5}/README.md +3 -1
  3. {apdev-0.2.2 → apdev-0.2.5}/pyproject.toml +6 -6
  4. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/__init__.py +1 -1
  5. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/cli.py +13 -1
  6. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/release.sh +45 -9
  7. {apdev-0.2.2 → apdev-0.2.5}/src/apdev.egg-info/PKG-INFO +9 -7
  8. {apdev-0.2.2 → apdev-0.2.5}/tests/test_cli.py +47 -0
  9. {apdev-0.2.2 → apdev-0.2.5}/setup.cfg +0 -0
  10. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/__main__.py +0 -0
  11. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/charsets/base.json +0 -0
  12. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/charsets/chinese.json +0 -0
  13. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/charsets/japanese.json +0 -0
  14. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/charsets/korean.json +0 -0
  15. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/check_chars.py +0 -0
  16. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/check_imports.py +0 -0
  17. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/config.py +0 -0
  18. {apdev-0.2.2 → apdev-0.2.5}/src/apdev/py.typed +0 -0
  19. {apdev-0.2.2 → apdev-0.2.5}/src/apdev.egg-info/SOURCES.txt +0 -0
  20. {apdev-0.2.2 → apdev-0.2.5}/src/apdev.egg-info/dependency_links.txt +0 -0
  21. {apdev-0.2.2 → apdev-0.2.5}/src/apdev.egg-info/entry_points.txt +0 -0
  22. {apdev-0.2.2 → apdev-0.2.5}/src/apdev.egg-info/requires.txt +0 -0
  23. {apdev-0.2.2 → apdev-0.2.5}/src/apdev.egg-info/top_level.txt +0 -0
  24. {apdev-0.2.2 → apdev-0.2.5}/tests/test_check_chars.py +0 -0
  25. {apdev-0.2.2 → apdev-0.2.5}/tests/test_check_imports.py +0 -0
  26. {apdev-0.2.2 → apdev-0.2.5}/tests/test_config.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apdev
3
- Version: 0.2.2
3
+ Version: 0.2.5
4
4
  Summary: Shared development tools for Python projects - character validation, circular import detection, and more
5
- Author-email: aipartnerup <tercel.yi@gmail.com>
5
+ Author-email: aiperceivable <tercel.yi@gmail.com>
6
6
  License: Apache-2.0
7
- Project-URL: Homepage, https://aipartnerup.com
8
- Project-URL: Documentation, https://github.com/aipartnerup/apdev
9
- Project-URL: Repository, https://github.com/aipartnerup/apdev
10
- Project-URL: Issues, https://github.com/aipartnerup/apdev/issues
7
+ Project-URL: Homepage, https://aiperceivable.com
8
+ Project-URL: Documentation, https://github.com/aiperceivable/apdev
9
+ Project-URL: Repository, https://github.com/aiperceivable/apdev
10
+ Project-URL: Issues, https://github.com/aiperceivable/apdev/issues
11
11
  Keywords: development-tools,quality-assurance,linting,static-analysis,character-validation,circular-imports,release-automation,unicode-checker,trojan-source-detection
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Developers
@@ -86,6 +86,8 @@ apdev check-imports
86
86
 
87
87
  Interactive release automation for publishing Python packages to PyPI and GitHub. Auto-detects project name from `pyproject.toml` and GitHub repo from git remote.
88
88
 
89
+ From the project root, `apdev release` uses the project's `.venv` automatically when no virtual environment is active. Install `build`, `pip`, and `twine` in the environment used for release.
90
+
89
91
  ```bash
90
92
  # Run with auto-detected version from pyproject.toml
91
93
  apdev release
@@ -131,7 +133,7 @@ apdev check-imports # Reads base_package / src_dir from pyproject.toml
131
133
 
132
134
  ```yaml
133
135
  repos:
134
- - repo: https://github.com/aipartnerup/apdev
136
+ - repo: https://github.com/aiperceivable/apdev
135
137
  rev: python/v0.1.0
136
138
  hooks:
137
139
  - id: check-chars
@@ -56,6 +56,8 @@ apdev check-imports
56
56
 
57
57
  Interactive release automation for publishing Python packages to PyPI and GitHub. Auto-detects project name from `pyproject.toml` and GitHub repo from git remote.
58
58
 
59
+ From the project root, `apdev release` uses the project's `.venv` automatically when no virtual environment is active. Install `build`, `pip`, and `twine` in the environment used for release.
60
+
59
61
  ```bash
60
62
  # Run with auto-detected version from pyproject.toml
61
63
  apdev release
@@ -101,7 +103,7 @@ apdev check-imports # Reads base_package / src_dir from pyproject.toml
101
103
 
102
104
  ```yaml
103
105
  repos:
104
- - repo: https://github.com/aipartnerup/apdev
106
+ - repo: https://github.com/aiperceivable/apdev
105
107
  rev: python/v0.1.0
106
108
  hooks:
107
109
  - id: check-chars
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "apdev"
7
- version = "0.2.2"
7
+ version = "0.2.5"
8
8
  description = "Shared development tools for Python projects - character validation, circular import detection, and more"
9
9
  readme = "README.md"
10
10
  license = {text = "Apache-2.0"}
11
11
  requires-python = ">=3.10"
12
12
  authors = [
13
- {name = "aipartnerup", email = "tercel.yi@gmail.com"}
13
+ {name = "aiperceivable", email = "tercel.yi@gmail.com"}
14
14
  ]
15
15
  keywords = [
16
16
  "development-tools",
@@ -67,7 +67,7 @@ line-length = 100
67
67
  select = ["E", "F", "I", "W"]
68
68
 
69
69
  [project.urls]
70
- Homepage = "https://aipartnerup.com"
71
- Documentation = "https://github.com/aipartnerup/apdev"
72
- Repository = "https://github.com/aipartnerup/apdev"
73
- Issues = "https://github.com/aipartnerup/apdev/issues"
70
+ Homepage = "https://aiperceivable.com"
71
+ Documentation = "https://github.com/aiperceivable/apdev"
72
+ Repository = "https://github.com/aiperceivable/apdev"
73
+ Issues = "https://github.com/aiperceivable/apdev/issues"
@@ -1,3 +1,3 @@
1
1
  """apdev - Shared development tools for Python projects."""
2
2
 
3
- __version__ = "0.2.2"
3
+ __version__ = "0.2.5"
@@ -150,7 +150,19 @@ def main(argv: list[str] | None = None) -> int:
150
150
  cmd.append("--yes")
151
151
  if args.version:
152
152
  cmd.append(args.version)
153
- result = subprocess.run(cmd, env={**os.environ})
153
+ release_env = os.environ.copy()
154
+ project_venv = Path.cwd() / ".venv"
155
+ venv_bin = project_venv / "bin"
156
+ if (
157
+ not release_env.get("VIRTUAL_ENV")
158
+ and (project_venv / "pyvenv.cfg").is_file()
159
+ and os.access(venv_bin / "python", os.X_OK)
160
+ ):
161
+ release_env["VIRTUAL_ENV"] = str(project_venv)
162
+ release_env["PATH"] = os.pathsep.join(
163
+ (str(venv_bin), release_env.get("PATH") or os.defpath)
164
+ )
165
+ result = subprocess.run(cmd, env=release_env)
154
166
  return result.returncode
155
167
 
156
168
  return 0
@@ -203,22 +203,58 @@ step1_version_verification() {
203
203
  echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
204
204
 
205
205
  PYPROJECT_VERSION=$(grep -E '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
206
- # Support both static (__version__ = "x.x.x") and dynamic (importlib.metadata) version patterns
207
- INIT_VERSION=$(python3 -c "from ${PACKAGE_NAME} import __version__; print(__version__)" 2>/dev/null)
208
- if [ -z "$INIT_VERSION" ]; then
209
- INIT_VERSION=$(grep -E '^__version__ = ' src/${PACKAGE_NAME}/__init__.py | sed 's/__version__ = "\(.*\)"/\1/')
206
+
207
+ # Locate __init__.py (src layout or flat layout)
208
+ INIT_FILE=""
209
+ if [ -f "src/${PACKAGE_NAME}/__init__.py" ]; then
210
+ INIT_FILE="src/${PACKAGE_NAME}/__init__.py"
211
+ SRC_ROOT="src"
212
+ elif [ -f "${PACKAGE_NAME}/__init__.py" ]; then
213
+ INIT_FILE="${PACKAGE_NAME}/__init__.py"
214
+ SRC_ROOT="."
215
+ fi
216
+
217
+ INIT_VERSION=""
218
+ INIT_DYNAMIC=false
219
+ if [ -n "$INIT_FILE" ]; then
220
+ # 1) Try dynamic import with local source on PYTHONPATH
221
+ INIT_VERSION=$(PYTHONPATH="${SRC_ROOT}:${PYTHONPATH:-}" python3 -c "from ${PACKAGE_NAME} import __version__; print(__version__)" 2>/dev/null)
222
+ # 2) Fallback: grep static __version__ = "x.x.x"
223
+ if [ -z "$INIT_VERSION" ]; then
224
+ INIT_VERSION=$(grep -E '^__version__ = ' "$INIT_FILE" 2>/dev/null | sed 's/__version__ = "\(.*\)"/\1/')
225
+ fi
226
+ # 3) If still empty, check if __init__.py uses dynamic versioning (importlib.metadata)
227
+ if [ -z "$INIT_VERSION" ]; then
228
+ if grep -qE 'importlib\.metadata|from importlib' "$INIT_FILE" 2>/dev/null; then
229
+ INIT_VERSION="$PYPROJECT_VERSION"
230
+ INIT_DYNAMIC=true
231
+ fi
232
+ fi
210
233
  fi
211
234
 
212
235
  echo -e " pyproject.toml: ${CYAN}${PYPROJECT_VERSION}${NC}"
213
- echo -e " __init__.py: ${CYAN}${INIT_VERSION}${NC}"
236
+ if [ -z "$INIT_FILE" ]; then
237
+ echo -e " __init__.py: ${YELLOW}(not found, skipped)${NC}"
238
+ elif [ "$INIT_DYNAMIC" = true ]; then
239
+ echo -e " __init__.py: ${CYAN}${INIT_VERSION}${NC} (dynamic, from pyproject.toml)"
240
+ elif [ -n "$INIT_VERSION" ]; then
241
+ echo -e " __init__.py: ${CYAN}${INIT_VERSION}${NC}"
242
+ else
243
+ echo -e " __init__.py: ${YELLOW}(no __version__ defined, skipped)${NC}"
244
+ fi
214
245
  echo -e " Script version: ${CYAN}${VERSION}${NC}"
215
-
216
- if [ "$PYPROJECT_VERSION" != "$VERSION" ] || [ "$INIT_VERSION" != "$VERSION" ]; then
217
- echo -e "${RED}❌ Version mismatch detected!${NC}"
246
+
247
+ if [ "$PYPROJECT_VERSION" != "$VERSION" ]; then
248
+ echo -e "${RED}❌ Version mismatch: pyproject.toml (${PYPROJECT_VERSION}) != script (${VERSION})${NC}"
249
+ return 1
250
+ fi
251
+
252
+ if [ -n "$INIT_VERSION" ] && [ "$INIT_VERSION" != "$VERSION" ]; then
253
+ echo -e "${RED}❌ Version mismatch: __init__.py (${INIT_VERSION}) != script (${VERSION})${NC}"
218
254
  echo -e "${YELLOW}💡 Hint: Try 'pip install -e .' to sync the installed package version${NC}"
219
255
  return 1
220
256
  fi
221
-
257
+
222
258
  echo -e "${GREEN}✅ All versions match${NC}"
223
259
  echo ""
224
260
  return 0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apdev
3
- Version: 0.2.2
3
+ Version: 0.2.5
4
4
  Summary: Shared development tools for Python projects - character validation, circular import detection, and more
5
- Author-email: aipartnerup <tercel.yi@gmail.com>
5
+ Author-email: aiperceivable <tercel.yi@gmail.com>
6
6
  License: Apache-2.0
7
- Project-URL: Homepage, https://aipartnerup.com
8
- Project-URL: Documentation, https://github.com/aipartnerup/apdev
9
- Project-URL: Repository, https://github.com/aipartnerup/apdev
10
- Project-URL: Issues, https://github.com/aipartnerup/apdev/issues
7
+ Project-URL: Homepage, https://aiperceivable.com
8
+ Project-URL: Documentation, https://github.com/aiperceivable/apdev
9
+ Project-URL: Repository, https://github.com/aiperceivable/apdev
10
+ Project-URL: Issues, https://github.com/aiperceivable/apdev/issues
11
11
  Keywords: development-tools,quality-assurance,linting,static-analysis,character-validation,circular-imports,release-automation,unicode-checker,trojan-source-detection
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Intended Audience :: Developers
@@ -86,6 +86,8 @@ apdev check-imports
86
86
 
87
87
  Interactive release automation for publishing Python packages to PyPI and GitHub. Auto-detects project name from `pyproject.toml` and GitHub repo from git remote.
88
88
 
89
+ From the project root, `apdev release` uses the project's `.venv` automatically when no virtual environment is active. Install `build`, `pip`, and `twine` in the environment used for release.
90
+
89
91
  ```bash
90
92
  # Run with auto-detected version from pyproject.toml
91
93
  apdev release
@@ -131,7 +133,7 @@ apdev check-imports # Reads base_package / src_dir from pyproject.toml
131
133
 
132
134
  ```yaml
133
135
  repos:
134
- - repo: https://github.com/aipartnerup/apdev
136
+ - repo: https://github.com/aiperceivable/apdev
135
137
  rev: python/v0.1.0
136
138
  hooks:
137
139
  - id: check-chars
@@ -5,6 +5,11 @@ import subprocess
5
5
  import sys
6
6
  import textwrap
7
7
  from pathlib import Path
8
+ from unittest.mock import Mock
9
+
10
+ import pytest
11
+
12
+ from apdev import cli
8
13
 
9
14
 
10
15
  def run_apdev(*args: str, cwd: str | Path | None = None) -> subprocess.CompletedProcess[str]:
@@ -26,6 +31,48 @@ def test_cli_help() -> None:
26
31
  assert "release" in result.stdout
27
32
 
28
33
 
34
+ @pytest.mark.parametrize(
35
+ ("local_venv", "active_venv"), [(True, False), (True, True), (False, False)]
36
+ )
37
+ def test_cli_release_selects_project_virtualenv(
38
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, local_venv: bool, active_venv: bool
39
+ ) -> None:
40
+ monkeypatch.chdir(tmp_path)
41
+ project_venv = Path.cwd() / ".venv"
42
+ if local_venv:
43
+ (project_venv / "bin").mkdir(parents=True)
44
+ (project_venv / "pyvenv.cfg").touch()
45
+ python = project_venv / "bin" / "python"
46
+ python.touch()
47
+ python.chmod(0o755)
48
+ original_path = os.defpath
49
+ if active_venv:
50
+ active_path = str(tmp_path / "active")
51
+ monkeypatch.setenv("VIRTUAL_ENV", active_path)
52
+ original_path = os.pathsep.join((str(Path(active_path) / "bin"), original_path))
53
+ else:
54
+ monkeypatch.delenv("VIRTUAL_ENV", raising=False)
55
+ monkeypatch.setenv("PATH", original_path)
56
+ run = Mock(return_value=subprocess.CompletedProcess(args=[], returncode=0))
57
+ monkeypatch.setattr(cli.subprocess, "run", run)
58
+
59
+ assert cli.main(["release", "--yes", "0.1.0"]) == 0
60
+
61
+ run.assert_called_once()
62
+ args = run.call_args.args[0]
63
+ assert args[0] == "bash"
64
+ assert args[2:] == ["--yes", "0.1.0"]
65
+ env = run.call_args.kwargs["env"]
66
+ if local_venv and not active_venv:
67
+ assert env["PATH"] == os.pathsep.join((str(project_venv / "bin"), original_path))
68
+ assert env["VIRTUAL_ENV"] == str(project_venv)
69
+ assert "VIRTUAL_ENV" not in os.environ
70
+ else:
71
+ assert env["PATH"] == original_path
72
+ assert env.get("VIRTUAL_ENV") == os.environ.get("VIRTUAL_ENV")
73
+ assert os.environ["PATH"] == original_path
74
+
75
+
29
76
  def test_cli_check_chars_clean(tmp_path: Path) -> None:
30
77
  """apdev check-chars returns 0 for clean files."""
31
78
  f = tmp_path / "ok.py"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes