Skip to content

Commit

Permalink
Use nox to test in Python 3.7+ (#73)
Browse files Browse the repository at this point in the history
* use nox to test in python 3.7-3.10

* remove python 3.8+ debug syntax

* dirs_exist_ok (Python 3.8+) workaround

* python 3.8+ sqlite call

Co-authored-by: Jannis Leidel <jannis@leidel.info>
  • Loading branch information
dholth and jezdez committed Nov 29, 2022
1 parent bc0dcae commit 8a43a39
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
5 changes: 4 additions & 1 deletion conda_index/index/convert_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ def basename(path):
return path
return path.rsplit("/")[-1]

conn.create_function("migrate_basename", narg=1, func=basename, deterministic=True)
try:
conn.create_function("migrate_basename", narg=1, func=basename, deterministic=True)
except TypeError: # Python < 3.8
conn.create_function("migrate_basename", narg=1, func=basename)

for table in TABLE_NAMES + ["stat"]:
conn.execute(
Expand Down
2 changes: 1 addition & 1 deletion conda_index/index/sqlitecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, channel_root, subdir):
os.mkdir(self.cache_dir)

log.debug(
f"CondaIndexCache {channel_root=}, {subdir=} {self.db_filename=} {self.cache_is_brand_new=}"
f"CondaIndexCache channel_root={channel_root}, subdir={subdir} db_filename={self.db_filename} cache_is_brand_new={self.cache_is_brand_new}"
)

def __getstate__(self):
Expand Down
12 changes: 12 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import nox


@nox.session(venv_backend="conda")
@nox.parametrize(
"python",
[(python) for python in ("3.7", "3.8", "3.9", "3.10")],
)
def tests(session):
session.conda_install("conda", "conda-build")
session.install("-e", ".[test]")
session.run("pytest")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
license = { file = "LICENSE" }
readme = "README.md"
dynamic = ["version", "description"]
requires-python = ">=3.9"
requires-python = ">=3.7"
dependencies = [
"click >=8",
"conda >=4.12.0", # not available on pypi
Expand Down
12 changes: 11 additions & 1 deletion tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,17 @@ def _build_test_index(workdir):
"""

# workdir may be the same during a single test run?
shutil.copytree(join(here, "index_hotfix_pkgs"), workdir, dirs_exist_ok=True)
# Python 3.7 workaround "no dirs_exist_ok flag"
index_hotfix_pkgs = join(here, "index_hotfix_pkgs")
for path in os.scandir(index_hotfix_pkgs):
if path.is_dir():
shutil.copytree(
join(here, "index_hotfix_pkgs", path.name), join(workdir, path.name)
)
elif path.is_file():
shutil.copyfile(
join(here, "index_hotfix_pkgs", path.name), join(workdir, path.name)
)

with open(os.path.join(workdir, TEST_SUBDIR, "repodata.json")) as f:
original_metadata = json.load(f)
Expand Down

0 comments on commit 8a43a39

Please sign in to comment.