HomeDocs
DocsCommunityTestimonialsUsersGitHubTwitterBlogJobsTermsPrivacyCookies
TermsPrivacyCookies
Hey! These docs are for version 2.8, which is no longer officially supported. Click here for the latest version, 2.15!


Options controlling which dependencies will be inferred for Python targets.

Config section: <span style="color: purple"><code>[python-infer]</code></span>

## Basic options

<div style="color: purple"> <h3><code>imports</code></h3> <code>--[no-]python-infer-imports</code><br> <code>PANTS_PYTHON_INFER_IMPORTS</code><br> </div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>True</code></span>

<br>

Infer a target's imported dependencies by parsing import statements from sources.

</div> <br>

<div style="color: purple"> <h3><code>string_imports</code></h3> <code>--[no-]python-infer-string-imports</code><br> <code>PANTS_PYTHON_INFER_STRING_IMPORTS</code><br> </div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>False</code></span>

<br>

Infer a target's dependencies based on strings that look like dynamic dependencies, such as Django settings files expressing dependencies as strings. To ignore any false positives, put `!{bad_address}` in the `dependencies` field of your target.

</div> <br>

<div style="color: purple"> <h3><code>string_imports_min_dots</code></h3> <code>--python-infer-string-imports-min-dots=&lt;int&gt;</code><br> <code>PANTS_PYTHON_INFER_STRING_IMPORTS_MIN_DOTS</code><br> </div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>2</code></span>

<br>

If --string-imports is True, treat valid-looking strings with at least this many dots in them as potential dynamic dependencies. E.g., `'foo.bar.Baz'` will be treated as a potential dependency if this option is set to 2 but not if set to 3.

</div> <br>

<div style="color: purple"> <h3><code>inits</code></h3> <code>--[no-]python-infer-inits</code><br> <code>PANTS_PYTHON_INFER_INITS</code><br> </div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>False</code></span>

<br>

Infer a target's dependencies on any `__init__.py` files in the packages it is located in (recursively upward in the directory structure).

Even if this is disabled, Pants will still include any ancestor `__init__.py` files, only they will not be 'proper' dependencies, e.g. they will not show up in `./pants dependencies` and their own dependencies will not be used.

If you have empty `__init__.py` files, it's safe to leave this option off; otherwise, you should enable this option.

</div> <br>

<div style="color: purple"> <h3><code>conftests</code></h3> <code>--[no-]python-infer-conftests</code><br> <code>PANTS_PYTHON_INFER_CONFTESTS</code><br> </div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>True</code></span>

<br>

Infer a test target's dependencies on any conftest.py files in the current directory and ancestor directories.

</div> <br>

<div style="color: purple"> <h3><code>entry_points</code></h3> <code>--[no-]python-infer-entry-points</code><br> <code>PANTS_PYTHON_INFER_ENTRY_POINTS</code><br> </div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>True</code></span>

<br>

Infer dependencies on targets' entry points, e.g. `pex_binary`'s `entry_point` field, `python_awslambda`'s `handler` field and `python_distribution`'s `entry_points` field.

</div> <br>

## Advanced options

None

## Deprecated options

None