Skip to content

Commit

Permalink
🧪 testing compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Jul 13, 2024
1 parent 138ba3c commit a68b0f1
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 77 deletions.
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ dependencies = [
"pytest",
"pytest-cov",
"tomlkit",
"pytest-xdist",
"virtualenv-api"
"pytest-xdist"
]

[tool.hatch.envs.test.scripts]
Expand Down Expand Up @@ -175,7 +174,6 @@ matrix.version.dependencies = [
"pytest-cov",
"tomlkit",
"pytest-xdist",
"virtualenv-api",
{value = "hatch~=1.7.0", if = ["1.7.x"]},
{value = "hatch~=1.8.1", if = ["1.8.x"]},
{value = "hatch~=1.9.7", if = ["1.9.x"]},
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-matrix.py3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - click
# - hatch<2,>=1.7.0
# - pip-tools>=6
Expand Down Expand Up @@ -179,8 +178,6 @@ shellingham==1.5.4
# via
# -c requirements.txt
# hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# -c requirements.txt
Expand Down Expand Up @@ -220,8 +217,6 @@ virtualenv==20.26.3
# via
# -c requirements.txt
# hatch
virtualenv-api==2.1.18
# via hatch.envs.matrix.py3.10
wheel==0.43.0
# via
# -c requirements.txt
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-matrix.py3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - click
# - hatch<2,>=1.7.0
# - pip-tools>=6
Expand Down Expand Up @@ -175,8 +174,6 @@ shellingham==1.5.4
# via
# -c requirements.txt
# hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# -c requirements.txt
Expand Down Expand Up @@ -207,8 +204,6 @@ virtualenv==20.26.3
# via
# -c requirements.txt
# hatch
virtualenv-api==2.1.18
# via hatch.envs.matrix.py3.11
wheel==0.43.0
# via
# -c requirements.txt
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-matrix.py3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - click
# - hatch<2,>=1.7.0
# - pip-tools>=6
Expand Down Expand Up @@ -167,8 +166,6 @@ shellingham==1.5.4
# via
# -c requirements.txt
# hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# -c requirements.txt
Expand Down Expand Up @@ -199,8 +196,6 @@ virtualenv==20.26.3
# via
# -c requirements.txt
# hatch
virtualenv-api==2.1.18
# via hatch.envs.matrix.py3.12
wheel==0.43.0
# via
# -c requirements.txt
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-matrix.py3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - click
# - hatch<2,>=1.7.0
# - pip-tools>=6
Expand Down Expand Up @@ -182,8 +181,6 @@ shellingham==1.5.4
# via
# -c requirements.txt
# hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# -c requirements.txt
Expand Down Expand Up @@ -225,8 +222,6 @@ virtualenv==20.26.3
# via
# -c requirements.txt
# hatch
virtualenv-api==2.1.18
# via hatch.envs.matrix.py3.8
wheel==0.43.0
# via
# -c requirements.txt
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-matrix.py3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - click
# - hatch<2,>=1.7.0
# - pip-tools>=6
Expand Down Expand Up @@ -180,8 +179,6 @@ shellingham==1.5.4
# via
# -c requirements.txt
# hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# -c requirements.txt
Expand Down Expand Up @@ -221,8 +218,6 @@ virtualenv==20.26.3
# via
# -c requirements.txt
# hatch
virtualenv-api==2.1.18
# via hatch.envs.matrix.py3.9
wheel==0.43.0
# via
# -c requirements.txt
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - click
# - hatch<2,>=1.7.0
# - pip-tools>=6
Expand Down Expand Up @@ -175,8 +174,6 @@ shellingham==1.5.4
# via
# -c requirements.txt
# hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# -c requirements.txt
Expand Down Expand Up @@ -207,8 +204,6 @@ virtualenv==20.26.3
# via
# -c requirements.txt
# hatch
virtualenv-api==2.1.18
# via hatch.envs.test
wheel==0.43.0
# via
# -c requirements.txt
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-versions.1.10.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - hatch~=1.10.0
# - click
# - hatch<2,>=1.7.0
Expand Down Expand Up @@ -117,8 +116,6 @@ rich==13.7.1
# hatch
shellingham==1.5.4
# via hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# anyio
Expand All @@ -137,8 +134,6 @@ uv==0.2.24
# via hatch
virtualenv==20.26.3
# via hatch
virtualenv-api==2.1.18
# via hatch.envs.versions.1.10.x
wheel==0.43.0
# via pip-tools
zipp==3.19.2
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-versions.1.11.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - hatch~=1.11.1
# - click
# - hatch<2,>=1.7.0
Expand Down Expand Up @@ -117,8 +116,6 @@ rich==13.7.1
# hatch
shellingham==1.5.4
# via hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# anyio
Expand All @@ -137,8 +134,6 @@ uv==0.2.24
# via hatch
virtualenv==20.26.3
# via hatch
virtualenv-api==2.1.18
# via hatch.envs.versions.1.11.x
wheel==0.43.0
# via pip-tools
zipp==3.19.2
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-versions.1.12.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - hatch~=1.12.0
# - click
# - hatch<2,>=1.7.0
Expand Down Expand Up @@ -117,8 +116,6 @@ rich==13.7.1
# hatch
shellingham==1.5.4
# via hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# anyio
Expand All @@ -137,8 +134,6 @@ uv==0.2.24
# via hatch
virtualenv==20.26.3
# via hatch
virtualenv-api==2.1.18
# via hatch.envs.versions.1.12.x
wheel==0.43.0
# via pip-tools
zipp==3.19.2
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-versions.1.7.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - hatch~=1.7.0
# - click
# - hatch<2,>=1.7.0
Expand Down Expand Up @@ -119,8 +118,6 @@ rich==13.7.1
# hatch
shellingham==1.5.4
# via hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# anyio
Expand All @@ -137,8 +134,6 @@ userpath==1.9.2
# via hatch
virtualenv==20.26.3
# via hatch
virtualenv-api==2.1.18
# via hatch.envs.versions.1.7.x
wheel==0.43.0
# via pip-tools
zipp==3.19.2
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-versions.1.8.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - hatch~=1.8.1
# - click
# - hatch<2,>=1.7.0
Expand Down Expand Up @@ -117,8 +116,6 @@ rich==13.7.1
# hatch
shellingham==1.5.4
# via hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# anyio
Expand All @@ -135,8 +132,6 @@ userpath==1.9.2
# via hatch
virtualenv==20.26.3
# via hatch
virtualenv-api==2.1.18
# via hatch.envs.versions.1.8.x
wheel==0.43.0
# via pip-tools
zipp==3.19.2
Expand Down
5 changes: 0 additions & 5 deletions requirements/requirements-versions.1.9.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# - pytest-cov
# - tomlkit
# - pytest-xdist
# - virtualenv-api
# - hatch~=1.9.7
# - click
# - hatch<2,>=1.7.0
Expand Down Expand Up @@ -119,8 +118,6 @@ rich==13.7.1
# hatch
shellingham==1.5.4
# via hatch
six==1.16.0
# via virtualenv-api
sniffio==1.3.1
# via
# anyio
Expand All @@ -137,8 +134,6 @@ userpath==1.9.2
# via hatch
virtualenv==20.25.3
# via hatch
virtualenv-api==2.1.18
# via hatch.envs.versions.1.9.x
wheel==0.43.0
# via pip-tools
zipp==3.19.2
Expand Down
40 changes: 26 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from hatch.project.core import Project
from hatch.utils.fs import Path, temp_directory
from hatch.utils.platform import Platform
from virtualenvapi.manage import VirtualEnvironment

from hatch_pip_compile.plugin import PipCompileEnvironment

Expand Down Expand Up @@ -211,26 +210,39 @@ def invoke_environment(
return result

@staticmethod
def get_virtualenv(
environment: PipCompileEnvironment,
) -> tuple[VirtualEnvironment, pathlib.Path]:
def virtualenv_exists(environment: PipCompileEnvironment) -> bool:
"""
Get the virtual environment
Check if the virtual environment exists
"""
virtualenv_path = environment.virtual_env.directory
virtualenv = VirtualEnvironment(str(virtualenv_path))
return virtualenv, virtualenv_path
virtualenv_cfg = environment.virtual_env.directory / "pyvenv.cfg"
return virtualenv_cfg.exists()

@staticmethod
def is_installed(
self,
environment: PipCompileEnvironment,
package: str,
):
site_packages_search = environment.virtual_env.directory.rglob("**/site-packages")
site_packages = next(site_packages_search, None)
if not site_packages:
) -> bool:
"""
Check if a package is installed in the environment
This method simply checks if the package is in the site-packages directory
of the virtual environment.
"""
if not self.virtualenv_exists(environment=environment):
return False
return (site_packages / package).exists()
if self.platform.windows:
site_packages = environment.virtual_env.directory / "Lib" / "site-packages"
if not site_packages.exists():
return False
else:
site_packages_search = environment.virtual_env.directory.glob(
"lib/python*/site-packages"
)
site_packages = next(site_packages_search, None)
if site_packages is None:
return False
package_dir = site_packages / package
return (package_dir / "__init__.py").exists()


@pytest.fixture
Expand Down
Loading

0 comments on commit a68b0f1

Please sign in to comment.