apdev 0.2.5__tar.gz → 0.2.6__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.5 → apdev-0.2.6}/PKG-INFO +38 -5
  2. {apdev-0.2.5 → apdev-0.2.6}/README.md +37 -4
  3. {apdev-0.2.5 → apdev-0.2.6}/pyproject.toml +1 -1
  4. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/__init__.py +1 -1
  5. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/cli.py +12 -0
  6. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/release.sh +41 -7
  7. {apdev-0.2.5 → apdev-0.2.6}/src/apdev.egg-info/PKG-INFO +38 -5
  8. {apdev-0.2.5 → apdev-0.2.6}/tests/test_cli.py +67 -1
  9. {apdev-0.2.5 → apdev-0.2.6}/setup.cfg +0 -0
  10. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/__main__.py +0 -0
  11. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/charsets/base.json +0 -0
  12. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/charsets/chinese.json +0 -0
  13. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/charsets/japanese.json +0 -0
  14. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/charsets/korean.json +0 -0
  15. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/check_chars.py +0 -0
  16. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/check_imports.py +0 -0
  17. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/config.py +0 -0
  18. {apdev-0.2.5 → apdev-0.2.6}/src/apdev/py.typed +0 -0
  19. {apdev-0.2.5 → apdev-0.2.6}/src/apdev.egg-info/SOURCES.txt +0 -0
  20. {apdev-0.2.5 → apdev-0.2.6}/src/apdev.egg-info/dependency_links.txt +0 -0
  21. {apdev-0.2.5 → apdev-0.2.6}/src/apdev.egg-info/entry_points.txt +0 -0
  22. {apdev-0.2.5 → apdev-0.2.6}/src/apdev.egg-info/requires.txt +0 -0
  23. {apdev-0.2.5 → apdev-0.2.6}/src/apdev.egg-info/top_level.txt +0 -0
  24. {apdev-0.2.5 → apdev-0.2.6}/tests/test_check_chars.py +0 -0
  25. {apdev-0.2.5 → apdev-0.2.6}/tests/test_check_imports.py +0 -0
  26. {apdev-0.2.5 → apdev-0.2.6}/tests/test_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apdev
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: Shared development tools for Python projects - character validation, circular import detection, and more
5
5
  Author-email: aiperceivable <tercel.yi@gmail.com>
6
6
  License: Apache-2.0
@@ -94,6 +94,10 @@ apdev release
94
94
 
95
95
  # Or specify version explicitly
96
96
  apdev release 0.2.0
