Skip to content

Commit 459f9f1

Browse files
committed
Upgrades to linux accesibility
1 parent f59ff39 commit 459f9f1

File tree

8 files changed

+119
-42
lines changed

8 files changed

+119
-42
lines changed

.github/workflows/build-and-publish-wheels.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,30 @@ on:
88
jobs:
99
build-and-publish:
1010
name: Build wheel for ${{ matrix.folder }}
11-
runs-on: windows-latest
11+
runs-on: ${{ matrix.runner }}
1212
strategy:
1313
matrix:
1414
include:
1515
- folder: win-x86
1616
plat_tag: win32
17+
runner: windows-latest
18+
shell: cmd
1719
- folder: win-x64
1820
plat_tag: win_amd64
21+
runner: windows-latest
22+
shell: cmd
1923
- folder: win-arm64
2024
plat_tag: win_arm64
25+
runner: windows-latest
26+
shell: cmd
27+
- folder: linux-x64
28+
plat_tag: linux_x86_64
29+
runner: ubuntu-latest
30+
shell: bash
31+
- folder: linux-arm64
32+
plat_tag: linux_aarch64
33+
runner: ubuntu-latest
34+
shell: bash
2135

2236
steps:
2337
- name: Checkout
@@ -28,7 +42,8 @@ jobs:
2842
with:
2943
python-version: "3.10"
3044

31-
- name: Prepare scripts directory
45+
- name: Prepare scripts directory (Windows)
46+
if: matrix.runner == 'windows-latest'
3247
shell: cmd
3348
run: |
3449
echo Verificando archivo .bat en src\initvenv\scripts...
@@ -54,6 +69,28 @@ jobs:
5469
exit 1
5570
)
5671
72+
- name: Prepare scripts directory (Linux)
73+
if: matrix.runner == 'ubuntu-latest'
74+
shell: bash
75+
run: |
76+
echo "Verifying binary in src/initvenv/bin/${{ matrix.folder }}"
77+
if [ ! -f "src/initvenv/bin/${{ matrix.folder }}/initVenv" ]; then
78+
echo "Error: src/initvenv/bin/${{ matrix.folder }}/initVenv not found"
79+
exit 1
80+
else
81+
echo "✓ src/initvenv/bin/${{ matrix.folder }}/initVenv found"
82+
fi
83+
84+
# Clean any previous initvenv in scripts
85+
if [ -f "src/initvenv/scripts/initvenv" ]; then
86+
rm -f "src/initvenv/scripts/initvenv"
87+
echo "Removed previous initvenv in src/initvenv/scripts"
88+
fi
89+
90+
echo "Copying binary from src/initvenv/bin/${{ matrix.folder }}"
91+
cp "src/initvenv/bin/${{ matrix.folder }}/initVenv" "src/initvenv/scripts/initvenv"
92+
echo "✓ Copied initVenv to src/initvenv/scripts/initvenv"
93+
5794
- name: Install build tools
5895
run: |
5996
python -m pip install --upgrade pip

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "initvenv"
7-
version = "0.1.1"
7+
version = "0.2.0a1"
88
description = "Cross-language CLI tool written in C# to initialize Python virtual environments instantly with one command: 'initvenv'."
99
readme = { file = "README.md", content-type = "text/markdown", charset = "utf-8" }
1010
license = "GPL-3.0"

src/initvenv/_launcher.py

