forked from fsspec/universal_pathlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
116 lines (90 loc) · 2.97 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"""Automation using nox."""
import glob
import os
import nox
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = "lint", "tests"
locations = ("upath",)
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"])
def tests(session: nox.Session) -> None:
# workaround in case no aiohttp binary wheels are available
session.env["AIOHTTP_NO_EXTENSIONS"] = "1"
session.install(".[tests,dev]")
session.run(
"pytest",
"-m",
"not hdfs",
"--cov",
"--cov-config=pyproject.toml",
*session.posargs,
env={"COVERAGE_FILE": f".coverage.{session.python}"},
)
@nox.session(python="3.8", name="tests-minversion")
def tests_minversion(session: nox.Session) -> None:
session.install("fsspec==2022.1.0", ".[tests,dev]")
session.run(
"pytest",
"-m",
"not hdfs",
"--cov",
"--cov-config=pyproject.toml",
*session.posargs,
env={"COVERAGE_FILE": f".coverage.{session.python}"},
)
@nox.session
def lint(session: nox.Session) -> None:
session.install("pre-commit")
session.install("-e", ".[tests]")
args = *(session.posargs or ("--show-diff-on-failure",)), "--all-files"
session.run("pre-commit", "run", *args)
@nox.session
def safety(session: nox.Session) -> None:
"""Scan dependencies for insecure packages."""
session.install(".")
session.install("safety")
session.run("safety", "check", "--full-report")
@nox.session
def build(session: nox.Session) -> None:
session.install("build", "setuptools", "twine")
session.run("python", "-m", "build")
dists = glob.glob("dist/*")
session.run("twine", "check", *dists, silent=True)
@nox.session
def develop(session: nox.Session) -> None:
"""Sets up a python development environment for the project."""
args = session.posargs or ("venv",)
venv_dir = os.fsdecode(os.path.abspath(args[0]))
session.log(f"Setting up virtual environment in {venv_dir}")
session.install("virtualenv")
session.run("virtualenv", venv_dir, silent=True)
python = os.path.join(venv_dir, "bin/python")
session.run(python, "-m", "pip", "install", "-e", ".[tests,dev]", external=True)
@nox.session
def black(session):
print("please run `nox -s lint` instead")
raise SystemExit(1)
@nox.session
def type_checking(session):
session.install("-e", ".[tests]")
session.run("python", "-m", "mypy")
@nox.session
def typesafety(session):
session.install("-e", ".[tests]")
session.run(
"python",
"-m",
"pytest",
"-v",
"-p",
"pytest-mypy-plugins",
"--mypy-pyproject-toml-file",
"pyproject.toml",
"typesafety",
)
@nox.session(python="3.12")
def generate_flavours(session):
session.install("-r", "dev/requirements.txt")
with open("upath/_flavour_sources.py", "w") as target:
session.run(
"python", "dev/fsspec_inspector/generate_flavours.py", stdout=target
)