From 8a35ae779b9627f28f80d4ec4f7bf5cf4d9c5a98 Mon Sep 17 00:00:00 2001 From: Tutos Rive <108991712+tutosrive@users.noreply.github.com> Date: Tue, 28 Oct 2025 17:06:21 -0500 Subject: [PATCH 1/4] Change url pypi from main to tests site --- .github/workflows/build-and-publish-wheels.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish-wheels.yml b/.github/workflows/build-and-publish-wheels.yml index 9ff00a0..1df5fad 100644 --- a/.github/workflows/build-and-publish-wheels.yml +++ b/.github/workflows/build-and-publish-wheels.yml @@ -88,7 +88,10 @@ jobs: env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - run: python -m twine upload dist/*.whl + # Prodcution + # run: python -m twine upload dist/*.whl + # Test + run: python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*.whl - name: Upload artifact (wheel) uses: actions/upload-artifact@v4 From 31b4b649739e4557e0eaf7243628d416b278f8be Mon Sep 17 00:00:00 2001 From: Tutos Rive <108991712+tutosrive@users.noreply.github.com> Date: Tue, 28 Oct 2025 17:14:28 -0500 Subject: [PATCH 2/4] Fix .toml version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 13f3b97..df1616b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "initvenv" -version = "0.1.0a7" +version = "0.1.0a8" description = "Test InitVenv package. Currently available as a standalone executable at https://github.com/Dev2Forge/Init-Venv/releases." readme = { file = "README.md", content-type = "text/markdown", charset = "utf-8" } license = "GPL-3.0" From df9184245ba0d0d0e4a1f852942b403ac4b91dd4 Mon Sep 17 00:00:00 2001 From: Tutos Rive <108991712+tutosrive@users.noreply.github.com> Date: Tue, 28 Oct 2025 17:19:43 -0500 Subject: [PATCH 3/4] Update _launcher --- pyproject.toml | 2 +- src/initvenv/_launcher.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index df1616b..fa0ea54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "initvenv" -version = "0.1.0a8" +version = "0.1.0a9" description = "Test InitVenv package. Currently available as a standalone executable at https://github.com/Dev2Forge/Init-Venv/releases." readme = { file = "README.md", content-type = "text/markdown", charset = "utf-8" } license = "GPL-3.0" diff --git a/src/initvenv/_launcher.py b/src/initvenv/_launcher.py index 4c45783..4678997 100644 --- a/src/initvenv/_launcher.py +++ b/src/initvenv/_launcher.py @@ -34,7 +34,7 @@ def main(): if bat.exists(): # On Windows run the .bat through cmd.exe so associations work - cmd = "cmd.exe" # os.environ.get("COMSPEC", "cmd.exe") + cmd = os.environ.get("COMSPEC", "cmd.exe") # "cmd.exe" # os.environ.get("COMSPEC", "cmd.exe") args = [cmd, "/c", str(bat)] + sys.argv[1:] os.execv(cmd, args) From 3cfb99c7286b258e6a4f6897dfdab2208e358efd Mon Sep 17 00:00:00 2001 From: Tutos Rive <108991712+tutosrive@users.noreply.github.com> Date: Tue, 28 Oct 2025 18:02:46 -0500 Subject: [PATCH 4/4] Fix launcher --- pyproject.toml | 2 +- src/initvenv/_launcher.py | 63 ++++++++++++++++++++----------- src/initvenv/scripts/initvenv.bat | 12 +++++- 3 files changed, 52 insertions(+), 25 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fa0ea54..f2f5145 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "initvenv" -version = "0.1.0a9" +version = "0.1.0a10" description = "Test InitVenv package. Currently available as a standalone executable at https://github.com/Dev2Forge/Init-Venv/releases." readme = { file = "README.md", content-type = "text/markdown", charset = "utf-8" } license = "GPL-3.0" diff --git a/src/initvenv/_launcher.py b/src/initvenv/_launcher.py index 4678997..50c1642 100644 --- a/src/initvenv/_launcher.py +++ b/src/initvenv/_launcher.py @@ -2,49 +2,68 @@ import sys import platform from pathlib import Path - +import subprocess def main(): """Launcher entry point that runs the bundled initvenv.bat (or initvenv.exe). - On Windows this will execute the shipped .bat (preferred) or the .exe. - On other platforms it prints a short message with the platform name. + If the user does not pass a path, uses "." as default. """ - system_name = platform.system() - # If not Windows, inform the user and exit gracefully - if not system_name.lower().startswith("win"): - print(f"Próximamente funcionará en esta plataforma {system_name}") + + if not platform.system().lower().startswith("win"): + print(f"Próximamente funcionará en esta plataforma {platform.system()}") + return 0 + + # Prevent recursive re-invocation + if os.environ.get("INITVENV_LAUNCHED") == "1": return 0 - # location of this module -> package root pkg_root = Path(__file__).resolve().parent - # scripts directory inside the package scripts_dir = pkg_root / "scripts" - # prefer the .bat next to the installed script bat = scripts_dir / "initvenv.bat" exe = scripts_dir / "initvenv.exe" - # If not found where expected, try one level up (defensive) if not bat.exists() and not exe.exists(): pkg_root_up = pkg_root.parent scripts_dir = pkg_root_up / "scripts" bat = scripts_dir / "initvenv.bat" - # exe = scripts_dir / "initvenv.exe" + exe = scripts_dir / "initvenv.exe" + + # If no path provided, default to current directory "." + user_args = sys.argv[1:] + if not user_args: + target = "." + else: + target = user_args[0] + + env = os.environ.copy() + env["INITVENV_LAUNCHED"] = "1" + + cmd = os.environ.get("COMSPEC", "cmd.exe") if bat.exists(): - # On Windows run the .bat through cmd.exe so associations work - cmd = os.environ.get("COMSPEC", "cmd.exe") # "cmd.exe" # os.environ.get("COMSPEC", "cmd.exe") - args = [cmd, "/c", str(bat)] + sys.argv[1:] - os.execv(cmd, args) + bat_path = str(bat) + argv = [cmd, "/c", bat_path, target] + try: + subprocess.run(argv, check=True, env=env) + return 0 + except subprocess.CalledProcessError as e: + print(f"Error ejecutando {bat}: {e}", file=sys.stderr) + return e.returncode - # if exe.exists(): - # # Execute the exe directly, replacing the current process - # os.execv(str(exe), [str(exe)] + sys.argv[1:]) + if exe.exists(): + exe_path = str(exe) + argv = [exe_path, target] + try: + subprocess.run(argv, check=True, env=env) + return 0 + except subprocess.CalledProcessError as e: + print(f"Error ejecutando {exe}: {e}", file=sys.stderr) + return e.returncode print("Error: neither initvenv.bat nor initvenv.exe were found in package scripts/", file=sys.stderr) return 2 - -if __name__ == '__main__': - sys.exit(main()) +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file diff --git a/src/initvenv/scripts/initvenv.bat b/src/initvenv/scripts/initvenv.bat index 2233316..bf93e38 100644 --- a/src/initvenv/scripts/initvenv.bat +++ b/src/initvenv/scripts/initvenv.bat @@ -1,3 +1,11 @@ @echo off -start "" "initvenv.exe" "%CD%" -exit \ No newline at end of file +if "%~1"=="" ( + set "target=%CD%" +) else ( + set "target=%~1" +) + +setlocal +"%~dp0initvenv.exe" "%target%" +endlocal +exit /b %ERRORLEVEL% \ No newline at end of file