Skip to main content

python Submodule

Constructs

Pip

Manages dependencies using a requirements.txt file and the pip CLI tool.

Initializers

import { python } from 'projen'

new python.Pip(project: Project, _options?: PipOptions)
NameTypeDescription
project
projen.ProjectNo description.
_options
PipOptions
No description.

projectRequired
  • Type: projen.Project

_optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addDependency
Adds a runtime dependency.
addDevDependency
Adds a dev dependency.
installDependencies
Installs dependencies (called during post-synthesis).

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired
  • Type: string

Format <module>@<semver>.


addDevDependency
public addDevDependency(spec: string): void

Adds a dev dependency.

specRequired
  • Type: string

Format <module>@<semver>.


installDependencies
public installDependencies(): void

Installs dependencies (called during post-synthesis).

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.Pip.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.Pip.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
installCiTask
projen.TaskA task that installs and updates dependencies.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

installCiTaskRequired
public readonly installCiTask: Task;
  • Type: projen.Task

A task that installs and updates dependencies.


Poetry

Manage project dependencies, virtual environments, and packaging through the poetry CLI tool.

Initializers

import { python } from 'projen'

new python.Poetry(project: Project, options: PoetryOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
PoetryOptions
No description.

projectRequired
  • Type: projen.Project

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addDependency
Adds a runtime dependency.
addDevDependency
Adds a dev dependency.
installDependencies
Installs dependencies (called during post-synthesis).
setupEnvironment
Initializes the virtual environment if it doesn't exist (called during post-synthesis).

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired
  • Type: string

Format <module>@<semver>.


addDevDependency
public addDevDependency(spec: string): void

Adds a dev dependency.

specRequired
  • Type: string

Format <module>@<semver>.


installDependencies
public installDependencies(): void

Installs dependencies (called during post-synthesis).

setupEnvironment
public setupEnvironment(): void

Initializes the virtual environment if it doesn't exist (called during post-synthesis).

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.Poetry.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.Poetry.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
installCiTask
projen.TaskTask for installing dependencies according to the existing lockfile.
installTask
projen.TaskTask for updating the lockfile and installing project dependencies.
publishTask
projen.TaskTask for publishing the package to a package repository.
publishTestTask
projen.TaskTask for publishing the package to the Test PyPI repository for testing purposes.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

installCiTaskRequired
public readonly installCiTask: Task;
  • Type: projen.Task

Task for installing dependencies according to the existing lockfile.


installTaskRequired
public readonly installTask: Task;
  • Type: projen.Task

Task for updating the lockfile and installing project dependencies.


publishTaskRequired
public readonly publishTask: Task;
  • Type: projen.Task

Task for publishing the package to a package repository.


publishTestTaskRequired
public readonly publishTestTask: Task;
  • Type: projen.Task

Task for publishing the package to the Test PyPI repository for testing purposes.


PoetryPyproject

Represents configuration of a pyproject.toml file for a Poetry project.

https://python-poetry.org/docs/pyproject/

Initializers

import { python } from 'projen'

new python.PoetryPyproject(scope: IConstruct, options: PoetryPyprojectOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
options
PoetryPyprojectOptions
No description.

scopeRequired
  • Type: constructs.IConstruct

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.PoetryPyproject.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.PoetryPyproject.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
file
PyprojectTomlFile
No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

fileRequired
public readonly file: PyprojectTomlFile;

Projenrc

Allows writing projenrc files in python.

This will install projen as a Python dependency and will add a synth task which will run .projenrc.py.

Initializers

import { python } from 'projen'

new python.Projenrc(project: Project, options?: ProjenrcOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
ProjenrcOptions
No description.

projectRequired
  • Type: projen.Project

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.
of
Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

isConstruct
import { python } from 'projen'

python.Projenrc.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.Projenrc.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

of
import { python } from 'projen'

python.Projenrc.of(project: Project)

Returns the Projenrc instance associated with a project or undefined if there is no Projenrc.

projectRequired
  • Type: projen.Project

The project.


Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
filePath
stringThe name of the projenrc file.
pythonExec
stringPath to the python executable to use.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

filePathRequired
public readonly filePath: string;
  • Type: string

The name of the projenrc file.


pythonExecRequired
public readonly pythonExec: string;
  • Type: string

Path to the python executable to use.


PyprojectTomlFile

Represents configuration of a pyproject.toml file.

https://packaging.python.org/en/latest/guides/writing-pyproject-toml/

Initializers

import { python } from 'projen'

new python.PyprojectTomlFile(scope: IConstruct, config: PyprojectToml)
NameTypeDescription
scope
constructs.IConstructNo description.
config
PyprojectToml
No description.

scopeRequired
  • Type: constructs.IConstruct

configRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addDeletionOverride
Syntactic sugar for addOverride(path, undefined).
addOverride
Adds an override to the synthesized object file.
addToArray
Adds to an array in the synthesized object file.
patch
Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addDeletionOverride
public addDeletionOverride(path: string): void

Syntactic sugar for addOverride(path, undefined).

pathRequired
  • Type: string

The path of the value to delete.


addOverride
public addOverride(path: string, value: any): void

Adds an override to the synthesized object file.

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

project.tsconfig.file.addOverride('compilerOptions.alwaysStrict', true);
project.tsconfig.file.addOverride('compilerOptions.lib', ['dom', 'dom.iterable', 'esnext']);

would add the overrides

"compilerOptions": {
"alwaysStrict": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to override values in complex types.

Any intermediate keys will be created as needed.


valueRequired
  • Type: any

The value.

Could be primitive or complex.


addToArray
public addToArray(path: string, values: ...any[]): void

Adds to an array in the synthesized object file.

If the array is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2020"]
...
}
...
project.tsconfig.file.addToArray('compilerOptions.exclude', 'coverage');
project.tsconfig.file.addToArray('compilerOptions.lib', 'dom', 'dom.iterable', 'esnext');

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["es2020", "dom", "dom.iterable", "esnext"]
...
}
...
pathRequired
  • Type: string

The path of the property, you can use dot notation to att to arrays in complex types.

Any intermediate keys will be created as needed.


valuesRequired
  • Type: ...any[]

The values to add.

Could be primitive or complex.


patch
public patch(patches: ...JsonPatch[]): void

Applies an RFC 6902 JSON-patch to the synthesized object file. See https://datatracker.ietf.org/doc/html/rfc6902 for more information.

For example, with the following object file

"compilerOptions": {
"exclude": ["node_modules"],
"lib": ["es2020"]
...
}
...
project.tsconfig.file.patch(JsonPatch.add("/compilerOptions/exclude/-", "coverage"));
project.tsconfig.file.patch(JsonPatch.replace("/compilerOptions/lib", ["dom", "dom.iterable", "esnext"]));

would result in the following object file

"compilerOptions": {
"exclude": ["node_modules", "coverage"],
"lib": ["dom", "dom.iterable", "esnext"]
...
}
...
patchesRequired
  • Type: ...projen.JsonPatch[]

The patch operations to apply.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.PyprojectTomlFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.PyprojectTomlFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.
omitEmpty
booleanIndicates if empty objects and arrays are omitted from the output object.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


omitEmptyRequired
public readonly omitEmpty: boolean;
  • Type: boolean

Indicates if empty objects and arrays are omitted from the output object.


Pytest

Initializers

import { python } from 'projen'

new python.Pytest(project: Project, options?: PytestOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
PytestOptions
No description.

projectRequired
  • Type: projen.Project

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.Pytest.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.Pytest.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
testdir
stringNo description.
testMatch
string[]No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

testdirRequired
  • Deprecated: Use sampleTestdir on the project instead.
public readonly testdir: string;
  • Type: string

testMatchRequired
public readonly testMatch: string[];
  • Type: string[]

PytestSample

Python test code sample.

Initializers

import { python } from 'projen'

new python.PytestSample(project: Project, options: PytestSampleOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
PytestSampleOptions
No description.

projectRequired
  • Type: projen.Project

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.PytestSample.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.PytestSample.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

PythonProject

Python project.

Initializers

import { python } from 'projen'

new python.PythonProject(options: PythonProjectOptions)
NameTypeDescription
options
PythonProjectOptions
No description.

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
addExcludeFromCleanup
Exclude the matching files from pre-synth cleanup.
addGitIgnore
Adds a .gitignore pattern.
addPackageIgnore
Exclude these files from the bundled package.
addTask
Adds a new task to this project.
addTip
Prints a "tip" message during synthesis.
annotateGenerated
Marks the provided file(s) as being generated.
postSynthesize
Called after all components are synthesized.
preSynthesize
Called before all components are synthesized.
removeTask
Removes a task from a project.
runTaskCommand
Returns the shell command to execute in order to run a task.
synth
Synthesize all project files into outdir.
tryFindFile
Finds a file at the specified relative path within this project and all its subprojects.
tryFindJsonFile
Finds a json file by name.
tryFindObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
tryRemoveFile
Finds a file at the specified relative path within this project and removes it.
addDependency
Adds a runtime dependency.
addDevDependency
Adds a dev dependency.

toString
public toString(): string

Returns a string representation of this construct.

addExcludeFromCleanup
public addExcludeFromCleanup(globs: ...string[]): void

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: ...string[]

The glob patterns to match.


addGitIgnore
public addGitIgnore(pattern: string): void

Adds a .gitignore pattern.

patternRequired
  • Type: string

The glob pattern to ignore.


addPackageIgnore
public addPackageIgnore(_pattern: string): void

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: string

The glob pattern to exclude.


addTask
public addTask(name: string, props?: TaskOptions): Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: string

The task name to add.


propsOptional
  • Type: projen.TaskOptions

Task properties.


addTip
public addTip(message: string): void

Prints a "tip" message during synthesis.

messageRequired
  • Type: string

The message.


annotateGenerated
public annotateGenerated(glob: string): void

Marks the provided file(s) as being generated.

This is achieved using the github-linguist attributes. Generated files do not count against the repository statistics and language breakdown.

https://github.com/github/linguist/blob/master/docs/overrides.md

globRequired
  • Type: string

the glob pattern to match (could be a file path).


postSynthesize
public postSynthesize(): void

Called after all components are synthesized.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before all components are synthesized.

removeTask
public removeTask(name: string): Task

Removes a task from a project.

nameRequired
  • Type: string

The name of the task to remove.


runTaskCommand
public runTaskCommand(task: Task): string

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
public synth(): void

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
tryFindFile
public tryFindFile(filePath: string): FileBase

Finds a file at the specified relative path within this project and all its subprojects.

filePathRequired
  • Type: string

The file path.

If this path is relative, it will be resolved from the root of this project.


tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile

Finds a json file by name.

filePathRequired
  • Type: string

The file path.


tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

filePathRequired
  • Type: string

The file path.


tryRemoveFile
public tryRemoveFile(filePath: string): FileBase

Finds a file at the specified relative path within this project and removes it.

filePathRequired
  • Type: string

The file path.

If this path is relative, it will be resolved from the root of this project.


addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired
  • Type: string

Format <module>@<semver>.


addDevDependency
public addDevDependency(spec: string): void

Adds a dev dependency.

specRequired
  • Type: string

Format <module>@<semver>.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isProject
Test whether the given construct is a project.
of
Find the closest ancestor project for given construct.

isConstruct
import { python } from 'projen'

python.PythonProject.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isProject
import { python } from 'projen'

python.PythonProject.isProject(x: any)

Test whether the given construct is a project.

xRequired
  • Type: any

of
import { python } from 'projen'

python.PythonProject.of(construct: IConstruct)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
buildTask
projen.TaskNo description.
commitGenerated
booleanWhether to commit the managed files by default.
compileTask
projen.TaskNo description.
components
projen.Component[]Returns all the components within this project.
deps
projen.DependenciesProject dependencies.
ejected
booleanWhether or not the project is being ejected.
files
projen.FileBase[]All files in this project.
gitattributes
projen.GitAttributesFileThe .gitattributes file for this repository.
gitignore
projen.IgnoreFile.gitignore.
logger
projen.LoggerLogging utilities.
name
stringProject name.
outdir
stringAbsolute output directory of this project.
packageTask
projen.TaskNo description.
postCompileTask
projen.TaskNo description.
preCompileTask
projen.TaskNo description.
projectBuild
projen.ProjectBuildManages the build process of the project.
projenCommand
stringThe command to use in order to run the projen CLI.
root
projen.ProjectThe root project.
subprojects
projen.Project[]Returns all the subprojects within this project.
tasks
projen.TasksProject tasks.
testTask
projen.TaskNo description.
defaultTask
projen.TaskThis is the "default" task, the one that executes "projen".
initProject
projen.InitProjectThe options used when this project is bootstrapped via projen new.
parent
projen.ProjectA parent project.
projectType
projen.ProjectTypeNo description.
autoApprove
projen.github.AutoApproveAuto approve set up for this project.
devContainer
projen.vscode.DevContainerAccess for .devcontainer.json (used for GitHub Codespaces).
github
projen.github.GitHubAccess all github components.
gitpod
projen.GitpodAccess for Gitpod.
vscode
projen.vscode.VsCodeAccess all VSCode components.
depsManager
IPythonDeps
API for managing dependencies.
envManager
IPythonEnv
API for managing the Python runtime environment.
moduleName
stringPython module name (the project name, with any hyphens or periods replaced with underscores).
sampleTestdir
stringDirectory where sample tests are located.
version
stringVersion of the package for distribution (should follow semver).
packagingManager
IPythonPackaging
API for managing packaging the project as a library.
pytest
Pytest
Pytest component.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


buildTaskRequired
public readonly buildTask: Task;
  • Type: projen.Task

commitGeneratedRequired
public readonly commitGenerated: boolean;
  • Type: boolean

Whether to commit the managed files by default.


compileTaskRequired
public readonly compileTask: Task;
  • Type: projen.Task

componentsRequired
public readonly components: Component[];
  • Type: projen.Component[]

Returns all the components within this project.


depsRequired
public readonly deps: Dependencies;
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
public readonly ejected: boolean;
  • Type: boolean

Whether or not the project is being ejected.


filesRequired
public readonly files: FileBase[];
  • Type: projen.FileBase[]

All files in this project.


gitattributesRequired
public readonly gitattributes: GitAttributesFile;
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
public readonly gitignore: IgnoreFile;
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
public readonly logger: Logger;
  • Type: projen.Logger

Logging utilities.


nameRequired
public readonly name: string;
  • Type: string

Project name.


outdirRequired
public readonly outdir: string;
  • Type: string

Absolute output directory of this project.


packageTaskRequired
public readonly packageTask: Task;
  • Type: projen.Task

postCompileTaskRequired
public readonly postCompileTask: Task;
  • Type: projen.Task

preCompileTaskRequired
public readonly preCompileTask: Task;
  • Type: projen.Task

projectBuildRequired
public readonly projectBuild: ProjectBuild;
  • Type: projen.ProjectBuild

Manages the build process of the project.


projenCommandRequired
public readonly projenCommand: string;
  • Type: string

The command to use in order to run the projen CLI.


rootRequired
public readonly root: Project;
  • Type: projen.Project

The root project.


subprojectsRequired
public readonly subprojects: Project[];
  • Type: projen.Project[]

Returns all the subprojects within this project.


tasksRequired
public readonly tasks: Tasks;
  • Type: projen.Tasks

Project tasks.


testTaskRequired
public readonly testTask: Task;
  • Type: projen.Task

defaultTaskOptional
public readonly defaultTask: Task;
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


initProjectOptional
public readonly initProject: InitProject;
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
public readonly parent: Project;
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


projectTypeRequired
public readonly projectType: ProjectType;
  • Type: projen.ProjectType

autoApproveOptional
public readonly autoApprove: AutoApprove;
  • Type: projen.github.AutoApprove

Auto approve set up for this project.


devContainerOptional
public readonly devContainer: DevContainer;
  • Type: projen.vscode.DevContainer

Access for .devcontainer.json (used for GitHub Codespaces).

This will be undefined if devContainer boolean is false


githubOptional
public readonly github: GitHub;
  • Type: projen.github.GitHub

Access all github components.

This will be undefined for subprojects.


gitpodOptional
public readonly gitpod: Gitpod;
  • Type: projen.Gitpod

Access for Gitpod.

This will be undefined if gitpod boolean is false


vscodeOptional
public readonly vscode: VsCode;
  • Type: projen.vscode.VsCode

Access all VSCode components.

This will be undefined for subprojects.


depsManagerRequired
public readonly depsManager: IPythonDeps;

API for managing dependencies.


envManagerRequired
public readonly envManager: IPythonEnv;

API for managing the Python runtime environment.


moduleNameRequired
public readonly moduleName: string;
  • Type: string

Python module name (the project name, with any hyphens or periods replaced with underscores).


sampleTestdirRequired
public readonly sampleTestdir: string;
  • Type: string
  • Default: "tests"

Directory where sample tests are located.


versionRequired
public readonly version: string;
  • Type: string

Version of the package for distribution (should follow semver).


packagingManagerOptional
public readonly packagingManager: IPythonPackaging;

API for managing packaging the project as a library.

Only applies when the projectType is LIB.


pytestOptional
public readonly pytest: Pytest;

Pytest component.


Constants

NameTypeDescription
DEFAULT_TASK
stringThe name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
public readonly DEFAULT_TASK: string;
  • Type: string

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


PythonSample

Python code sample.

Initializers

import { python } from 'projen'

new python.PythonSample(project: Project, options: PythonSampleOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
PythonSampleOptions
No description.

projectRequired
  • Type: projen.Project

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.PythonSample.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.PythonSample.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

RequirementsFile

Specifies a list of packages to be installed using pip.

https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format

Initializers

import { python } from 'projen'

new python.RequirementsFile(project: Project, filePath: string, options: RequirementsFileOptions)
NameTypeDescription
project
projen.ProjectNo description.
filePath
stringNo description.
options
RequirementsFileOptions
No description.

projectRequired
  • Type: projen.Project

filePathRequired
  • Type: string

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.
addPackages
Adds the specified packages provided in semver format.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

addPackages
public addPackages(packages: ...string[]): void

Adds the specified packages provided in semver format.

Comment lines (start with #) are ignored.

packagesRequired
  • Type: ...string[]

Package version in format <module>@<semver>.


Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.RequirementsFile.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.RequirementsFile.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


SetupPy

Python packaging script where package metadata can be placed.

Initializers

import { python } from 'projen'

new python.SetupPy(project: Project, options: SetupPyOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
SetupPyOptions
No description.

projectRequired
  • Type: projen.Project

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Writes the file to the project's output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Writes the file to the project's output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.SetupPy.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.SetupPy.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
absolutePath
stringThe absolute path of this file.
path
stringThe file path, relative to the project's outdir.
changed
booleanIndicates if the file has been changed during synthesis.
marker
stringThe projen marker, used to identify files as projen-generated.
executable
booleanIndicates if the file should be marked as executable.
readonly
booleanIndicates if the file should be read-only or read-write.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

absolutePathRequired
public readonly absolutePath: string;
  • Type: string

The absolute path of this file.


pathRequired
public readonly path: string;
  • Type: string

The file path, relative to the project's outdir.


changedOptional
public readonly changed: boolean;
  • Type: boolean

Indicates if the file has been changed during synthesis.

This property is only available in postSynthesize() hooks. If this is undefined, the file has not been synthesized yet.


markerOptional
public readonly marker: string;
  • Type: string

The projen marker, used to identify files as projen-generated.

Value is undefined if the project is being ejected.


executableRequired
public readonly executable: boolean;
  • Type: boolean

Indicates if the file should be marked as executable.


readonlyRequired
public readonly readonly: boolean;
  • Type: boolean

Indicates if the file should be read-only or read-write.


Setuptools

Manages packaging through setuptools with a setup.py script.

Initializers

import { python } from 'projen'

new python.Setuptools(project: Project, options: SetuptoolsOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
SetuptoolsOptions
No description.

projectRequired
  • Type: projen.Project

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.Setuptools.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.Setuptools.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
publishTask
projen.TaskA task that uploads the package to a package repository.
publishTestTask
projen.TaskA task that uploads the package to the Test PyPI repository.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

publishTaskRequired
public readonly publishTask: Task;
  • Type: projen.Task

A task that uploads the package to a package repository.


publishTestTaskRequired
public readonly publishTestTask: Task;
  • Type: projen.Task

A task that uploads the package to the Test PyPI repository.


Uv

Manage project dependencies, virtual environments, and packaging through uv.

Initializers

import { python } from 'projen'

new python.Uv(scope: IConstruct, options: UvOptions)
NameTypeDescription
scope
constructs.IConstructNo description.
options
UvOptions
No description.

scopeRequired
  • Type: constructs.IConstruct

optionsRequired

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
addDependency
Adds a runtime dependency.
addDevDependency
Adds a dev dependency.
installDependencies
Installs dependencies (called during post-synthesis).
setupEnvironment
Initializes the virtual environment if it doesn't exist (called during post-synthesis).

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired
  • Type: string

addDevDependency
public addDevDependency(spec: string): void

Adds a dev dependency.

specRequired
  • Type: string

installDependencies
public installDependencies(): void

Installs dependencies (called during post-synthesis).

setupEnvironment
public setupEnvironment(): void

Initializes the virtual environment if it doesn't exist (called during post-synthesis).

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.Uv.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.Uv.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.
file
PyprojectTomlFile
The pyproject.toml file.
installCiTask
projen.TaskA task that installs and updates dependencies.
installTask
projen.TaskNo description.
publishTask
projen.TaskA task that uploads the package to a package repository.
publishTestTask
projen.TaskNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

fileRequired
public readonly file: PyprojectTomlFile;

The pyproject.toml file.


installCiTaskRequired
public readonly installCiTask: Task;
  • Type: projen.Task

A task that installs and updates dependencies.


installTaskRequired
public readonly installTask: Task;
  • Type: projen.Task

publishTaskRequired
public readonly publishTask: Task;
  • Type: projen.Task

A task that uploads the package to a package repository.


publishTestTaskRequired
public readonly publishTestTask: Task;
  • Type: projen.Task

Venv

Manages a virtual environment through the Python venv module.

Initializers

import { python } from 'projen'

new python.Venv(project: Project, options?: VenvOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
VenvOptions
No description.

projectRequired
  • Type: projen.Project

optionsOptional

Methods

NameDescription
toString
Returns a string representation of this construct.
postSynthesize
Called after synthesis.
preSynthesize
Called before synthesis.
synthesize
Synthesizes files to the project output directory.
setupEnvironment
Initializes the virtual environment if it doesn't exist (called during post-synthesis).

toString
public toString(): string

Returns a string representation of this construct.

postSynthesize
public postSynthesize(): void

Called after synthesis.

Order is not guaranteed.

preSynthesize
public preSynthesize(): void

Called before synthesis.

synthesize
public synthesize(): void

Synthesizes files to the project output directory.

setupEnvironment
public setupEnvironment(): void

Initializes the virtual environment if it doesn't exist (called during post-synthesis).

Static Functions

NameDescription
isConstruct
Checks if x is a construct.
isComponent
Test whether the given construct is a component.

isConstruct
import { python } from 'projen'

python.Venv.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


isComponent
import { python } from 'projen'

python.Venv.isComponent(x: any)

Test whether the given construct is a component.

xRequired
  • Type: any

Properties

NameTypeDescription
node
constructs.NodeThe tree node.
project
projen.ProjectNo description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


projectRequired
public readonly project: Project;
  • Type: projen.Project

Structs

BuildSystem

Declares any Python level dependencies that must be installed in order to run the project’s build system successfully.

Initializer

import { python } from 'projen'

const buildSystem: python.BuildSystem = { ... }

Properties

NameTypeDescription
requires
string[]List of strings following the version specifier specification, representing dependencies required to execute the build system.
backendPath
string[]list of directories to prepend to sys.path when loading the build backend, relative to project root.
buildBackend
stringString is formatted following the same module:object syntax as a setuptools entry point.

requiresRequired
public readonly requires: string[];
  • Type: string[]

List of strings following the version specifier specification, representing dependencies required to execute the build system.


backendPathOptional
public readonly backendPath: string[];
  • Type: string[]

list of directories to prepend to sys.path when loading the build backend, relative to project root.


buildBackendOptional
public readonly buildBackend: string;
  • Type: string

String is formatted following the same module:object syntax as a setuptools entry point.

It’s also legal to leave out the :object part.


PipOptions

Options for pip.

Initializer

import { python } from 'projen'

const pipOptions: python.PipOptions = { ... }

PoetryOptions

Initializer

import { python } from 'projen'

const poetryOptions: python.PoetryOptions = { ... }

Properties

NameTypeDescription
authorEmail
stringAuthor's e-mail.
authorName
stringAuthor's name.
version
stringVersion of the package.
classifiers
string[]A list of PyPI trove classifiers that describe the project.
description
stringA short description of the package.
homepage
stringA URL to the website of the project.
license
stringLicense of this package as an SPDX identifier.
packageName
stringPackage name.
poetryOptions
PoetryPyprojectOptionsWithoutDeps
Additional options to set for poetry if using poetry.
setupConfig
{[ key: string ]: any}Additional fields to pass in the setup() function if using setuptools.
uvOptions
UvOptions
Additional options to set for uv if using uv.
pythonExec
stringPath to the python executable to use.

authorEmailRequired
public readonly authorEmail: string;
  • Type: string
  • Default: $GIT_USER_EMAIL

Author's e-mail.


authorNameRequired
public readonly authorName: string;
  • Type: string
  • Default: $GIT_USER_NAME

Author's name.


versionRequired
public readonly version: string;
  • Type: string
  • Default: "0.1.0"

Version of the package.


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

A list of PyPI trove classifiers that describe the project.

https://pypi.org/classifiers/


descriptionOptional
public readonly description: string;
  • Type: string

A short description of the package.


homepageOptional
public readonly homepage: string;
  • Type: string

A URL to the website of the project.


licenseOptional
public readonly license: string;
  • Type: string

License of this package as an SPDX identifier.


packageNameOptional
public readonly packageName: string;
  • Type: string

Package name.


poetryOptionsOptional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;

Additional options to set for poetry if using poetry.


setupConfigOptional
public readonly setupConfig: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Additional fields to pass in the setup() function if using setuptools.


uvOptionsOptional
public readonly uvOptions: UvOptions;

Additional options to set for uv if using uv.


pythonExecOptional
public readonly pythonExec: string;
  • Type: string
  • Default: "python"

Path to the python executable to use.


PoetryPyprojectOptions

Poetry-specific options.

https://python-poetry.org/docs/pyproject/

Initializer

import { python } from 'projen'

const poetryPyprojectOptions: python.PoetryPyprojectOptions = { ... }

Properties

NameTypeDescription
authors
string[]The authors of the package.
classifiers
string[]A list of PyPI trove classifiers that describe the project.
description
stringA short description of the package (required).
documentation
stringA URL to the documentation of the project.
exclude
string[]A list of patterns that will be excluded in the final package.
extras
{[ key: string ]: string[]}Package extras.
homepage
stringA URL to the website of the project.
include
string[]A list of patterns that will be included in the final package.
keywords
string[]A list of keywords (max: 5) that the package is related to.
license
stringLicense of this package as an SPDX identifier.
maintainers
string[]the maintainers of the package.
name
stringName of the package (required).
packageMode
booleanPackage mode (optional).
packages
any[]A list of packages and modules to include in the final distribution.
plugins
anyPlugins.
readme
stringThe name of the readme file of the package.
repository
stringA URL to the repository of the project.
scripts
{[ key: string ]: any}The scripts or executables that will be installed when installing the package.
source
any[]Source registries from which packages are retrieved.
urls
{[ key: string ]: string}Project custom URLs, in addition to homepage, repository and documentation.
version
stringVersion of the package (required).
dependencies
{[ key: string ]: any}A list of dependencies for the project.
devDependencies
{[ key: string ]: any}A list of development dependencies for the project.

authorsOptional
public readonly authors: string[];
  • Type: string[]

The authors of the package.

Must be in the form "name "


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

A list of PyPI trove classifiers that describe the project.

https://pypi.org/classifiers/


descriptionOptional
public readonly description: string;
  • Type: string

A short description of the package (required).


documentationOptional
public readonly documentation: string;
  • Type: string

A URL to the documentation of the project.


excludeOptional
public readonly exclude: string[];
  • Type: string[]

A list of patterns that will be excluded in the final package.

If a VCS is being used for a package, the exclude field will be seeded with the VCS’ ignore settings (.gitignore for git for example).


extrasOptional
public readonly extras: {[ key: string ]: string[]};
  • Type: {[ key: string ]: string[]}

Package extras.


homepageOptional
public readonly homepage: string;
  • Type: string

A URL to the website of the project.


includeOptional
public readonly include: string[];
  • Type: string[]

A list of patterns that will be included in the final package.


keywordsOptional
public readonly keywords: string[];
  • Type: string[]

A list of keywords (max: 5) that the package is related to.


licenseOptional
public readonly license: string;
  • Type: string

License of this package as an SPDX identifier.

If the project is proprietary and does not use a specific license, you can set this value as "Proprietary".


maintainersOptional
public readonly maintainers: string[];
  • Type: string[]

the maintainers of the package.

Must be in the form "name "


nameOptional
public readonly name: string;
  • Type: string

Name of the package (required).


packageModeOptional
public readonly packageMode: boolean;
  • Type: boolean
  • Default: true

Package mode (optional).

https://python-poetry.org/docs/pyproject/#package-mode


Example

false
packagesOptional
public readonly packages: any[];
  • Type: any[]

A list of packages and modules to include in the final distribution.


pluginsOptional
public readonly plugins: any;
  • Type: any

Plugins.

Must be specified as a table.

https://toml.io/en/v1.0.0#table


readmeOptional
public readonly readme: string;
  • Type: string

The name of the readme file of the package.


repositoryOptional
public readonly repository: string;
  • Type: string

A URL to the repository of the project.


scriptsOptional
public readonly scripts: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

The scripts or executables that will be installed when installing the package.


sourceOptional
public readonly source: any[];
  • Type: any[]

Source registries from which packages are retrieved.


urlsOptional
public readonly urls: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Project custom URLs, in addition to homepage, repository and documentation.

E.g. "Bug Tracker"


versionOptional
public readonly version: string;
  • Type: string

Version of the package (required).


dependenciesOptional
public readonly dependencies: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

A list of dependencies for the project.

The python version for which your package is compatible is also required.


Example

{ requests: "^2.13.0" }
devDependenciesOptional
public readonly devDependencies: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

A list of development dependencies for the project.


Example

{ requests: "^2.13.0" }

PoetryPyprojectOptionsWithoutDeps

Poetry-specific options.

https://python-poetry.org/docs/pyproject/

Initializer

import { python } from 'projen'

const poetryPyprojectOptionsWithoutDeps: python.PoetryPyprojectOptionsWithoutDeps = { ... }

Properties

NameTypeDescription
authors
string[]The authors of the package.
classifiers
string[]A list of PyPI trove classifiers that describe the project.
description
stringA short description of the package (required).
documentation
stringA URL to the documentation of the project.
exclude
string[]A list of patterns that will be excluded in the final package.
extras
{[ key: string ]: string[]}Package extras.
homepage
stringA URL to the website of the project.
include
string[]A list of patterns that will be included in the final package.
keywords
string[]A list of keywords (max: 5) that the package is related to.
license
stringLicense of this package as an SPDX identifier.
maintainers
string[]the maintainers of the package.
name
stringName of the package (required).
packageMode
booleanPackage mode (optional).
packages
any[]A list of packages and modules to include in the final distribution.
plugins
anyPlugins.
readme
stringThe name of the readme file of the package.
repository
stringA URL to the repository of the project.
scripts
{[ key: string ]: any}The scripts or executables that will be installed when installing the package.
source
any[]Source registries from which packages are retrieved.
urls
{[ key: string ]: string}Project custom URLs, in addition to homepage, repository and documentation.
version
stringVersion of the package (required).

authorsOptional
public readonly authors: string[];
  • Type: string[]

The authors of the package.

Must be in the form "name "


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

A list of PyPI trove classifiers that describe the project.

https://pypi.org/classifiers/


descriptionOptional
public readonly description: string;
  • Type: string

A short description of the package (required).


documentationOptional
public readonly documentation: string;
  • Type: string

A URL to the documentation of the project.


excludeOptional
public readonly exclude: string[];
  • Type: string[]

A list of patterns that will be excluded in the final package.

If a VCS is being used for a package, the exclude field will be seeded with the VCS’ ignore settings (.gitignore for git for example).


extrasOptional
public readonly extras: {[ key: string ]: string[]};
  • Type: {[ key: string ]: string[]}

Package extras.


homepageOptional
public readonly homepage: string;
  • Type: string

A URL to the website of the project.


includeOptional
public readonly include: string[];
  • Type: string[]

A list of patterns that will be included in the final package.


keywordsOptional
public readonly keywords: string[];
  • Type: string[]

A list of keywords (max: 5) that the package is related to.


licenseOptional
public readonly license: string;
  • Type: string

License of this package as an SPDX identifier.

If the project is proprietary and does not use a specific license, you can set this value as "Proprietary".


maintainersOptional
public readonly maintainers: string[];
  • Type: string[]

the maintainers of the package.

Must be in the form "name "


nameOptional
public readonly name: string;
  • Type: string

Name of the package (required).


packageModeOptional
public readonly packageMode: boolean;
  • Type: boolean
  • Default: true

Package mode (optional).

https://python-poetry.org/docs/pyproject/#package-mode


Example

false
packagesOptional
public readonly packages: any[];
  • Type: any[]

A list of packages and modules to include in the final distribution.


pluginsOptional
public readonly plugins: any;
  • Type: any

Plugins.

Must be specified as a table.

https://toml.io/en/v1.0.0#table


readmeOptional
public readonly readme: string;
  • Type: string

The name of the readme file of the package.


repositoryOptional
public readonly repository: string;
  • Type: string

A URL to the repository of the project.


scriptsOptional
public readonly scripts: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

The scripts or executables that will be installed when installing the package.


sourceOptional
public readonly source: any[];
  • Type: any[]

Source registries from which packages are retrieved.


urlsOptional
public readonly urls: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Project custom URLs, in addition to homepage, repository and documentation.

E.g. "Bug Tracker"


versionOptional
public readonly version: string;
  • Type: string

Version of the package (required).


ProjectAuthor

Initializer

import { python } from 'projen'

const projectAuthor: python.ProjectAuthor = { ... }

Properties

NameTypeDescription
email
stringNo description.
name
stringNo description.

emailOptional
public readonly email: string;
  • Type: string

nameOptional
public readonly name: string;
  • Type: string

ProjenrcOptions

Options for Projenrc.

Initializer

import { python } from 'projen'

const projenrcOptions: python.ProjenrcOptions = { ... }

Properties

NameTypeDescription
filename
stringThe name of the projenrc file.
projenVersion
stringThe projen version to use.
pythonExec
stringPath to the python executable to use.

filenameOptional
public readonly filename: string;
  • Type: string
  • Default: ".projenrc.py"

The name of the projenrc file.


projenVersionOptional
public readonly projenVersion: string;
  • Type: string
  • Default: current version

The projen version to use.


pythonExecOptional
public readonly pythonExec: string;
  • Type: string
  • Default: "python"

Path to the python executable to use.


PyprojectToml

Initializer

import { python } from 'projen'

const pyprojectToml: python.PyprojectToml = { ... }

Properties

NameTypeDescription
buildSystem
BuildSystem
No description.
dependencyGroups
PyprojectTomlDependencyGroups
Named groups of dependencies, similar to requirements.txt files, which launchers, IDEs, and other tools can find and identify by name. Each item in [dependency-groups] is defined as mapping of group name to list of dependency specifiers.
project
PyprojectTomlProject
There are two kinds of metadata: static and dynamic.
tool
PyprojectTomlTool
Every tool that is used by the project can have users specify configuration data as long as they use a sub-table within [tool].

buildSystemOptional
public readonly buildSystem: BuildSystem;

dependencyGroupsOptional
public readonly dependencyGroups: PyprojectTomlDependencyGroups;

Named groups of dependencies, similar to requirements.txt files, which launchers, IDEs, and other tools can find and identify by name. Each item in [dependency-groups] is defined as mapping of group name to list of dependency specifiers.


projectOptional
public readonly project: PyprojectTomlProject;

There are two kinds of metadata: static and dynamic.

Static metadata is listed in the [project] table directly and cannot be specified or changed by a tool.

  • Dynamic metadata key names are listed inside the dynamic key and represents metadata that a tool will later provide.

toolOptional
public readonly tool: PyprojectTomlTool;

Every tool that is used by the project can have users specify configuration data as long as they use a sub-table within [tool].

Generally a project can use the subtable tool.$NAME if, and only if, they own the entry for $NAME in the Cheeseshop/PyPI.


PyprojectTomlDependencyGroups

Named groups of dependencies, similar to requirements.txt files, which launchers, IDEs, and other tools can find and identify by name. Each item in [dependency-groups] is defined as mapping of group name to list of dependency specifiers.

Initializer

import { python } from 'projen'

const pyprojectTomlDependencyGroups: python.PyprojectTomlDependencyGroups = { ... }

Properties

NameTypeDescription
dev
any[]No description.

devOptional
public readonly dev: any[];
  • Type: any[]

PyprojectTomlProject

There are two kinds of metadata: static and dynamic.

Static metadata is listed in the [project] table directly and cannot be specified or changed by a tool.

  • Dynamic metadata key names are listed inside the dynamic key and represents metadata that a tool will later provide.

Initializer

import { python } from 'projen'

const pyprojectTomlProject: python.PyprojectTomlProject = { ... }

Properties

NameTypeDescription
name
stringValid name consists only of ASCII letters and numbers, period, underscore and hyphen.
authors
ProjectAuthor[]
People or organizations considered as 'authors' of the project.
classifiers
string[]List of Trove classifiers that describe the project. PyPI use the classifiers to categorize projects.
dependencies
string[]An array of dependency specifier strings, each representing a mandatory dependent package of the project.
description
stringSummary description of the project in one line.
dynamic
PyprojectTomlProjectDynamic[]
Specifies which keys are intentionally unspecified under [project] table so build backend can/will provide such metadata dynamically.
entryPoints
anyExtra entry point groups that allow applications to load plugins. For example, Pygments (a syntax highlighting tool) can use additional styles from separately installed packages through [project.entry-points."pygments.styles"]. Each key is the name of the entry-point group, and each value is a table of entry points.
guiScripts
{[ key: string ]: string}Table of entry points that allows package installers to create a GUI wrapper for. Each key is the name of the script to be created, and each value is the function or object to all, in form of either importable.module or importable.module:object.attr. Windows platform treats gui_scripts specially in that they are wrapped in a GUI executable, so they can be started without a console, but cannot use standard streams unless application code redirects them.
importNames
string[]An array of strings specifying the import names that the project exclusively provides when installed.
importNamespaces
string[]An array of strings specifying the import names that the project provides when installed, but not exclusively.
keywords
string[]List of keywords or tags that describe the project.
license
anyFor now it is a table with either: - file key specifying a relative path to a license file, or - text key containing full license content.
licenseFiles
string[]Relative paths or globs to paths of license files.
maintainers
ProjectAuthor[]
People or organizations considered as 'maintainers' of the project.
optionalDependencies
anyEach entry is a key/value pair, with the key specifying extra feature name (such as socks in requests[socks]), and value is an array of dependency specifier strings.
readme
anyValue can be a relative path to text / markdown (.md suffix) / reStructuredText (.rst suffix) readme file, or a table with either: - file key containing path of aforementioned readme file, or - text key containing the full readme text embedded inside pyproject.toml.
requiresPython
stringSpecifies the Python version(s) that the distribution is compatible with.
scripts
{[ key: string ]: string}Table of entry points that allows package installers to create a command-line wrapper for. Each key is the name of the script to be created, and each value is the function or object to all, in form of either importable.module or importable.module:object.attr. Windows platform treats console_scripts specially in that they are wrapped in a console executable, so they are attached to a console and can use sys.stdin, sys.stdout and sys.stderr for I/O.
urls
{[ key: string ]: string}Table consisting one or multiple label: URL pairs.
version
stringVersion of the project, as defined in the Version specifier specification, and preferably already normalized.

nameRequired
public readonly name: string;
  • Type: string

Valid name consists only of ASCII letters and numbers, period, underscore and hyphen.

It must start and end with a letter or number.


authorsOptional
public readonly authors: ProjectAuthor[];

People or organizations considered as 'authors' of the project.

Each author is a table with name key, email key, or both.


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

List of Trove classifiers that describe the project. PyPI use the classifiers to categorize projects.


dependenciesOptional
public readonly dependencies: string[];
  • Type: string[]

An array of dependency specifier strings, each representing a mandatory dependent package of the project.


descriptionOptional
public readonly description: string;
  • Type: string

Summary description of the project in one line.

Tools may not accept multiple lines.


dynamicOptional
public readonly dynamic: PyprojectTomlProjectDynamic[];

Specifies which keys are intentionally unspecified under [project] table so build backend can/will provide such metadata dynamically.

Each key must be listed only once. It is an error to both list a key in dynamic and use the key directly in [project]. One of the most common usage is version, which allows build backend to retrieve project version from source code or version control system instead of hardcoding it in pyproject.toml.


entryPointsOptional
public readonly entryPoints: any;
  • Type: any

Extra entry point groups that allow applications to load plugins. For example, Pygments (a syntax highlighting tool) can use additional styles from separately installed packages through [project.entry-points."pygments.styles"]. Each key is the name of the entry-point group, and each value is a table of entry points.


guiScriptsOptional
public readonly guiScripts: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Table of entry points that allows package installers to create a GUI wrapper for. Each key is the name of the script to be created, and each value is the function or object to all, in form of either importable.module or importable.module:object.attr. Windows platform treats gui_scripts specially in that they are wrapped in a GUI executable, so they can be started without a console, but cannot use standard streams unless application code redirects them.


importNamesOptional
public readonly importNames: string[];
  • Type: string[]

An array of strings specifying the import names that the project exclusively provides when installed.


importNamespacesOptional
public readonly importNamespaces: string[];
  • Type: string[]

An array of strings specifying the import names that the project provides when installed, but not exclusively.


keywordsOptional
public readonly keywords: string[];
  • Type: string[]

List of keywords or tags that describe the project.

They could be used by search engines to categorize the project.


licenseOptional
public readonly license: any;
  • Type: any

For now it is a table with either: - file key specifying a relative path to a license file, or - text key containing full license content.

Newer tool may accept a single SPDX license expression string instead of a table.


licenseFilesOptional
public readonly licenseFiles: string[];
  • Type: string[]

Relative paths or globs to paths of license files.

Can be an empty list.


maintainersOptional
public readonly maintainers: ProjectAuthor[];

People or organizations considered as 'maintainers' of the project.

Each maintainer is a table with name key, email key, or both.


optionalDependenciesOptional
public readonly optionalDependencies: any;
  • Type: any

Each entry is a key/value pair, with the key specifying extra feature name (such as socks in requests[socks]), and value is an array of dependency specifier strings.


readmeOptional
public readonly readme: any;
  • Type: any

Value can be a relative path to text / markdown (.md suffix) / reStructuredText (.rst suffix) readme file, or a table with either: - file key containing path of aforementioned readme file, or - text key containing the full readme text embedded inside pyproject.toml.


requiresPythonOptional
public readonly requiresPython: string;
  • Type: string

Specifies the Python version(s) that the distribution is compatible with.

Must be in the format specified in Version specifiers.


scriptsOptional
public readonly scripts: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Table of entry points that allows package installers to create a command-line wrapper for. Each key is the name of the script to be created, and each value is the function or object to all, in form of either importable.module or importable.module:object.attr. Windows platform treats console_scripts specially in that they are wrapped in a console executable, so they are attached to a console and can use sys.stdin, sys.stdout and sys.stderr for I/O.


urlsOptional
public readonly urls: {[ key: string ]: string};
  • Type: {[ key: string ]: string}

Table consisting one or multiple label: URL pairs.

Common indexes like PyPI uses well-known Project URLs when presenting project pages.


versionOptional
public readonly version: string;
  • Type: string

Version of the project, as defined in the Version specifier specification, and preferably already normalized.


PyprojectTomlTool

Every tool that is used by the project can have users specify configuration data as long as they use a sub-table within [tool].

Generally a project can use the subtable tool.$NAME if, and only if, they own the entry for $NAME in the Cheeseshop/PyPI.

Initializer

import { python } from 'projen'

const pyprojectTomlTool: python.PyprojectTomlTool = { ... }

Properties

NameTypeDescription
black
anyThe uncompromising Python code formatter.
cibuildwheel
anyBuild Python wheels for all platforms.
hatch
anyModern, extensible Python project management.
maturin
anyBuild and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages.
mypy
anyOptional static typing for Python.
pdm
anyA modern Python package manager with PEP 621 support.
poe
anyA task runner that works well with pyproject.toml files.
poetry
anyPython dependency management and packaging made easy.
pyright
anyStatic type checker for Python.
pytest
anyStandardized automated testing of Python packages.
repoReview
anyReview a repository for best practices.
ruff
anyAn extremely fast Python linter and formatter, written in Rust.
scikitBuild
anyImproved build system generator for Python C/C++/Fortran extensions.
setuptools
anyEasily download, build, install, upgrade, and uninstall Python packages.
setuptoolsScm
anyManage Python package versions using SCM (e.g. Git).
taskipy
anyThe complementary task runner for python.
tombi
anyTombi is a toolkit for TOML;
tox
anyStandardized automated testing of Python packages.
ty
anyAn extremely fast Python type checker, written in Rust.
uv
anyAn extremely fast Python package installer and resolver, written in Rust.

blackOptional
public readonly black: any;
  • Type: any

The uncompromising Python code formatter.


cibuildwheelOptional
public readonly cibuildwheel: any;
  • Type: any

Build Python wheels for all platforms.


hatchOptional
public readonly hatch: any;
  • Type: any

Modern, extensible Python project management.


maturinOptional
public readonly maturin: any;
  • Type: any

Build and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages.


mypyOptional
public readonly mypy: any;
  • Type: any

Optional static typing for Python.


pdmOptional
public readonly pdm: any;
  • Type: any

A modern Python package manager with PEP 621 support.


poeOptional
public readonly poe: any;
  • Type: any

A task runner that works well with pyproject.toml files.


poetryOptional
public readonly poetry: any;
  • Type: any

Python dependency management and packaging made easy.


pyrightOptional
public readonly pyright: any;
  • Type: any

Static type checker for Python.


pytestOptional
public readonly pytest: any;
  • Type: any

Standardized automated testing of Python packages.


repoReviewOptional
public readonly repoReview: any;
  • Type: any

Review a repository for best practices.


ruffOptional
public readonly ruff: any;
  • Type: any

An extremely fast Python linter and formatter, written in Rust.


scikitBuildOptional
public readonly scikitBuild: any;
  • Type: any

Improved build system generator for Python C/C++/Fortran extensions.


setuptoolsOptional
public readonly setuptools: any;
  • Type: any

Easily download, build, install, upgrade, and uninstall Python packages.


setuptoolsScmOptional
public readonly setuptoolsScm: any;
  • Type: any

Manage Python package versions using SCM (e.g. Git).


taskipyOptional
public readonly taskipy: any;
  • Type: any

The complementary task runner for python.


tombiOptional
public readonly tombi: any;
  • Type: any

Tombi is a toolkit for TOML;

providing a formatter/linter and language server


toxOptional
public readonly tox: any;
  • Type: any

Standardized automated testing of Python packages.


tyOptional
public readonly ty: any;
  • Type: any

An extremely fast Python type checker, written in Rust.


uvOptional
public readonly uv: any;
  • Type: any

An extremely fast Python package installer and resolver, written in Rust.


PytestOptions

Initializer

import { python } from 'projen'

const pytestOptions: python.PytestOptions = { ... }

Properties

NameTypeDescription
maxFailures
numberStop the testing process after the first N failures.
testdir
stringLocation of sample tests.
testMatch
string[]List of paths to test files or directories.
version
stringPytest version.

maxFailuresOptional
public readonly maxFailures: number;
  • Type: number

Stop the testing process after the first N failures.


testdirOptional
  • Deprecated: Reference sampleTestdir on the project instead; to change the directory where tests are discovered from, use testMatch.
public readonly testdir: string;
  • Type: string
  • Default: "tests"

Location of sample tests.

Typically the same directory where project tests will be located.


testMatchOptional
public readonly testMatch: string[];
  • Type: string[]
  • Default: []

List of paths to test files or directories.

Useful when all project tests are in a known location to speed up test collection and to avoid picking up undesired tests by accident.

Leave empty to discover all test_*.py or *_test.py files, per Pytest default.

The array will be concatenated and passed as a single argument to pytest.


Example

["tests/unit", "tests/qa"]
versionOptional
public readonly version: string;
  • Type: string
  • Default: "7.4.3"

Pytest version.


PytestSampleOptions

Options for python test code sample.

Initializer

import { python } from 'projen'

const pytestSampleOptions: python.PytestSampleOptions = { ... }

Properties

NameTypeDescription
moduleName
stringName of the python package as used in imports and filenames.
testdir
stringTest directory.

moduleNameRequired
public readonly moduleName: string;
  • Type: string

Name of the python package as used in imports and filenames.


testdirRequired
public readonly testdir: string;
  • Type: string

Test directory.


PythonExecutableOptions

Initializer

import { python } from 'projen'

const pythonExecutableOptions: python.PythonExecutableOptions = { ... }

Properties

NameTypeDescription
pythonExec
stringPath to the python executable to use.

pythonExecOptional
public readonly pythonExec: string;
  • Type: string
  • Default: "python"

Path to the python executable to use.


PythonPackagingOptions

Initializer

import { python } from 'projen'

const pythonPackagingOptions: python.PythonPackagingOptions = { ... }

Properties

NameTypeDescription
authorEmail
stringAuthor's e-mail.
authorName
stringAuthor's name.
version
stringVersion of the package.
classifiers
string[]A list of PyPI trove classifiers that describe the project.
description
stringA short description of the package.
homepage
stringA URL to the website of the project.
license
stringLicense of this package as an SPDX identifier.
packageName
stringPackage name.
poetryOptions
PoetryPyprojectOptionsWithoutDeps
Additional options to set for poetry if using poetry.
setupConfig
{[ key: string ]: any}Additional fields to pass in the setup() function if using setuptools.
uvOptions
UvOptions
Additional options to set for uv if using uv.

authorEmailRequired
public readonly authorEmail: string;
  • Type: string
  • Default: $GIT_USER_EMAIL

Author's e-mail.


authorNameRequired
public readonly authorName: string;
  • Type: string
  • Default: $GIT_USER_NAME

Author's name.


versionRequired
public readonly version: string;
  • Type: string
  • Default: "0.1.0"

Version of the package.


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

A list of PyPI trove classifiers that describe the project.

https://pypi.org/classifiers/


descriptionOptional
public readonly description: string;
  • Type: string

A short description of the package.


homepageOptional
public readonly homepage: string;
  • Type: string

A URL to the website of the project.


licenseOptional
public readonly license: string;
  • Type: string

License of this package as an SPDX identifier.


packageNameOptional
public readonly packageName: string;
  • Type: string

Package name.


poetryOptionsOptional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;

Additional options to set for poetry if using poetry.


setupConfigOptional
public readonly setupConfig: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Additional fields to pass in the setup() function if using setuptools.


uvOptionsOptional
public readonly uvOptions: UvOptions;

Additional options to set for uv if using uv.


PythonProjectOptions

Options for PythonProject.

Initializer

import { python } from 'projen'

const pythonProjectOptions: python.PythonProjectOptions = { ... }

Properties

NameTypeDescription
name
stringThis is the name of your project.
commitGenerated
booleanWhether to commit the managed files by default.
gitIgnoreOptions
projen.IgnoreFileOptionsConfiguration options for .gitignore file.
gitOptions
projen.GitOptionsConfiguration options for git.
logging
projen.LoggerOptionsConfigure logging options such as verbosity.
outdir
stringThe root directory of the project.
parent
projen.ProjectThe parent project, if this project is part of a bigger project.
projenCommand
stringThe shell command to use in order to run the projen CLI.
projenrcJson
booleanGenerate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrcJsonOptions
projen.ProjenrcJsonOptionsOptions for .projenrc.json.
renovatebot
booleanUse renovatebot to handle dependency upgrades.
renovatebotOptions
projen.RenovatebotOptionsOptions for renovatebot.
autoApproveOptions
projen.github.AutoApproveOptionsEnable and configure the 'auto approve' workflow.
autoMerge
booleanEnable automatic merging on GitHub.
autoMergeOptions
projen.github.AutoMergeOptionsConfigure options for automatic merging on GitHub.
clobber
booleanAdd a clobber task which resets the repo to origin.
devContainer
booleanAdd a VSCode development environment (used for GitHub Codespaces).
github
booleanEnable GitHub integration.
githubOptions
projen.github.GitHubOptionsOptions for GitHub integration.
gitpod
booleanAdd a Gitpod development environment.
mergify
booleanWhether mergify should be enabled on this repository or not.
mergifyOptions
projen.github.MergifyOptionsOptions for mergify.
projectType
projen.ProjectTypeWhich type of project this is (library/app).
projenCredentials
projen.github.GithubCredentialsChoose a method of providing GitHub API access for projen workflows.
projenTokenSecret
stringThe name of a secret which includes a GitHub Personal Access Token to be used by projen workflows.
readme
projen.SampleReadmePropsThe README setup.
stale
booleanAuto-close of stale issues and pull request.
staleOptions
projen.github.StaleOptionsAuto-close stale issues and pull requests.
vscode
booleanEnable VSCode integration.
authorEmail
stringAuthor's e-mail.
authorName
stringAuthor's name.
version
stringVersion of the package.
classifiers
string[]A list of PyPI trove classifiers that describe the project.
description
stringA short description of the package.
homepage
stringA URL to the website of the project.
license
stringLicense of this package as an SPDX identifier.
packageName
stringPackage name.
poetryOptions
PoetryPyprojectOptionsWithoutDeps
Additional options to set for poetry if using poetry.
setupConfig
{[ key: string ]: any}Additional fields to pass in the setup() function if using setuptools.
uvOptions
UvOptions
Additional options to set for uv if using uv.
pythonExec
stringPath to the python executable to use.
moduleName
stringName of the python package as used in imports and filenames.
deps
string[]List of runtime dependencies for this project.
devDeps
string[]List of dev dependencies for this project.
pip
booleanUse pip with a requirements.txt file to track project dependencies.
poetry
booleanUse poetry to manage your project dependencies, virtual environment, and (optional) packaging/publishing.
projenrcJs
booleanUse projenrc in javascript.
projenrcJsOptions
projen.javascript.ProjenrcOptionsOptions related to projenrc in JavaScript.
projenrcPython
booleanUse projenrc in Python.
projenrcPythonOptions
ProjenrcOptions
Options related to projenrc in python.
projenrcTs
booleanUse projenrc in TypeScript.
projenrcTsOptions
projen.typescript.ProjenrcTsOptionsOptions related to projenrc in TypeScript.
pytest
booleanInclude pytest tests.
pytestOptions
PytestOptions
pytest options.
sample
booleanInclude sample code and test if the relevant directories don't exist.
sampleTestdir
stringLocation of sample tests.
setuptools
booleanUse setuptools with a setup.py script for packaging and publishing.
uv
booleanUse uv to manage your project dependencies, virtual environment, and (optional) packaging/publishing.
venv
booleanUse venv to manage a virtual environment for installing dependencies inside.
venvOptions
VenvOptions
Venv options.

nameRequired
public readonly name: string;
  • Type: string
  • Default: $BASEDIR

This is the name of your project.


commitGeneratedOptional
public readonly commitGenerated: boolean;
  • Type: boolean
  • Default: true

Whether to commit the managed files by default.


gitIgnoreOptionsOptional
public readonly gitIgnoreOptions: IgnoreFileOptions;
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


gitOptionsOptional
public readonly gitOptions: GitOptions;
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
public readonly logging: LoggerOptions;
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
public readonly outdir: string;
  • Type: string
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
public readonly parent: Project;
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projenCommandOptional
public readonly projenCommand: string;
  • Type: string
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrcJsonOptional
public readonly projenrcJson: boolean;
  • Type: boolean
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrcJsonOptionsOptional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
public readonly renovatebot: boolean;
  • Type: boolean
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebotOptionsOptional
public readonly renovatebotOptions: RenovatebotOptions;
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


autoApproveOptionsOptional
public readonly autoApproveOptions: AutoApproveOptions;
  • Type: projen.github.AutoApproveOptions
  • Default: auto approve is disabled

Enable and configure the 'auto approve' workflow.


autoMergeOptional
public readonly autoMerge: boolean;
  • Type: boolean
  • Default: true

Enable automatic merging on GitHub.

Has no effect if github.mergify is set to false.


autoMergeOptionsOptional
public readonly autoMergeOptions: AutoMergeOptions;
  • Type: projen.github.AutoMergeOptions
  • Default: see defaults in AutoMergeOptions

Configure options for automatic merging on GitHub.

Has no effect if github.mergify or autoMerge is set to false.


clobberOptional
public readonly clobber: boolean;
  • Type: boolean
  • Default: true, but false for subprojects

Add a clobber task which resets the repo to origin.


devContainerOptional
public readonly devContainer: boolean;
  • Type: boolean
  • Default: false

Add a VSCode development environment (used for GitHub Codespaces).


githubOptional
public readonly github: boolean;
  • Type: boolean
  • Default: true

Enable GitHub integration.

Enabled by default for root projects. Disabled for non-root projects.


githubOptionsOptional
public readonly githubOptions: GitHubOptions;
  • Type: projen.github.GitHubOptions
  • Default: see GitHubOptions

Options for GitHub integration.


gitpodOptional
public readonly gitpod: boolean;
  • Type: boolean
  • Default: false

Add a Gitpod development environment.


mergifyOptional
  • Deprecated: use githubOptions.mergify instead
public readonly mergify: boolean;
  • Type: boolean
  • Default: true

Whether mergify should be enabled on this repository or not.


mergifyOptionsOptional
  • Deprecated: use githubOptions.mergifyOptions instead
public readonly mergifyOptions: MergifyOptions;
  • Type: projen.github.MergifyOptions
  • Default: default options

Options for mergify.


projectTypeOptional
  • Deprecated: no longer supported at the base project level
public readonly projectType: ProjectType;
  • Type: projen.ProjectType
  • Default: ProjectType.UNKNOWN

Which type of project this is (library/app).


projenCredentialsOptional
public readonly projenCredentials: GithubCredentials;
  • Type: projen.github.GithubCredentials
  • Default: use a personal access token named PROJEN_GITHUB_TOKEN

Choose a method of providing GitHub API access for projen workflows.


projenTokenSecretOptional
  • Deprecated: use projenCredentials
public readonly projenTokenSecret: string;
  • Type: string
  • Default: "PROJEN_GITHUB_TOKEN"

The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows.

This token needs to have the repo, workflows and packages scope.


readmeOptional
public readonly readme: SampleReadmeProps;
  • Type: projen.SampleReadmeProps
  • Default: { filename: 'README.md', contents: '# replace this' }

The README setup.


Example

"{ filename: 'readme.md', contents: '# title' }"
staleOptional
public readonly stale: boolean;
  • Type: boolean
  • Default: false

Auto-close of stale issues and pull request.

See staleOptions for options.


staleOptionsOptional
public readonly staleOptions: StaleOptions;
  • Type: projen.github.StaleOptions
  • Default: see defaults in StaleOptions

Auto-close stale issues and pull requests.

To disable set stale to false.


vscodeOptional
public readonly vscode: boolean;
  • Type: boolean
  • Default: true

Enable VSCode integration.

Enabled by default for root projects. Disabled for non-root projects.


authorEmailRequired
public readonly authorEmail: string;
  • Type: string
  • Default: $GIT_USER_EMAIL

Author's e-mail.


authorNameRequired
public readonly authorName: string;
  • Type: string
  • Default: $GIT_USER_NAME

Author's name.


versionRequired
public readonly version: string;
  • Type: string
  • Default: "0.1.0"

Version of the package.


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

A list of PyPI trove classifiers that describe the project.

https://pypi.org/classifiers/


descriptionOptional
public readonly description: string;
  • Type: string

A short description of the package.


homepageOptional
public readonly homepage: string;
  • Type: string

A URL to the website of the project.


licenseOptional
public readonly license: string;
  • Type: string

License of this package as an SPDX identifier.


packageNameOptional
public readonly packageName: string;
  • Type: string

Package name.


poetryOptionsOptional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;

Additional options to set for poetry if using poetry.


setupConfigOptional
public readonly setupConfig: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Additional fields to pass in the setup() function if using setuptools.


uvOptionsOptional
public readonly uvOptions: UvOptions;

Additional options to set for uv if using uv.


pythonExecOptional
public readonly pythonExec: string;
  • Type: string
  • Default: "python"

Path to the python executable to use.


moduleNameRequired
public readonly moduleName: string;
  • Type: string
  • Default: $PYTHON_MODULE_NAME

Name of the python package as used in imports and filenames.

Must only consist of alphanumeric characters and underscores.


depsOptional
public readonly deps: string[];
  • Type: string[]
  • Default: []

List of runtime dependencies for this project.

Dependencies use the format: <module>@<semver>

Additional dependencies can be added via project.addDependency().


devDepsOptional
public readonly devDeps: string[];
  • Type: string[]
  • Default: []

List of dev dependencies for this project.

Dependencies use the format: <module>@<semver>

Additional dependencies can be added via project.addDevDependency().


pipOptional
public readonly pip: boolean;
  • Type: boolean
  • Default: true, unless poetry is true, then false

Use pip with a requirements.txt file to track project dependencies.


poetryOptional
public readonly poetry: boolean;
  • Type: boolean
  • Default: false

Use poetry to manage your project dependencies, virtual environment, and (optional) packaging/publishing.

This feature is incompatible with pip, setuptools, or venv. If you set this option to true, then pip, setuptools, and venv must be set to false.


projenrcJsOptional
public readonly projenrcJs: boolean;
  • Type: boolean
  • Default: false

Use projenrc in javascript.

This will install projen as a JavaScript dependency and add a synth task which will run .projenrc.js.


projenrcJsOptionsOptional
public readonly projenrcJsOptions: ProjenrcOptions;
  • Type: projen.javascript.ProjenrcOptions
  • Default: default options

Options related to projenrc in JavaScript.


projenrcPythonOptional
public readonly projenrcPython: boolean;
  • Type: boolean
  • Default: true

Use projenrc in Python.

This will install projen as a Python dependency and add a synth task which will run .projenrc.py.


projenrcPythonOptionsOptional
public readonly projenrcPythonOptions: ProjenrcOptions;

Options related to projenrc in python.


projenrcTsOptional
public readonly projenrcTs: boolean;
  • Type: boolean
  • Default: false

Use projenrc in TypeScript.

This will create a tsconfig file (default: tsconfig.projen.json) and use ts-node in the default task to parse the project source files.


projenrcTsOptionsOptional
public readonly projenrcTsOptions: ProjenrcTsOptions;
  • Type: projen.typescript.ProjenrcTsOptions
  • Default: default options

Options related to projenrc in TypeScript.


pytestOptional
public readonly pytest: boolean;
  • Type: boolean
  • Default: true

Include pytest tests.


pytestOptionsOptional
public readonly pytestOptions: PytestOptions;

pytest options.


sampleOptional
public readonly sample: boolean;
  • Type: boolean
  • Default: true

Include sample code and test if the relevant directories don't exist.


sampleTestdirOptional
public readonly sampleTestdir: string;
  • Type: string
  • Default: "tests"

Location of sample tests.

Typically the same directory where project tests will be located.


setuptoolsOptional
public readonly setuptools: boolean;
  • Type: boolean
  • Default: true, unless poetry is true, then false

Use setuptools with a setup.py script for packaging and publishing.


uvOptional
public readonly uv: boolean;
  • Type: boolean
  • Default: false

Use uv to manage your project dependencies, virtual environment, and (optional) packaging/publishing.


venvOptional
public readonly venv: boolean;
  • Type: boolean
  • Default: true, unless poetry is true, then false

Use venv to manage a virtual environment for installing dependencies inside.


venvOptionsOptional
public readonly venvOptions: VenvOptions;

Venv options.


PythonSampleOptions

Options for python sample code.

Initializer

import { python } from 'projen'

const pythonSampleOptions: python.PythonSampleOptions = { ... }

Properties

NameTypeDescription
dir
stringSample code directory.

dirRequired
public readonly dir: string;
  • Type: string

Sample code directory.


RequirementsFileOptions

Initializer

import { python } from 'projen'

const requirementsFileOptions: python.RequirementsFileOptions = { ... }

Properties

NameTypeDescription
packageProvider
IPackageProvider
Provide a list of packages that can be dynamically updated.

packageProviderOptional
public readonly packageProvider: IPackageProvider;

Provide a list of packages that can be dynamically updated.


SetupPyOptions

Fields to pass in the setup() function of setup.py.

https://docs.python.org/3/distutils/setupscript.html

Initializer

import { python } from 'projen'

const setupPyOptions: python.SetupPyOptions = { ... }

Properties

NameTypeDescription
additionalOptions
{[ key: string ]: any}Escape hatch to allow any value.
authorEmail
stringAuthor's e-mail.
authorName
stringAuthor's name.
classifiers
string[]A list of PyPI trove classifiers that describe the project.
description
stringA short project description.
homepage
stringPackage's Homepage / Website.
license
stringThe project license.
name
stringName of the package.
packages
string[]List of submodules to be packaged.
version
stringManually specify package version.

additionalOptionsOptional
public readonly additionalOptions: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Escape hatch to allow any value.


authorEmailOptional
public readonly authorEmail: string;
  • Type: string

Author's e-mail.


authorNameOptional
public readonly authorName: string;
  • Type: string

Author's name.


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

A list of PyPI trove classifiers that describe the project.

https://pypi.org/classifiers/


descriptionOptional
public readonly description: string;
  • Type: string

A short project description.


homepageOptional
public readonly homepage: string;
  • Type: string

Package's Homepage / Website.


licenseOptional
public readonly license: string;
  • Type: string

The project license.


nameOptional
public readonly name: string;
  • Type: string

Name of the package.


packagesOptional
public readonly packages: string[];
  • Type: string[]

List of submodules to be packaged.


versionOptional
public readonly version: string;
  • Type: string

Manually specify package version.


SetuptoolsOptions

Initializer

import { python } from 'projen'

const setuptoolsOptions: python.SetuptoolsOptions = { ... }

Properties

NameTypeDescription
authorEmail
stringAuthor's e-mail.
authorName
stringAuthor's name.
version
stringVersion of the package.
classifiers
string[]A list of PyPI trove classifiers that describe the project.
description
stringA short description of the package.
homepage
stringA URL to the website of the project.
license
stringLicense of this package as an SPDX identifier.
packageName
stringPackage name.
poetryOptions
PoetryPyprojectOptionsWithoutDeps
Additional options to set for poetry if using poetry.
setupConfig
{[ key: string ]: any}Additional fields to pass in the setup() function if using setuptools.
uvOptions
UvOptions
Additional options to set for uv if using uv.
pythonExec
stringPath to the python executable to use.

authorEmailRequired
public readonly authorEmail: string;
  • Type: string
  • Default: $GIT_USER_EMAIL

Author's e-mail.


authorNameRequired
public readonly authorName: string;
  • Type: string
  • Default: $GIT_USER_NAME

Author's name.


versionRequired
public readonly version: string;
  • Type: string
  • Default: "0.1.0"

Version of the package.


classifiersOptional
public readonly classifiers: string[];
  • Type: string[]

A list of PyPI trove classifiers that describe the project.

https://pypi.org/classifiers/


descriptionOptional
public readonly description: string;
  • Type: string

A short description of the package.


homepageOptional
public readonly homepage: string;
  • Type: string

A URL to the website of the project.


licenseOptional
public readonly license: string;
  • Type: string

License of this package as an SPDX identifier.


packageNameOptional
public readonly packageName: string;
  • Type: string

Package name.


poetryOptionsOptional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;

Additional options to set for poetry if using poetry.


setupConfigOptional
public readonly setupConfig: {[ key: string ]: any};
  • Type: {[ key: string ]: any}

Additional fields to pass in the setup() function if using setuptools.


uvOptionsOptional
public readonly uvOptions: UvOptions;

Additional options to set for uv if using uv.


pythonExecOptional
public readonly pythonExec: string;
  • Type: string
  • Default: "python"

Path to the python executable to use.


UvOptions

Options for UV project.

Initializer

import { python } from 'projen'

const uvOptions: python.UvOptions = { ... }

Properties

NameTypeDescription
pythonExec
stringPath to the python executable to use.
buildSystem
BuildSystem
Declares any Python level dependencies that must be installed in order to run the project’s build system successfully.
project
PyprojectTomlProject
The project's basic metadata configuration.
uv
UvConfiguration
The configuration and metadata for uv.

pythonExecOptional
public readonly pythonExec: string;
  • Type: string
  • Default: "python"

Path to the python executable to use.


buildSystemOptional
public readonly buildSystem: BuildSystem;

Declares any Python level dependencies that must be installed in order to run the project’s build system successfully.


projectOptional
public readonly project: PyprojectTomlProject;

The project's basic metadata configuration.


uvOptional
public readonly uv: UvConfiguration;

The configuration and metadata for uv.


VenvOptions

Options for venv.

Initializer

import { python } from 'projen'

const venvOptions: python.VenvOptions = { ... }

Properties

NameTypeDescription
envdir
stringName of directory to store the environment in.
pythonExec
stringPath to the python executable to use.

envdirOptional
public readonly envdir: string;
  • Type: string
  • Default: ".env"

Name of directory to store the environment in.


pythonExecOptional
public readonly pythonExec: string;
  • Type: string
  • Default: "python"

Path to the python executable to use.


Protocols

IPackageProvider

Properties

NameTypeDescription
packages
projen.Dependency[]An array of packages (may be dynamically generated).

packagesRequired
public readonly packages: Dependency[];
  • Type: projen.Dependency[]

An array of packages (may be dynamically generated).


IPythonDeps

Methods

NameDescription
addDependency
Adds a runtime dependency.
addDevDependency
Adds a dev dependency.
installDependencies
Installs dependencies (called during post-synthesis).

addDependency
public addDependency(spec: string): void

Adds a runtime dependency.

specRequired
  • Type: string

Format <module>@<semver>.


addDevDependency
public addDevDependency(spec: string): void

Adds a dev dependency.

specRequired
  • Type: string

Format <module>@<semver>.


installDependencies
public installDependencies(): void

Installs dependencies (called during post-synthesis).

Properties

NameTypeDescription
installCiTask
projen.TaskA task that installs and updates dependencies.

installCiTaskRequired
public readonly installCiTask: Task;
  • Type: projen.Task

A task that installs and updates dependencies.


IPythonEnv

Methods

NameDescription
setupEnvironment
Initializes the virtual environment if it doesn't exist (called during post-synthesis).

setupEnvironment
public setupEnvironment(): void

Initializes the virtual environment if it doesn't exist (called during post-synthesis).

IPythonPackaging

Properties

NameTypeDescription
publishTask
projen.TaskA task that uploads the package to a package repository.

publishTaskRequired
public readonly publishTask: Task;
  • Type: projen.Task

A task that uploads the package to a package repository.


Enums

PyprojectTomlProjectDynamic

Members

NameDescription
VERSION
version.
DESCRIPTION
description.
README
readme.
REQUIRES_HYPHEN_PYTHON
requires-python.
LICENSE
license.
LICENSE_HYPHEN_FILES
license-files.
AUTHORS
authors.
MAINTAINERS
maintainers.
KEYWORDS
keywords.
CLASSIFIERS
classifiers.
URLS
urls.
SCRIPTS
scripts.
GUI_HYPHEN_SCRIPTS
gui-scripts.
ENTRY_HYPHEN_POINTS
entry-points.
DEPENDENCIES
dependencies.
OPTIONAL_HYPHEN_DEPENDENCIES
optional-dependencies.
IMPORT_HYPHEN_NAMES
import-names.
IMPORT_HYPHEN_NAMESPACES
import-namespaces.

VERSION

version.


DESCRIPTION

description.


README

readme.


REQUIRES_HYPHEN_PYTHON

requires-python.


LICENSE

license.


LICENSE_HYPHEN_FILES

license-files.


AUTHORS

authors.


MAINTAINERS

maintainers.


KEYWORDS

keywords.


CLASSIFIERS

classifiers.


URLS

urls.


SCRIPTS

scripts.


GUI_HYPHEN_SCRIPTS

gui-scripts.


ENTRY_HYPHEN_POINTS

entry-points.


DEPENDENCIES

dependencies.


OPTIONAL_HYPHEN_DEPENDENCIES

optional-dependencies.


IMPORT_HYPHEN_NAMES

import-names.


IMPORT_HYPHEN_NAMESPACES

import-namespaces.