Skip to content

Commit

Permalink
when need add SCRIPTS folder to sys.path
Browse files Browse the repository at this point in the history
- test: for Windows, attempt add SCRIPTS folder to sys.path
- test: for Windows, walk SCRIPTS folder print files and folders
  • Loading branch information
msftcangoblowm committed Aug 27, 2024
1 parent 73f6e89 commit f0a2bf9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project follows an extension of
fourth number represents an administrative maintenance release with no code
changes.

### [2.4.1.2] - 2024-08-27

#### Tests

* for Windows, attempt add SCRIPTS folder to sys.path
* for Windows, walk SCRIPTS folder print files and folders

### [2.4.1.1] - 2024-08-27

#### Tests
Expand Down
2 changes: 1 addition & 1 deletion src/sphobjinv/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"""

__version__ = "2.4.1"
__version__ = "2.4.1.2"
19 changes: 18 additions & 1 deletion tests/test_cli_textconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
@pytest.fixture
def windows_paths():
"""Fixture prints diagnostic info for bugging Windows paths."""
import os
import platform
import site

def func() -> None:
Expand All @@ -74,6 +74,23 @@ def func() -> None:
# On Windows, what is the lib path?
# /home/faulkmore/.local/lib/python3.9/site-packages
print(f"Packages site path: {site.USER_SITE}", file=sys.stderr)
if platform.system() == "Windows":
site_packages = site.getsitepackages()
site_user_packages = site.getusersitepackages()
print(f"site packages: {site_packages!r}", file=sys.stderr)
print(f"user site packages: {site_user_packages!r}", file=sys.stderr)

path_scripts = Path(site.USER_SITE).parent.joinpath("SCRIPTS")
scripts_path = str(path_scripts)
print(f"path_scripts: {path_scripts}", file=sys.stderr)
for (dirpath, dirnames, filenames) in os.walk(str(path_scripts)):
print(f"{dirpath!s} {dirnames!r} {filenames!r}")

# Set path to parent folder of package entrypoint executables
if scripts_path not in sys.path:
# https://stackoverflow.com/a/10253916
# `[better way] <https://stackoverflow.com/a/59411635>`_
sys.path.append(0, scripts_path)

return func

Expand Down
19 changes: 18 additions & 1 deletion tests/test_cli_textconv_with_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
@pytest.fixture
def windows_paths():
"""Fixture prints diagnostic info for bugging Windows paths."""
import os
import site
import platform

def func() -> None:
"""Diagnostic info for bugging Windows paths."""
Expand All @@ -68,6 +68,23 @@ def func() -> None:
# On Windows, what is the lib path?
# /home/faulkmore/.local/lib/python3.9/site-packages
print(f"Packages site path: {site.USER_SITE}", file=sys.stderr)
if platform.system() == "Windows":
site_packages = site.getsitepackages()
site_user_packages = site.getusersitepackages()
print(f"site packages: {site_packages!r}", file=sys.stderr)
print(f"user site packages: {site_user_packages!r}", file=sys.stderr)

path_scripts = Path(site.USER_SITE).parent.joinpath("SCRIPTS")
scripts_path = str(path_scripts)
print(f"path_scripts: {path_scripts}", file=sys.stderr)
for (dirpath, dirnames, filenames) in os.walk(str(path_scripts)):
print(f"{dirpath!s} {dirnames!r} {filenames!r}")

# Set path to parent folder of package entrypoint executables
# https://stackoverflow.com/a/10253916
# `[better way] <https://stackoverflow.com/a/59411635>`_
if scripts_path not in sys.path:
sys.path.append(0, scripts_path)

return func

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ commands=
deps=

[pytest]
# cd .tox; tox --root=.. -c ../tox.ini -e py38-sphx_latest-attrs_latest-jsch_latest \
# --workdir=.; cd - 2>/dev/null
# cd .tox; PYTHONPATH=../ tox --root=.. -c ../tox.ini \
# -e py38-sphx_latest-attrs_latest-jsch_latest --workdir=.; cd - 2>/dev/null
markers =
local: Tests not requiring Internet access
nonloc: Tests requiring Internet access
Expand Down

0 comments on commit f0a2bf9

Please sign in to comment.