Lines changed: 79 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,60 +10,100 @@ def main():
1010
If the user does not pass a path, uses "." as default.
1111
"""
1212

13-
if not platform.system().lower().startswith("win"):
14-
print(f"This platform {platform.system()} is coming soon!")
15-
return 0
16-
17-
# Prevent recursive re-invocation
18-
if os.environ.get("INITVENV_LAUNCHED") == "1":
19-
return 0
20-
21-
pkg_root = Path(__file__).resolve().parent
22-
scripts_dir = pkg_root / "scripts"
13+
if platform.system().lower().startswith("win"):
14+
# Prevent recursive re-invocation
15+
if os.environ.get("INITVENV_LAUNCHED") == "1":
16+
return 0
2317

24-
bat = scripts_dir / "initvenv.bat"
25-
exe = scripts_dir / "initvenv.exe"
18+
pkg_root = Path(__file__).resolve().parent
19+
scripts_dir = pkg_root / "scripts"
2620

27-
if not bat.exists() and not exe.exists():
28-
pkg_root_up = pkg_root.parent
29-
scripts_dir = pkg_root_up / "scripts"
3021
bat = scripts_dir / "initvenv.bat"
3122
exe = scripts_dir / "initvenv.exe"
3223

33-
# If no path provided, default to current directory "."
34-
user_args = sys.argv[1:]
35-
if not user_args:
36-
target = "."
37-
else:
38-
target = user_args[0]
24+
if not bat.exists() and not exe.exists():
25+
pkg_root_up = pkg_root.parent
26+
scripts_dir = pkg_root_up / "scripts"
27+
bat = scripts_dir / "initvenv.bat"
28+
exe = scripts_dir / "initvenv.exe"
3929

40-
env = os.environ.copy()
41-
env["INITVENV_LAUNCHED"] = "1"
30+
# If no path provided, default to current directory "."
31+
user_args = sys.argv[1:]
32+
if not user_args:
33+
target = "."
34+
else:
35+
target = user_args[0]
4236

43-
cmd = os.environ.get("COMSPEC", "cmd.exe")
37+
env = os.environ.copy()
38+
env["INITVENV_LAUNCHED"] = "1"
4439

45-
if bat.exists():
46-
bat_path = str(bat)
47-
argv = [cmd, "/c", bat_path, target]
48-
try:
49-
subprocess.run(argv, check=True, env=env)
40+
cmd = os.environ.get("COMSPEC", "cmd.exe")
41+
42+
if bat.exists():
43+
bat_path = str(bat)
44+
argv = [cmd, "/c", bat_path, target]
45+
try:
46+
subprocess.run(argv, check=True, env=env)
47+
return 0
48+
except subprocess.CalledProcessError as e:
49+
print(f"Error executing {bat}: {e}", file=sys.stderr)
50+
return e.returncode
51+
52+
if exe.exists():
53+
exe_path = str(exe)
54+
argv = [exe_path, target]
55+
try:
56+
subprocess.run(argv, check=True, env=env)
57+
return 0
58+
except subprocess.CalledProcessError as e:
59+
print(f"Error executing {exe}: {e}", file=sys.stderr)
60+
return e.returncode
61+
62+
print("Error: neither initvenv.bat nor initvenv.exe were found in package scripts/", file=sys.stderr)
63+
return 2
64+
elif platform.system().lower() == "linux":
65+
# Prevent recursive re-invocation
66+
if os.environ.get("INITVENV_LAUNCHED") == "1":
5067
return 0
51-
except subprocess.CalledProcessError as e:
52-
print(f"Error executing {bat}: {e}", file=sys.stderr)
53-
return e.returncode
5468

55-
if exe.exists():
56-
exe_path = str(exe)
57-
argv = [exe_path, target]
69+
# Detect architecture
70+
machine = platform.machine().lower()
71+
if machine in ["x86_64", "amd64"]:
72+
arch = "x64"
73+
elif machine in ["aarch64", "arm64"]:
74+
arch = "arm64"
75+
else:
76+
print(f"Unsupported architecture: {machine}", file=sys.stderr)
77+
return 1
78+
79+
pkg_root = Path(__file__).resolve().parent
80+
bin_dir = pkg_root / "bin" / f"linux-{arch}"
81+
binary = bin_dir / "initVenv"
82+
83+
if not binary.exists():
84+
print(f"Error: Binary not found at {binary}", file=sys.stderr)
85+
return 2
86+
87+
# If no path provided, default to current directory "."
88+
user_args = sys.argv[1:]
89+
if not user_args:
90+
target = "."
91+
else:
92+
target = user_args[0]
93+
94+
env = os.environ.copy()
95+
env["INITVENV_LAUNCHED"] = "1"
96+
97+
argv = [str(binary), target]
5898
try:
5999
subprocess.run(argv, check=True, env=env)
60100
return 0
61101
except subprocess.CalledProcessError as e:
62-
print(f"Error executing {exe}: {e}", file=sys.stderr)
102+
print(f"Error executing {binary}: {e}", file=sys.stderr)
63103
return e.returncode
64-
65-
print("Error: neither initvenv.bat nor initvenv.exe were found in package scripts/", file=sys.stderr)
66-
return 2
104+
else:
105+
print(f"This platform {platform.system()} is coming soon!")
106+
return 0
67107

68108
if __name__ == "__main__":
69109
sys.exit(main())
12.7 MB
Binary file not shown.
13.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)