Description
Hi,
basilisp bootstrap
fails to install properly on MS-Windows:
Error processing line 1 of D:\bas\issue\.venv\basilispbootstrap.pth:
Traceback (most recent call last):
File "<frozen site>", line 186, in addpackage
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'basilisp'
To reproduce with Poetry from scartch on windows
- Create a
new
issue
venv,add
Basilisp and enter theshell
:
> poetry new issue
> cd issue
issue> poetry add basilisp
Creating virtualenv issue in D:\bas\issue\.venv
...
issue> poetry shell
(issue-py3.11) issue> basilisp version
Basilisp 0.3.6
bootstrap
Basilisp, and check theversion
, the above error message appears because Python fails to loadbasilispbootstrap.pth
(issue-py3.11) issue> basilisp bootstrap
Your Python installation has been bootstrapped! You can undo this at any time with with `basilisp bootstrap --uninstall`.
(issue-py3.11) issue> basilisp version
Error processing line 1 of D:\bas\issue\.venv\basilispbootstrap.pth:
Traceback (most recent call last):
File "<frozen site>", line 186, in addpackage
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'basilisp'
Remainder of file ignored
Basilisp 0.3.6
The cause is that the basilisp bootstrap
process added .pth
file at the root of the virtual environment (.venv\basilispbootstrap.pth
):
issue> cat .venv\basilispbootstrap.pth
import basilisp.sitecustomize
At startup, Python attempts to import basilisp.sitecustomize
, but basilisp
is not yet in sys.path, causing the failure.
Ideally, instead of placing the .pth
file in the first directory returned by site.getsitepackages()
(which is inappropriate on Windows):
>>> import site
>>> site.getsitepackages()
['D:\\bas\\issue\\.venv', 'D:\\bas\\issue\\.venv\\Lib\\site-packages']
basilisp bootstrap
should place it in the sys.path
directory where basilisp
is installed, so that basilisp
is always guaranteed to be available.
Possible options I can think of for fixing basilisp bootstrap
- Traverse
site.getsitepackages()
and place the.pth
file in the directory containingbasilisp
. - Use the sysconfig.get_paths()
purelib
value which directly points to the correctsite-packages
directory:
stdlib: directory containing the standard Python library files that are not platform-specific.
platstdlib: directory containing the standard Python library files that are platform-specific.
platlib: directory for site-specific, platform-specific files.
purelib: directory for site-specific, non-platform-specific files (‘pure’ Python).
include: directory for non-platform-specific header files for the Python C-API.
platinclude: directory for platform-specific header files for the Python C-API.
scripts: directory for script files.
data: directory for data files.
>>> import sysconfig
>>> sysconfig.get_paths()["purelib"]
'D:\\bas\\issue\\.venv\\Lib\\site-packages'
I prefer option (2) for its simplicity.
Do you have a preference or another suggestion?
Thanks