97
+
98
+ # Upload to a named .pypirc section (default: [tool.apdev] pypi_repository, or "pypi")
99
+ apdev release --repository reachreel
100
+ apdev release -r testpypi 0.3.0
97
101
  ```
98
102
 
99
103
  The command provides an interactive menu with steps:
@@ -104,7 +108,34 @@ The command provides an interactive menu with steps:
104
108
  5. Check package (`twine check`)
105
109
  6. Create git tag and push
106
110
  7. Create GitHub release (via `gh` CLI or API)
107
- 8. Upload to PyPI (`twine upload`)
111
+ 8. Upload to PyPI (`twine upload -r <repository> dist/*`)
112
+
113
+ Which `~/.pypirc` section is used, in order of precedence:
114
+
115
+ 1. `--repository NAME` / `-r NAME`
116
+ 2. `PYPI_REPOSITORY` environment variable
117
+ 3. `[tool.apdev] pypi_repository` in `pyproject.toml`
118
+ 4. the default `[pypi]` section
119
+
120
+ The resolved section is printed in the header before anything is uploaded, so a
121
+ second PyPI account is never a guess:
122
+
123
+ ```ini
124
+ # ~/.pypirc
125
+ [distutils]
126
+ index-servers =
127
+ pypi
128
+ reachreel
129
+
130
+ [pypi]
131
+ username = __token__
132
+ password = pypi-A... # account A
133
+
134
+ [reachreel]
135
+ repository = https://upload.pypi.org/legacy/
136
+ username = __token__
137
+ password = pypi-B... # account B
138
+ ```
108
139
 
109
140
  Override auto-detection with environment variables:
110
141
 
@@ -118,15 +149,17 @@ Add to your project's `pyproject.toml` so commands can run without CLI arguments
118
149
 
119
150
  ```toml
120
151
  [tool.apdev]
121
- base_package = "mypackage" # Required by check-imports
122
- src_dir = "src" # Source directory (default: "src")
152
+ base_package = "mypackage" # Required by check-imports
153
+ src_dir = "src" # Source directory (default: "src")
154
+ pypi_repository = "mypackage" # .pypirc section for `apdev release` (default: "pypi")
123
155
  ```
124
156
 
125
- With this config, both commands work out of the box:
157
+ With this config, the commands work out of the box:
126
158
 
127
159
  ```bash
128
160
  apdev check-chars # Checks default project directories and config files
129
161
  apdev check-imports # Reads base_package / src_dir from pyproject.toml
162
+ apdev release # Reads pypi_repository, so the right PyPI account is used
130
163
  ```
131
164
 
132
165
  ## Pre-commit Integration
@@ -64,6 +64,10 @@ apdev release
64
64
 
65
65
  # Or specify version explicitly
66
66
  apdev release 0.2.0
67
+
68
+ # Upload to a named .pypirc section (default: [tool.apdev] pypi_repository, or "pypi")
69
+ apdev release --repository reachreel
70
+ apdev release -r testpypi 0.3.0
67
71
  ```
68
72
 
69
73
  The command provides an interactive menu with steps:
@@ -74,7 +78,34 @@ The command provides an interactive menu with steps:
74
78
  5. Check package (`twine check`)
75
79
  6. Create git tag and push
76
80
  7. Create GitHub release (via `gh` CLI or API)
77
- 8. Upload to PyPI (`twine upload`)
81
+ 8. Upload to PyPI (`twine upload -r <repository> dist/*`)
82
+
83
+ Which `~/.pypirc` section is used, in order of precedence:
84
+
85
+ 1. `--repository NAME` / `-r NAME`
86
+ 2. `PYPI_REPOSITORY` environment variable
87
+ 3. `[tool.apdev] pypi_repository` in `pyproject.toml`
88
+ 4. the default `[pypi]` section
89
+
90
+ The resolved section is printed in the header before anything is uploaded, so a
91
+ second PyPI account is never a guess:
92
+
93
+ ```ini
94
+ # ~/.pypirc
95
+ [distutils]
96
+ index-servers =
97
+ pypi
98
+ reachreel
99
+
100
+ [pypi]
101
+ username = __token__
102
+ password = pypi-A... # account A
103
+
104
+ [reachreel]
105
+ repository = https://upload.pypi.org/legacy/
106
+ username = __token__
107
+ password = pypi-B... # account B
108
+ ```
78
109
 
79
110
  Override auto-detection with environment variables:
80
111
 
@@ -88,15 +119,17 @@ Add to your project's `pyproject.toml` so commands can run without CLI arguments
88
119
 
89
120
  ```toml
90
121
  [tool.apdev]
91
- base_package = "mypackage" # Required by check-imports
92
- src_dir = "src" # Source directory (default: "src")
122
+ base_package = "mypackage" # Required by check-imports
123
+ src_dir = "src" # Source directory (default: "src")
124
+ pypi_repository = "mypackage" # .pypirc section for `apdev release` (default: "pypi")
93
125
  ```
94
126
 
95
- With this config, both commands work out of the box:
127
+ With this config, the commands work out of the box:
96
128
 
97
129
  ```bash
98
130
  apdev check-chars # Checks default project directories and config files
99
131
  apdev check-imports # Reads base_package / src_dir from pyproject.toml
132
+ apdev release # Reads pypi_repository, so the right PyPI account is used
100
133
  ```
101
134
 
102
135
  ## Pre-commit Integration
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "apdev"
7
- version = "0.2.5"
7
+ version = "0.2.6"
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"}
@@ -1,3 +1,3 @@
1
1
  """apdev - Shared development tools for Python projects."""
2
2
 
3
- __version__ = "0.2.5"
3
+ __version__ = "0.2.6"
@@ -85,6 +85,15 @@ def _build_parser() -> argparse.ArgumentParser:
85
85
  action="store_true",
86
86
  help="Auto-accept all defaults (silent mode)",
87
87
  )
88
+ release_parser.add_argument(
89
+ "--repository",
90
+ "-r",
91
+ dest="repository",
92
+ help=(
93
+ "Named .pypirc section to upload to (default: [tool.apdev] "
94
+ "pypi_repository, or 'pypi')"
95
+ ),
96
+ )
88
97
  release_parser.add_argument(
89
98
  "version",
90
99
  nargs="?",
@@ -148,6 +157,9 @@ def main(argv: list[str] | None = None) -> int:
148
157
  cmd = ["bash", str(script)]
149
158
  if args.yes:
150
159
  cmd.append("--yes")
160
+ repository = args.repository or load_config().get("pypi_repository")
161
+ if repository:
162
+ cmd.extend(["--repository", str(repository)])
151
163
  if args.version:
152
164
  cmd.append(args.version)
153
165
  release_env = os.environ.copy()
@@ -6,19 +6,33 @@
6
6
  # ./release.sh --yes 0.2.0 # silent mode with specific version
7
7
  #
8
8
  # Auto-detects project name from pyproject.toml and GitHub repo from git remote.
9
- # Override with environment variables: PROJECT_NAME, PACKAGE_NAME, GITHUB_REPO
9
+ # Override with environment variables: PROJECT_NAME, PACKAGE_NAME, GITHUB_REPO,
10
+ # PYPI_REPOSITORY (named .pypirc section, default "pypi").
10
11
 
11
12
  # Note: set -e is disabled to allow step-by-step execution
12
13
  # Individual steps will handle their own error handling
13
14
 
14
15
  # Silent mode flag (--yes or -y to auto-accept all defaults)
15
16
  SILENT=false
17
+ PYPI_REPOSITORY="${PYPI_REPOSITORY:-}"
16
18
  POSITIONAL_ARGS=()
17
- for arg in "$@"; do
18
- case "$arg" in
19
+ while [ "$#" -gt 0 ]; do
20
+ case "$1" in
19
21
  --yes|-y) SILENT=true ;;
20
- *) POSITIONAL_ARGS+=("$arg") ;;
22
+ --repository|-r)
23
+ if [ "$#" -lt 2 ] || [ -z "$2" ]; then
24
+ echo "Error: --repository needs a .pypirc section name" >&2
25
+ exit 1
26
+ fi
27
+ PYPI_REPOSITORY="$2"
28
+ shift
29
+ ;;
30
+ --repository=*)
31
+ PYPI_REPOSITORY="${1#*=}"
32
+ ;;
33
+ *) POSITIONAL_ARGS+=("$1") ;;
21
34
  esac
35
+ shift
22
36
  done
23
37
  set -- "${POSITIONAL_ARGS[@]}"
24
38
 
@@ -58,6 +72,25 @@ if [ -z "$GITHUB_REPO" ]; then
58
72
  fi
59
73
  fi
60
74
 
75
+ # PyPI repository: --repository, then PYPI_REPOSITORY, then [tool.apdev]
76
+ # pypi_repository, then the default "pypi" section of ~/.pypirc.
77
+ #
78
+ # Parsed with awk instead of tomllib so the script works on any machine, even
79
+ # one whose `python3` is older than 3.11.
80
+ if [ -z "$PYPI_REPOSITORY" ] && [ -f pyproject.toml ]; then
81
+ PYPI_REPOSITORY=$(awk '
82
+ /^[[:space:]]*\[/ {
83
+ in_apdev = ($0 ~ /^[[:space:]]*\[tool\.apdev\][[:space:]]*$/)
84
+ next
85
+ }
86
+ in_apdev && /^[[:space:]]*pypi_repository[[:space:]]*=/ {
87
+ print
88
+ exit
89
+ }
90
+ ' pyproject.toml | sed -E 's/^[^=]*=[[:space:]]*//; s/[[:space:]]+$//; s/^"//; s/"$//; s/^\x27//; s/\x27$//')
91
+ fi
92
+ PYPI_REPOSITORY="${PYPI_REPOSITORY:-pypi}"
93
+
61
94
  # Get version from argument or pyproject.toml
