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(project: Project, options: PoetryPyprojectOptions)
NameTypeDescription
project
projen.ProjectNo description.
options
PoetryPyprojectOptions
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.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
projen.TomlFileNo description.

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

The tree node.


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

fileRequired
public readonly file: TomlFile;
  • Type: projen.TomlFile

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.


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.

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

The tree node.


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

testdirRequired
public readonly testdir: 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 mangaging the Python runtime environment.
moduleName
stringPython module name (the project name, with any hyphens or periods replaced with underscores).
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 mangaging 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).


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.


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

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.
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.


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).
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).


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).
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).


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).


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.


PytestOptions

Initializer

import { python } from 'projen'

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

Properties

NameTypeDescription
maxFailures
numberStop the testing process after the first N failures.
testdir
stringDirectory with tests.
version
stringPytest version.

maxFailuresOptional
public readonly maxFailures: number;
  • Type: number

Stop the testing process after the first N failures.


testdirOptional
public readonly testdir: string;
  • Type: string
  • Default: 'tests'

Directory with tests.


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.

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.


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.
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.
setuptools
booleanUse setuptools with a setup.py script for packaging and 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.


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.


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.


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.
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.


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

Path to the python executable to use.


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.