Skip to content

Commit

Permalink
feat: Add default dependencies fields (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewianda authored Jul 16, 2024
1 parent b0b8c8f commit b1a8c1d
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 109 deletions.
17 changes: 10 additions & 7 deletions docs/ext_lock_import.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ The lock_import extension.
<pre>
lock_import = use_extension("@rules_pycross//pycross/extensions:lock_import.bzl", "lock_import")
lock_import.import_pdm(<a href="#lock_import.import_pdm-all_development_groups">all_development_groups</a>, <a href="#lock_import.import_pdm-all_optional_groups">all_optional_groups</a>, <a href="#lock_import.import_pdm-default">default</a>,
<a href="#lock_import.import_pdm-default_alias_single_version">default_alias_single_version</a>, <a href="#lock_import.import_pdm-development_groups">development_groups</a>, <a href="#lock_import.import_pdm-disallow_builds">disallow_builds</a>,
<a href="#lock_import.import_pdm-local_wheels">local_wheels</a>, <a href="#lock_import.import_pdm-lock_file">lock_file</a>, <a href="#lock_import.import_pdm-optional_groups">optional_groups</a>, <a href="#lock_import.import_pdm-project_file">project_file</a>, <a href="#lock_import.import_pdm-repo">repo</a>,
<a href="#lock_import.import_pdm-default_alias_single_version">default_alias_single_version</a>, <a href="#lock_import.import_pdm-default_build_dependencies">default_build_dependencies</a>, <a href="#lock_import.import_pdm-development_groups">development_groups</a>,
<a href="#lock_import.import_pdm-disallow_builds">disallow_builds</a>, <a href="#lock_import.import_pdm-local_wheels">local_wheels</a>, <a href="#lock_import.import_pdm-lock_file">lock_file</a>, <a href="#lock_import.import_pdm-optional_groups">optional_groups</a>, <a href="#lock_import.import_pdm-project_file">project_file</a>, <a href="#lock_import.import_pdm-repo">repo</a>,
<a href="#lock_import.import_pdm-require_static_urls">require_static_urls</a>, <a href="#lock_import.import_pdm-target_environments">target_environments</a>)
lock_import.import_poetry(<a href="#lock_import.import_poetry-default_alias_single_version">default_alias_single_version</a>, <a href="#lock_import.import_poetry-disallow_builds">disallow_builds</a>, <a href="#lock_import.import_poetry-local_wheels">local_wheels</a>, <a href="#lock_import.import_poetry-lock_file">lock_file</a>,
<a href="#lock_import.import_poetry-project_file">project_file</a>, <a href="#lock_import.import_poetry-repo">repo</a>, <a href="#lock_import.import_poetry-target_environments">target_environments</a>)
lock_import.import_poetry(<a href="#lock_import.import_poetry-default_alias_single_version">default_alias_single_version</a>, <a href="#lock_import.import_poetry-default_build_dependencies">default_build_dependencies</a>, <a href="#lock_import.import_poetry-disallow_builds">disallow_builds</a>,
<a href="#lock_import.import_poetry-local_wheels">local_wheels</a>, <a href="#lock_import.import_poetry-lock_file">lock_file</a>, <a href="#lock_import.import_poetry-project_file">project_file</a>, <a href="#lock_import.import_poetry-repo">repo</a>, <a href="#lock_import.import_poetry-target_environments">target_environments</a>)
lock_import.import_uv(<a href="#lock_import.import_uv-all_development_groups">all_development_groups</a>, <a href="#lock_import.import_uv-all_optional_groups">all_optional_groups</a>, <a href="#lock_import.import_uv-default">default</a>,
<a href="#lock_import.import_uv-default_alias_single_version">default_alias_single_version</a>, <a href="#lock_import.import_uv-development_groups">development_groups</a>, <a href="#lock_import.import_uv-disallow_builds">disallow_builds</a>, <a href="#lock_import.import_uv-local_wheels">local_wheels</a>,
<a href="#lock_import.import_uv-lock_file">lock_file</a>, <a href="#lock_import.import_uv-optional_groups">optional_groups</a>, <a href="#lock_import.import_uv-project_file">project_file</a>, <a href="#lock_import.import_uv-repo">repo</a>, <a href="#lock_import.import_uv-require_static_urls">require_static_urls</a>,
<a href="#lock_import.import_uv-target_environments">target_environments</a>)
<a href="#lock_import.import_uv-default_alias_single_version">default_alias_single_version</a>, <a href="#lock_import.import_uv-default_build_dependencies">default_build_dependencies</a>, <a href="#lock_import.import_uv-development_groups">development_groups</a>,
<a href="#lock_import.import_uv-disallow_builds">disallow_builds</a>, <a href="#lock_import.import_uv-local_wheels">local_wheels</a>, <a href="#lock_import.import_uv-lock_file">lock_file</a>, <a href="#lock_import.import_uv-optional_groups">optional_groups</a>, <a href="#lock_import.import_uv-project_file">project_file</a>, <a href="#lock_import.import_uv-repo">repo</a>,
<a href="#lock_import.import_uv-require_static_urls">require_static_urls</a>, <a href="#lock_import.import_uv-target_environments">target_environments</a>)
lock_import.package(<a href="#lock_import.package-name">name</a>, <a href="#lock_import.package-always_build">always_build</a>, <a href="#lock_import.package-build_dependencies">build_dependencies</a>, <a href="#lock_import.package-build_target">build_target</a>, <a href="#lock_import.package-ignore_dependencies">ignore_dependencies</a>,
<a href="#lock_import.package-install_exclude_globs">install_exclude_globs</a>, <a href="#lock_import.package-repo">repo</a>)
</pre>
Expand All @@ -39,6 +39,7 @@ Import a PDM lock file.
| <a id="lock_import.import_pdm-all_optional_groups"></a>all_optional_groups | Install all optional dependencies. | Boolean | optional | `False` |
| <a id="lock_import.import_pdm-default"></a>default | Whether to install dependencies from the default group. | Boolean | optional | `True` |
| <a id="lock_import.import_pdm-default_alias_single_version"></a>default_alias_single_version | Generate aliases for all packages that have a single version in the lock file. | Boolean | optional | `False` |
| <a id="lock_import.import_pdm-default_build_dependencies"></a>default_build_dependencies | A list of package keys (name or name@version) that will be used as default build dependencies. | List of strings | optional | `[]` |
| <a id="lock_import.import_pdm-development_groups"></a>development_groups | List of development dependency groups to install. | List of strings | optional | `[]` |
| <a id="lock_import.import_pdm-disallow_builds"></a>disallow_builds | If True, only pre-built wheels are allowed. | Boolean | optional | `False` |
| <a id="lock_import.import_pdm-local_wheels"></a>local_wheels | A list of local .whl files to consider when processing lock files. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
Expand All @@ -60,6 +61,7 @@ Import a Poetry lock file.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="lock_import.import_poetry-default_alias_single_version"></a>default_alias_single_version | Generate aliases for all packages that have a single version in the lock file. | Boolean | optional | `False` |
| <a id="lock_import.import_poetry-default_build_dependencies"></a>default_build_dependencies | A list of package keys (name or name@version) that will be used as default build dependencies. | List of strings | optional | `[]` |
| <a id="lock_import.import_poetry-disallow_builds"></a>disallow_builds | If True, only pre-built wheels are allowed. | Boolean | optional | `False` |
| <a id="lock_import.import_poetry-local_wheels"></a>local_wheels | A list of local .whl files to consider when processing lock files. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
| <a id="lock_import.import_poetry-lock_file"></a>lock_file | The poetry.lock file. | <a href="https://bazel.build/concepts/labels">Label</a> | required | |
Expand All @@ -81,6 +83,7 @@ Import a uv lock file.
| <a id="lock_import.import_uv-all_optional_groups"></a>all_optional_groups | Install all optional dependencies. | Boolean | optional | `False` |
| <a id="lock_import.import_uv-default"></a>default | Whether to install dependencies from the default group. | Boolean | optional | `True` |
| <a id="lock_import.import_uv-default_alias_single_version"></a>default_alias_single_version | Generate aliases for all packages that have a single version in the lock file. | Boolean | optional | `False` |
| <a id="lock_import.import_uv-default_build_dependencies"></a>default_build_dependencies | A list of package keys (name or name@version) that will be used as default build dependencies. | List of strings | optional | `[]` |
| <a id="lock_import.import_uv-development_groups"></a>development_groups | List of development dependency groups to install. | List of strings | optional | `[]` |
| <a id="lock_import.import_uv-disallow_builds"></a>disallow_builds | If True, only pre-built wheels are allowed. | Boolean | optional | `False` |
| <a id="lock_import.import_uv-local_wheels"></a>local_wheels | A list of local .whl files to consider when processing lock files. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` |
Expand Down
7 changes: 4 additions & 3 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Public build rule API re-exports

<pre>
pycross_lock_file(<a href="#pycross_lock_file-name">name</a>, <a href="#pycross_lock_file-out">out</a>, <a href="#pycross_lock_file-always_include_sdist">always_include_sdist</a>, <a href="#pycross_lock_file-annotations">annotations</a>, <a href="#pycross_lock_file-default_alias_single_version">default_alias_single_version</a>,
<a href="#pycross_lock_file-disallow_builds">disallow_builds</a>, <a href="#pycross_lock_file-fully_qualified_environment_labels">fully_qualified_environment_labels</a>, <a href="#pycross_lock_file-generate_file_map">generate_file_map</a>,
<a href="#pycross_lock_file-local_wheels">local_wheels</a>, <a href="#pycross_lock_file-lock_model_file">lock_model_file</a>, <a href="#pycross_lock_file-pypi_index">pypi_index</a>, <a href="#pycross_lock_file-remote_wheels">remote_wheels</a>, <a href="#pycross_lock_file-repo_prefix">repo_prefix</a>,
<a href="#pycross_lock_file-target_environments">target_environments</a>)
<a href="#pycross_lock_file-default_build_dependencies">default_build_dependencies</a>, <a href="#pycross_lock_file-disallow_builds">disallow_builds</a>, <a href="#pycross_lock_file-fully_qualified_environment_labels">fully_qualified_environment_labels</a>,
<a href="#pycross_lock_file-generate_file_map">generate_file_map</a>, <a href="#pycross_lock_file-local_wheels">local_wheels</a>, <a href="#pycross_lock_file-lock_model_file">lock_model_file</a>, <a href="#pycross_lock_file-pypi_index">pypi_index</a>, <a href="#pycross_lock_file-remote_wheels">remote_wheels</a>,
<a href="#pycross_lock_file-repo_prefix">repo_prefix</a>, <a href="#pycross_lock_file-target_environments">target_environments</a>)
</pre>


Expand All @@ -25,6 +25,7 @@ pycross_lock_file(<a href="#pycross_lock_file-name">name</a>, <a href="#pycross_
| <a id="pycross_lock_file-always_include_sdist"></a>always_include_sdist | Always include an entry for a package's sdist if one exists. | Boolean | optional | `False` |
| <a id="pycross_lock_file-annotations"></a>annotations | Optional annotations to apply to packages. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` |
| <a id="pycross_lock_file-default_alias_single_version"></a>default_alias_single_version | Generate aliases for all packages that have a single version in the lock file. | Boolean | optional | `False` |
| <a id="pycross_lock_file-default_build_dependencies"></a>default_build_dependencies | A list of package keys (name or name@version) that will be used as default build dependencies. | List of strings | optional | `[]` |
| <a id="pycross_lock_file-disallow_builds"></a>disallow_builds | Do not allow pycross_wheel_build targets in the final lock file (i.e., require wheels). | Boolean | optional | `False` |
| <a id="pycross_lock_file-fully_qualified_environment_labels"></a>fully_qualified_environment_labels | Generate fully-qualified environment labels. | Boolean | optional | `True` |
| <a id="pycross_lock_file-generate_file_map"></a>generate_file_map | Generate a FILES dict containing a mapping of filenames to repo labels. | Boolean | optional | `False` |
Expand Down
8 changes: 8 additions & 0 deletions e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ lock_import.import_poetry(
# lock_repo with PDM and some package overrides
lock_import.import_pdm(
default_alias_single_version = True,
default_build_dependencies = [
"setuptools",
"wheel",
],
local_wheels = [
"//:cowsay-6.1-py3-none-any.whl",
],
Expand All @@ -93,6 +97,10 @@ lock_import.import_pdm(
# lock_repo with UV and some package overrides
lock_import.import_uv(
default_alias_single_version = True,
default_build_dependencies = [
"setuptools",
"wheel",
],
local_wheels = [
"//:cowsay-6.1-py3-none-any.whl",
],
Expand Down
Loading

0 comments on commit b1a8c1d

Please sign in to comment.