62
95
  if [ -z "$1" ]; then
63
96
  VERSION=$(grep -E '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
@@ -77,6 +110,7 @@ echo -e "${CYAN}║ ${PROJECT_NAME} Release Script v${VERSION}${NC}"
77
110
  echo -e "${CYAN}╚══════════════════════════════════════════════════════════╝${NC}"
78
111
  echo -e " Project: ${CYAN}${PROJECT_NAME}${NC}"
79
112
  [ -n "$GITHUB_REPO" ] && echo -e " GitHub: ${CYAN}${GITHUB_REPO}${NC}"
113
+ echo -e " PyPI: ${CYAN}${PYPI_REPOSITORY}${NC}"
80
114
  echo ""
81
115
 
82
116
  # Function to check if step is already done
@@ -754,15 +788,15 @@ step7_upload_pypi() {
754
788
  fi
755
789
 
756
790
  if ask_yn "Upload to PyPI?" "y"; then
757
- echo -e "${YELLOW}Uploading to PyPI...${NC}"
758
- if ! twine upload dist/*; then
791
+ echo -e "${YELLOW}Uploading to PyPI (${PYPI_REPOSITORY})...${NC}"
792
+ if ! twine upload -r "$PYPI_REPOSITORY" dist/*; then
759
793
  echo -e "${RED}❌ Upload to PyPI failed${NC}"
760
794
  return 1
761
795
  fi
762
796
  echo -e "${GREEN}✅ Successfully uploaded to PyPI!${NC}"
763
797
  else
764
798
  echo -e "${YELLOW}⚠️ Skipped PyPI upload${NC}"
765
- echo -e "${CYAN} Upload manually with: twine upload dist/*${NC}"
799
+ echo -e "${CYAN} Upload manually with: twine upload -r ${PYPI_REPOSITORY} dist/*${NC}"
766
800
  fi
767
801
  else
768
802
  echo -e "${YELLOW}⚠️ Skipped PyPI upload (version already exists)${NC}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apdev
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: Shared development tools for Python projects - character validation, circular import detection, and more
5
5
  Author-email: aiperceivable <tercel.yi@gmail.com>
6
6
  License: Apache-2.0
@@ -94,6 +94,10 @@ apdev release
94
94
 
95
95
  # Or specify version explicitly
96
96
  apdev release 0.2.0
97
+
98
+ # Upload to a named .pypirc section (default: [tool.apdev] pypi_repository, or "pypi")
99
+ apdev release --repository reachreel
100
+ apdev release -r testpypi 0.3.0
97
101
  ```
98
102
 
99
103
  The command provides an interactive menu with steps:
@@ -104,7 +108,34 @@ The command provides an interactive menu with steps:
104
108
  5. Check package (`twine check`)
105
109
  6. Create git tag and push
106
110
  7. Create GitHub release (via `gh` CLI or API)
107
- 8. Upload to PyPI (`twine upload`)
111
+ 8. Upload to PyPI (`twine upload -r <repository> dist/*`)
112
+
113
+ Which `~/.pypirc` section is used, in order of precedence:
114
+
115
+ 1. `--repository NAME` / `-r NAME`
116
+ 2. `PYPI_REPOSITORY` environment variable
117
+ 3. `[tool.apdev] pypi_repository` in `pyproject.toml`
118
+ 4. the default `[pypi]` section
119
+
120
+ The resolved section is printed in the header before anything is uploaded, so a
121
+ second PyPI account is never a guess:
122
+
123
+ ```ini
124
+ # ~/.pypirc
125
+ [distutils]
126
+ index-servers =
127
+ pypi
128
+ reachreel
129
+
130
+ [pypi]
131
+ username = __token__
132
+ password = pypi-A... # account A
133
+
134
+ [reachreel]
135
+ repository = https://upload.pypi.org/legacy/
136
+ username = __token__
137
+ password = pypi-B... # account B
138
+ ```
108
139
 
109
140
  Override auto-detection with environment variables:
110
141
 
@@ -118,15 +149,17 @@ Add to your project's `pyproject.toml` so commands can run without CLI arguments
118
149
 
119
150
  ```toml
120
151
  [tool.apdev]
121
- base_package = "mypackage" # Required by check-imports
122
- src_dir = "src" # Source directory (default: "src")
152
+ base_package = "mypackage" # Required by check-imports
153
+ src_dir = "src" # Source directory (default: "src")
154
+ pypi_repository = "mypackage" # .pypirc section for `apdev release` (default: "pypi")
123
155
  ```
124
156
 
125
- With this config, both commands work out of the box:
157
+ With this config, the commands work out of the box:
126
158
 
127
159
  ```bash
128
160
  apdev check-chars # Checks default project directories and config files
129
161
  apdev check-imports # Reads base_package / src_dir from pyproject.toml
162
+ apdev release # Reads pypi_repository, so the right PyPI account is used
130
163
  ```
131
164
 
132
165
  ## Pre-commit Integration
@@ -70,7 +70,73 @@ def test_cli_release_selects_project_virtualenv(
70
70
  else:
71
71
  assert env["PATH"] == original_path
72
72
  assert env.get("VIRTUAL_ENV") == os.environ.get("VIRTUAL_ENV")
73
- assert os.environ["PATH"] == original_path
73
+
74
+
75
+ def test_cli_release_forwards_repository_flag(
76
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
77
+ ) -> None:
78
+ """--repository is passed through to release.sh before the version."""
79
+ monkeypatch.chdir(tmp_path)
80
+ run = Mock(return_value=subprocess.CompletedProcess(args=[], returncode=0))
81
+ monkeypatch.setattr(cli.subprocess, "run", run)
82
+
83
+ assert cli.main(["release", "--repository", "reachreel", "0.1.0"]) == 0
84
+
85
+ args = run.call_args.args[0]
86
+ assert args[0] == "bash"
87
+ assert args[2:] == ["--repository", "reachreel", "0.1.0"]
88
+
89
+
90
+ def test_cli_release_reads_repository_from_config(
91
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
92
+ ) -> None:
93
+ """[tool.apdev] pypi_repository selects the section without a flag."""
94
+ monkeypatch.chdir(tmp_path)
95
+ Path("pyproject.toml").write_text(
96
+ textwrap.dedent(
97
+ """
98
+ [project]
99
+ name = "demo"
100
+ version = "0.1.0"
101
+
102
+ [tool.apdev]
103
+ pypi_repository = "reachreel"
104
+ """
105
+ ),
106
+ encoding="utf-8",
107
+ )
108
+ run = Mock(return_value=subprocess.CompletedProcess(args=[], returncode=0))
109
+ monkeypatch.setattr(cli.subprocess, "run", run)
110
+
111
+ assert cli.main(["release", "--yes"]) == 0
112
+
113
+ args = run.call_args.args[0]
114
+ assert args[2:] == ["--yes", "--repository", "reachreel"]
115
+
116
+
117
+ def test_cli_release_flag_beats_config(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
118
+ """An explicit --repository wins over [tool.apdev]."""
119
+ monkeypatch.chdir(tmp_path)
120
+ Path("pyproject.toml").write_text(
121
+ textwrap.dedent(
122
+ """
123
+ [project]
124
+ name = "demo"
125
+ version = "0.1.0"
126
+
127
+ [tool.apdev]
128
+ pypi_repository = "reachreel"
129
+ """
130
+ ),
131
+ encoding="utf-8",
132
+ )
133
+ run = Mock(return_value=subprocess.CompletedProcess(args=[], returncode=0))
134
+ monkeypatch.setattr(cli.subprocess, "run", run)
135
+
136
+ assert cli.main(["release", "--repository", "testpypi"]) == 0
137
+
138
+ args = run.call_args.args[0]
139
+ assert args[2:] == ["--repository", "testpypi"]
74
140
 
75
141
 
76
142
  def test_cli_check_chars_clean(tmp_path: Path) -> None:
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