-
-
Notifications
You must be signed in to change notification settings - Fork 91
docs: showcase usage with uv
#858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # This file is part of CycloneDX Python | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Copyright (c) OWASP Foundation. All Rights Reserved. | ||
|
|
||
| """ | ||
| initialize this testbed. | ||
| """ | ||
|
|
||
| from os import environ | ||
| from os.path import dirname, join | ||
| from shutil import rmtree | ||
| from subprocess import CompletedProcess, run # nosec:B404 | ||
| from sys import executable | ||
|
|
||
| __all__ = ['main'] | ||
|
|
||
| this_dir = dirname(__file__) | ||
| env_dir = join(this_dir, '.venv') | ||
|
|
||
| uv_env = environ.copy() | ||
| uv_env['UV_NO_PROGRESS'] = '1' | ||
| uv_env['UV_PROJECT_ENVIRONMENT'] = env_dir | ||
|
|
||
|
|
||
| def uv_run(*args: str) -> CompletedProcess: | ||
| # uv is not API, but a CLI -- call it like that! | ||
| call = ( | ||
| executable, '-m', 'uv', | ||
| *args | ||
| ) | ||
| print('+ ', *call) | ||
| res = run(call, cwd=this_dir, env=uv_env, shell=False) # nosec:B603 | ||
| if res.returncode != 0: | ||
| raise RuntimeError('process failed') | ||
| return res | ||
|
|
||
|
|
||
| def main() -> None: | ||
| # needed to reinit partially stripped evn | ||
| rmtree(env_dir, ignore_errors=True) | ||
|
|
||
| # the actual setup | ||
| uv_run('venv', env_dir) | ||
| uv_run('sync', '--no-dev', '--locked', '--no-active') | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| [project] | ||
| # https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#declaring-project-metadata | ||
| name = "via-uv" | ||
| version = "0.1.0" | ||
| description = "environment via uv" | ||
| license = { text = "Apache-2.0 OR MIT" } | ||
| readme = "README.md" | ||
| requires-python = ">=3.8" | ||
|
|
||
| # dynamic = [] # TODO | ||
|
|
||
| authors = ["Your Name <you@example.com>", "My Name"] | ||
| maintainers = [ | ||
| "John Smith <johnsmith@example.org>", | ||
| "Jane Smith <janesmith@example.org>", | ||
| ] | ||
|
|
||
| keywords = ["packaging", "pipenv", "test"] | ||
jkowalleck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| classifiers = [ | ||
| "License :: OSI Approved :: Apache Software License", | ||
| "License :: OSI Approved :: MIT License", | ||
| "Classifier: Development Status :: 4 - Beta", | ||
| "Intended Audience :: Developers" | ||
| ] | ||
|
|
||
| dependencies = [ | ||
| 'toml' | ||
| ] | ||
| optional-dependencies = { 'foo' = ['ddt'] } | ||
|
|
||
| # entry-point = {} # TODO | ||
|
|
||
| # gui-scripts = {} # TODO | ||
| # scripts = {} # TODO | ||
|
|
||
| [project.urls] | ||
jkowalleck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| homepage = "https://oss.acme.org/my-project/" | ||
| repository = "https://oss.acme.org/my-project.git" | ||
| documentation = "https://oss.acme.org/my-project/docs/" | ||
| "Bug Tracker" = "https://oss.acme.org/my-project/bugs/" | ||
| "Funding" = "https://oss.acme.org/my-project/funding/" | ||
| "Change log" = "https://oss.acme.org/my-project/changelog/" | ||
|
|
||
|
|
||
| [tool.uv] | ||
| # https://docs.astral.sh/uv/reference/settings/ | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.