Skip to content

Commit 7306e79

Browse files
committed
tests: tetsbed for uv
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent c253191 commit 7306e79

File tree

5 files changed

+145
-0
lines changed

5 files changed

+145
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pip = ">=23.0"
103103
pipenv = ">=2023.11.5"
104104
poetry = "^1.7"
105105
pdm = "^2.11"
106+
uv = "0.6.4"
106107

107108

108109

tests/_data/infiles/environment/via-uv/.gitignore

Whitespace-only changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This file is part of CycloneDX Python
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
18+
"""
19+
initialize this testbed.
20+
"""
21+
22+
from os import environ
23+
from os.path import dirname, join
24+
from shutil import rmtree
25+
from subprocess import CompletedProcess, run # nosec:B404
26+
from sys import executable
27+
28+
__all__ = ['main']
29+
30+
this_dir = dirname(__file__)
31+
env_dir = join(this_dir, '.venv')
32+
33+
uv_env = environ.copy()
34+
uv_env['UV_NO_PROGRESS'] = '1'
35+
uv_env['UV_PROJECT_ENVIRONMENT'] = env_dir
36+
37+
38+
def uv_run(*args: str) -> CompletedProcess:
39+
# uv is not API, but a CLI -- call it like that!
40+
call = (
41+
executable, '-m', 'uv',
42+
*args
43+
)
44+
print('+ ', *call)
45+
res = run(call, cwd=this_dir, env=uv_env, shell=False) # nosec:B603
46+
if res.returncode != 0:
47+
raise RuntimeError('process failed')
48+
return res
49+
50+
51+
def main() -> None:
52+
# needed to reinit partially stripped evn
53+
rmtree(env_dir, ignore_errors=True)
54+
55+
# the actual setup
56+
uv_run('venv', env_dir)
57+
uv_run('sync', '--no-dev', '--locked', '--no-active')
58+
59+
60+
if __name__ == '__main__':
61+
main()
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[project]
2+
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#declaring-project-metadata
3+
name = "via-uv"
4+
version = "0.1.0"
5+
description = "environment via uv"
6+
license = { text = "Apache-2.0 OR MIT" }
7+
readme = "README.md"
8+
requires-python = ">=3.8"
9+
10+
# dynamic = [] # TODO
11+
12+
authors = ["Your Name <[email protected]>", "My Name"]
13+
maintainers = [
14+
"John Smith <[email protected]>",
15+
"Jane Smith <[email protected]>",
16+
]
17+
18+
keywords = ["packaging", "pipenv", "test"]
19+
classifiers = [
20+
"License :: OSI Approved :: Apache Software License",
21+
"License :: OSI Approved :: MIT License",
22+
"Classifier: Development Status :: 4 - Beta",
23+
"Intended Audience :: Developers"
24+
]
25+
26+
dependencies = [
27+
'toml'
28+
]
29+
optional-dependencies = { 'foo' = ['ddt'] }
30+
31+
# entry-point = {} # TODO
32+
33+
# gui-scripts = {} # TODO
34+
# scripts = {} # TODO
35+
36+
[project.urls]
37+
homepage = "https://oss.acme.org/my-project/"
38+
repository = "https://oss.acme.org/my-project.git"
39+
documentation = "https://oss.acme.org/my-project/docs/"
40+
"Bug Tracker" = "https://oss.acme.org/my-project/bugs/"
41+
"Funding" = "https://oss.acme.org/my-project/funding/"
42+
"Change log" = "https://oss.acme.org/my-project/changelog/"

tests/_data/infiles/environment/via-uv/uv.lock

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)