Skip to content

Commit 115dcaf

Browse files
authored
Merge pull request #9 from KoltesDigital/main
Support Windows
2 parents a9ae173 + 69c2e76 commit 115dcaf

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ If using the system-provided Python on Debian/Ubuntu, you may need to run
2323
apt install python3.8-venv
2424
```
2525

26+
On Windows, [you need to enable symlink support](https://bazel.build/configure/windows#symlink).
27+
2628
## Example
2729
```
2830
$ cd example

build_env.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,22 @@ def is_external(file_: pathlib.Path) -> bool:
8383

8484

8585
def find_site_packages(env_path: pathlib.Path) -> pathlib.Path:
86-
lib_path = env_path / "lib"
86+
if sys.platform == 'win32':
87+
lib_path = env_path / "Lib"
8788

88-
# We should find one "pythonX.X" directory in here.
89-
for child in lib_path.iterdir():
90-
if child.name.startswith("python"):
91-
site_packages_path = child / "site-packages"
92-
if site_packages_path.exists():
93-
return site_packages_path
89+
site_packages_path = lib_path / "site-packages"
90+
if site_packages_path.exists():
91+
return site_packages_path
92+
93+
else:
94+
lib_path = env_path / "lib"
95+
96+
# We should find one "pythonX.X" directory in here.
97+
for child in lib_path.iterdir():
98+
if child.name.startswith("python"):
99+
site_packages_path = child / "site-packages"
100+
if site_packages_path.exists():
101+
return site_packages_path
94102

95103
raise Exception("Unable to find site-packages path in venv")
96104

@@ -163,11 +171,14 @@ def entry_points(path: List[str], **params) -> importlib_metadata.EntryPoints:
163171

164172
def generate_console_scripts(env_path: pathlib.Path) -> None:
165173
site_packages = find_site_packages(env_path)
166-
bin = env_path / "bin"
174+
if sys.platform == 'win32':
175+
bin_path = env_path / "Scripts"
176+
else:
177+
bin_path = env_path / "bin"
167178

168179
console_scripts = entry_points(path=[str(site_packages)], group="console_scripts")
169180
for ep in console_scripts:
170-
script = bin / ep.name
181+
script = bin_path / ep.name
171182
if script.exists():
172183
continue
173184
script.write_text(

0 commit comments

Comments
 (0)