python
Submodule
Constructs
Pip
- Implements: IPythonDeps
Manages dependencies using a requirements.txt file and the pip CLI tool.
Initializers
import { python } from 'projen'
new python.Pip(project: Project, _options?: PipOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
_options
Optional
- Type: PipOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds a runtime dependency. |
| Adds a dev dependency. |
| 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.
spec
Required
- Type: string
Format <module>@<semver>
.
addDevDependency
public addDevDependency(spec: string): void
Adds a dev dependency.
spec
Required
- Type: string
Format <module>@<semver>
.
installDependencies
public installDependencies(): void
Installs dependencies (called during post-synthesis).
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.Pip.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| projen.Task | A task that installs and updates dependencies. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
installCiTask
Required
public readonly installCiTask: Task;
- Type: projen.Task
A task that installs and updates dependencies.
Poetry
- Implements: IPythonDeps, IPythonEnv, IPythonPackaging
Manage project dependencies, virtual environments, and packaging through the poetry CLI tool.
Initializers
import { python } from 'projen'
new python.Poetry(project: Project, options: PoetryOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: PoetryOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| Adds a runtime dependency. |
| Adds a dev dependency. |
| Installs dependencies (called during post-synthesis). |
| 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.
spec
Required
- Type: string
Format <module>@<semver>
.
addDevDependency
public addDevDependency(spec: string): void
Adds a dev dependency.
spec
Required
- 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.Poetry.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| projen.Task | Task for installing dependencies according to the existing lockfile. |
| projen.Task | Task for updating the lockfile and installing project dependencies. |
| projen.Task | Task for publishing the package to a package repository. |
| projen.Task | Task for publishing the package to the Test PyPI repository for testing purposes. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
installCiTask
Required
public readonly installCiTask: Task;
- Type: projen.Task
Task for installing dependencies according to the existing lockfile.
installTask
Required
public readonly installTask: Task;
- Type: projen.Task
Task for updating the lockfile and installing project dependencies.
publishTask
Required
public readonly publishTask: Task;
- Type: projen.Task
Task for publishing the package to a package repository.
publishTestTask
Required
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.
Initializers
import { python } from 'projen'
new python.PoetryPyproject(project: Project, options: PoetryPyprojectOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: PoetryPyprojectOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.PoetryPyproject.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| projen.TomlFile | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
file
Required
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Optional
- Type: ProjenrcOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a component. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.Projenrc.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- 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.
project
Required
- Type: projen.Project
The project.
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The name of the projenrc file. |
| string | Path to the python executable to use. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
filePath
Required
public readonly filePath: string;
- Type: string
The name of the projenrc file.
pythonExec
Required
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Optional
- Type: PytestOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.Pytest.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | No description. |
| string[] | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
testdir
Required
testdir
- Deprecated: Use
sampleTestdir
on the project instead.
public readonly testdir: string;
- Type: string
testMatch
Required
public readonly testMatch: string[];
- Type: string[]
PytestSample
Python test code sample.
Initializers
import { python } from 'projen'
new python.PytestSample(project: Project, options: PytestSampleOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: PytestSampleOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.PytestSample.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
PythonProject
Python project.
Initializers
import { python } from 'projen'
new python.PythonProject(options: PythonProjectOptions)
Name | Type | Description |
---|---|---|
|
| No description. |
options
Required
- Type: PythonProjectOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Exclude the matching files from pre-synth cleanup. |
| Adds a .gitignore pattern. |
| Exclude these files from the bundled package. |
| Adds a new task to this project. |
| Prints a "tip" message during synthesis. |
| Marks the provided file(s) as being generated. |
| Called after all components are synthesized. |
| Called before all components are synthesized. |
| Removes a task from a project. |
| Returns the shell command to execute in order to run a task. |
| Synthesize all project files into outdir . |
| Finds a file at the specified relative path within this project and all its subprojects. |
| Finds a json file by name. |
| Finds an object file (like JsonFile, YamlFile, etc.) by name. |
| Finds a file at the specified relative path within this project and removes it. |
| Adds a runtime dependency. |
| 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.
globs
Required
- Type: ...string[]
The glob patterns to match.
addGitIgnore
public addGitIgnore(pattern: string): void
Adds a .gitignore pattern.
pattern
Required
- 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
.
_pattern
Required
- 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.
name
Required
- Type: string
The task name to add.
props
Optional
- Type: projen.TaskOptions
Task properties.
addTip
addTip
public addTip(message: string): void
Prints a "tip" message during synthesis.
message
Required
- 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
glob
Required
- 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.
name
Required
- 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>
task
Required
- Type: projen.Task
The task for which the command is required.
synth
public synth(): void
Synthesize all project files into outdir
.
- Call "this.preSynthesize()"
- Delete all generated files
- Synthesize all subprojects
- Synthesize all components of this project
- Call "postSynthesize()" for all components of this project
- Call "this.postSynthesize()"
tryFindFile
public tryFindFile(filePath: string): FileBase
Finds a file at the specified relative path within this project and all its subprojects.
filePath
Required
- Type: string
The file path.
If this path is relative, it will be resolved from the root of this project.
tryFindJsonFile
tryFindJsonFile
public tryFindJsonFile(filePath: string): JsonFile
Finds a json file by name.
filePath
Required
- Type: string
The file path.
tryFindObjectFile
public tryFindObjectFile(filePath: string): ObjectFile
Finds an object file (like JsonFile, YamlFile, etc.) by name.
filePath
Required
- 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.
filePath
Required
- 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.
spec
Required
- Type: string
Format <module>@<semver>
.
addDevDependency
public addDevDependency(spec: string): void
Adds a dev dependency.
spec
Required
- Type: string
Format <module>@<semver>
.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| Test whether the given construct is a project. |
| 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.
x
Required
- Type: any
Any object.
isProject
import { python } from 'projen'
python.PythonProject.isProject(x: any)
Test whether the given construct is a project.
x
Required
- 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.
construct
Required
- Type: constructs.IConstruct
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Task | No description. |
| boolean | Whether to commit the managed files by default. |
| projen.Task | No description. |
| projen.Component[] | Returns all the components within this project. |
| projen.Dependencies | Project dependencies. |
| boolean | Whether or not the project is being ejected. |
| projen.FileBase[] | All files in this project. |
| projen.GitAttributesFile | The .gitattributes file for this repository. |
| projen.IgnoreFile | .gitignore. |
| projen.Logger | Logging utilities. |
| string | Project name. |
| string | Absolute output directory of this project. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.Task | No description. |
| projen.ProjectBuild | Manages the build process of the project. |
| string | The command to use in order to run the projen CLI. |
| projen.Project | The root project. |
| projen.Project[] | Returns all the subprojects within this project. |
| projen.Tasks | Project tasks. |
| projen.Task | No description. |
| projen.Task | This is the "default" task, the one that executes "projen". |
| projen.InitProject | The options used when this project is bootstrapped via projen new . |
| projen.Project | A parent project. |
| projen.ProjectType | No description. |
| projen.github.AutoApprove | Auto approve set up for this project. |
| projen.vscode.DevContainer | Access for .devcontainer.json (used for GitHub Codespaces). |
| projen.github.GitHub | Access all github components. |
| projen.Gitpod | Access for Gitpod. |
| projen.vscode.VsCode | Access all VSCode components. |
|
| API for managing dependencies. |
|
| API for mangaging the Python runtime environment. |
| string | Python module name (the project name, with any hyphens or periods replaced with underscores). |
| string | Directory where sample tests are located. |
| string | Version of the package for distribution (should follow semver). |
|
| API for managing packaging the project as a library. |
|
| Pytest component. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
buildTask
Required
public readonly buildTask: Task;
- Type: projen.Task
commitGenerated
Required
public readonly commitGenerated: boolean;
- Type: boolean
Whether to commit the managed files by default.
compileTask
Required
public readonly compileTask: Task;
- Type: projen.Task
components
Required
public readonly components: Component[];
- Type: projen.Component[]
Returns all the components within this project.
deps
Required
public readonly deps: Dependencies;
- Type: projen.Dependencies
Project dependencies.
ejected
Required
public readonly ejected: boolean;
- Type: boolean
Whether or not the project is being ejected.
files
Required
public readonly files: FileBase[];
- Type: projen.FileBase[]
All files in this project.
gitattributes
Required
public readonly gitattributes: GitAttributesFile;
- Type: projen.GitAttributesFile
The .gitattributes file for this repository.
gitignore
Required
public readonly gitignore: IgnoreFile;
- Type: projen.IgnoreFile
.gitignore.
logger
Required
public readonly logger: Logger;
- Type: projen.Logger
Logging utilities.
name
Required
public readonly name: string;
- Type: string
Project name.
outdir
Required
public readonly outdir: string;
- Type: string
Absolute output directory of this project.
packageTask
Required
public readonly packageTask: Task;
- Type: projen.Task
postCompileTask
Required
public readonly postCompileTask: Task;
- Type: projen.Task
preCompileTask
Required
public readonly preCompileTask: Task;
- Type: projen.Task
projectBuild
Required
public readonly projectBuild: ProjectBuild;
- Type: projen.ProjectBuild
Manages the build process of the project.
projenCommand
Required
public readonly projenCommand: string;
- Type: string
The command to use in order to run the projen CLI.
root
Required
public readonly root: Project;
- Type: projen.Project
The root project.
subprojects
Required
public readonly subprojects: Project[];
- Type: projen.Project[]
Returns all the subprojects within this project.
tasks
Required
public readonly tasks: Tasks;
- Type: projen.Tasks
Project tasks.
testTask
Required
public readonly testTask: Task;
- Type: projen.Task
defaultTask
Optional
public readonly defaultTask: Task;
- Type: projen.Task
This is the "default" task, the one that executes "projen".
Undefined if the project is being ejected.
initProject
Optional
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.
parent
Optional
public readonly parent: Project;
- Type: projen.Project
A parent project.
If undefined, this is the root project.
projectType
Required
public readonly projectType: ProjectType;
- Type: projen.ProjectType
autoApprove
Optional
public readonly autoApprove: AutoApprove;
- Type: projen.github.AutoApprove
Auto approve set up for this project.
devContainer
Optional
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
github
Optional
public readonly github: GitHub;
- Type: projen.github.GitHub
Access all github components.
This will be undefined
for subprojects.
gitpod
Optional
public readonly gitpod: Gitpod;
- Type: projen.Gitpod
Access for Gitpod.
This will be undefined
if gitpod boolean is false
vscode
Optional
public readonly vscode: VsCode;
- Type: projen.vscode.VsCode
Access all VSCode components.
This will be undefined
for subprojects.
depsManager
Required
public readonly depsManager: IPythonDeps;
- Type: IPythonDeps
API for managing dependencies.
envManager
Required
public readonly envManager: IPythonEnv;
- Type: IPythonEnv
API for mangaging the Python runtime environment.
moduleName
Required
public readonly moduleName: string;
- Type: string
Python module name (the project name, with any hyphens or periods replaced with underscores).
sampleTestdir
Required
public readonly sampleTestdir: string;
- Type: string
- Default: "tests"
Directory where sample tests are located.
version
Required
public readonly version: string;
- Type: string
Version of the package for distribution (should follow semver).
packagingManager
Optional
public readonly packagingManager: IPythonPackaging;
- Type: IPythonPackaging
API for managing packaging the project as a library.
Only applies when the projectType
is LIB.
pytest
Optional
public readonly pytest: Pytest;
- Type: Pytest
Pytest component.
Constants
Name | Type | Description |
---|---|---|
| string | The name of the default task (the task executed when projen is run without arguments). |
DEFAULT_TASK
Required
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: PythonSampleOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.PythonSample.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
| string | No description. |
|
| No description. |
project
Required
- Type: projen.Project
filePath
Required
- Type: string
options
Required
- Type: RequirementsFileOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Writes the file to the project's output directory. |
| 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.
packages
Required
- Type: ...string[]
Package version in format <module>@<semver>
.
Static Functions
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.RequirementsFile.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
absolutePath
Required
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
path
Required
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changed
Optional
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.
marker
Optional
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.
executable
Required
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonly
Required
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)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: SetupPyOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.SetupPy.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| string | The absolute path of this file. |
| string | The file path, relative to the project's outdir. |
| boolean | Indicates if the file has been changed during synthesis. |
| string | The projen marker, used to identify files as projen-generated. |
| boolean | Indicates if the file should be marked as executable. |
| boolean | Indicates if the file should be read-only or read-write. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
absolutePath
Required
public readonly absolutePath: string;
- Type: string
The absolute path of this file.
path
Required
public readonly path: string;
- Type: string
The file path, relative to the project's outdir.
changed
Optional
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.
marker
Optional
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.
executable
Required
public readonly executable: boolean;
- Type: boolean
Indicates if the file should be marked as executable.
readonly
Required
public readonly readonly: boolean;
- Type: boolean
Indicates if the file should be read-only or read-write.
Setuptools
- Implements: IPythonPackaging
Manages packaging through setuptools with a setup.py script.
Initializers
import { python } from 'projen'
new python.Setuptools(project: Project, options: SetuptoolsOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Required
- Type: SetuptoolsOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.Setuptools.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
| projen.Task | A task that uploads the package to a package repository. |
| projen.Task | A task that uploads the package to the Test PyPI repository. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
public readonly project: Project;
- Type: projen.Project
publishTask
Required
public readonly publishTask: Task;
- Type: projen.Task
A task that uploads the package to a package repository.
publishTestTask
Required
public readonly publishTestTask: Task;
- Type: projen.Task
A task that uploads the package to the Test PyPI repository.
Venv
- Implements: IPythonEnv
Manages a virtual environment through the Python venv module.
Initializers
import { python } from 'projen'
new python.Venv(project: Project, options?: VenvOptions)
Name | Type | Description |
---|---|---|
| projen.Project | No description. |
|
| No description. |
project
Required
- Type: projen.Project
options
Optional
- Type: VenvOptions
Methods
Name | Description |
---|---|
| Returns a string representation of this construct. |
| Called after synthesis. |
| Called before synthesis. |
| Synthesizes files to the project output directory. |
| 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
Name | Description |
---|---|
| Checks if x is a construct. |
| 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.
x
Required
- Type: any
Any object.
isComponent
import { python } from 'projen'
python.Venv.isComponent(x: any)
Test whether the given construct is a component.
x
Required
- Type: any
Properties
Name | Type | Description |
---|---|---|
| constructs.Node | The tree node. |
| projen.Project | No description. |
node
Required
public readonly node: Node;
- Type: constructs.Node
The tree node.
project
Required
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
Name | Type | Description |
---|---|---|
| string | Author's e-mail. |
| string | Author's name. |
| string | Version of the package. |
| string[] | A list of PyPI trove classifiers that describe the project. |
| string | A short description of the package. |
| string | A URL to the website of the project. |
| string | License of this package as an SPDX identifier. |
| string | Package name. |
|
| Additional options to set for poetry if using poetry. |
| {[ key: string ]: any} | Additional fields to pass in the setup() function if using setuptools. |
| string | Path to the python executable to use. |
authorEmail
Required
public readonly authorEmail: string;
- Type: string
- Default: $GIT_USER_EMAIL
Author's e-mail.
authorName
Required
public readonly authorName: string;
- Type: string
- Default: $GIT_USER_NAME
Author's name.
version
Required
public readonly version: string;
- Type: string
- Default: "0.1.0"
Version of the package.
classifiers
Optional
public readonly classifiers: string[];
- Type: string[]
A list of PyPI trove classifiers that describe the project.
description
Optional
public readonly description: string;
- Type: string
A short description of the package.
homepage
Optional
public readonly homepage: string;
- Type: string
A URL to the website of the project.
license
Optional
public readonly license: string;
- Type: string
License of this package as an SPDX identifier.
packageName
Optional
public readonly packageName: string;
- Type: string
Package name.
poetryOptions
Optional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;
Additional options to set for poetry if using poetry.
setupConfig
Optional
public readonly setupConfig: {[ key: string ]: any};
- Type: {[ key: string ]: any}
Additional fields to pass in the setup() function if using setuptools.
pythonExec
Optional
public readonly pythonExec: string;
- Type: string
- Default: "python"
Path to the python executable to use.
PoetryPyprojectOptions
Poetry-specific options.
Initializer
import { python } from 'projen'
const poetryPyprojectOptions: python.PoetryPyprojectOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | The authors of the package. |
| string[] | A list of PyPI trove classifiers that describe the project. |
| string | A short description of the package (required). |
| string | A URL to the documentation of the project. |
| string[] | A list of patterns that will be excluded in the final package. |
| {[ key: string ]: string[]} | Package extras. |
| string | A URL to the website of the project. |
| string[] | A list of patterns that will be included in the final package. |
| string[] | A list of keywords (max: 5) that the package is related to. |
| string | License of this package as an SPDX identifier. |
| string[] | the maintainers of the package. |
| string | Name of the package (required). |
| any[] | A list of packages and modules to include in the final distribution. |
| any | Plugins. |
| string | The name of the readme file of the package. |
| string | A URL to the repository of the project. |
| {[ key: string ]: any} | The scripts or executables that will be installed when installing the package. |
| any[] | Source registries from which packages are retrieved. |
| {[ key: string ]: string} | Project custom URLs, in addition to homepage, repository and documentation. |
| string | Version of the package (required). |
| {[ key: string ]: any} | A list of dependencies for the project. |
| {[ key: string ]: any} | A list of development dependencies for the project. |
authors
Optional
public readonly authors: string[];
- Type: string[]
The authors of the package.
Must be in the form "name
classifiers
Optional
public readonly classifiers: string[];
- Type: string[]
A list of PyPI trove classifiers that describe the project.
description
Optional
public readonly description: string;
- Type: string
A short description of the package (required).
documentation
Optional
public readonly documentation: string;
- Type: string
A URL to the documentation of the project.
exclude
Optional
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).
extras
Optional
public readonly extras: {[ key: string ]: string[]};
- Type: {[ key: string ]: string[]}
Package extras.
homepage
Optional
public readonly homepage: string;
- Type: string
A URL to the website of the project.
include
Optional
public readonly include: string[];
- Type: string[]
A list of patterns that will be included in the final package.
keywords
Optional
public readonly keywords: string[];
- Type: string[]
A list of keywords (max: 5) that the package is related to.
license
Optional
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".
maintainers
Optional
public readonly maintainers: string[];
- Type: string[]
the maintainers of the package.
Must be in the form "name
name
Optional
public readonly name: string;
- Type: string
Name of the package (required).
packages
Optional
public readonly packages: any[];
- Type: any[]
A list of packages and modules to include in the final distribution.
plugins
Optional
public readonly plugins: any;
- Type: any
Plugins.
Must be specified as a table.
readme
Optional
public readonly readme: string;
- Type: string
The name of the readme file of the package.
repository
Optional
public readonly repository: string;
- Type: string
A URL to the repository of the project.
scripts
Optional
public readonly scripts: {[ key: string ]: any};
- Type: {[ key: string ]: any}
The scripts or executables that will be installed when installing the package.
source
Optional
public readonly source: any[];
- Type: any[]
Source registries from which packages are retrieved.
urls
Optional
public readonly urls: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Project custom URLs, in addition to homepage, repository and documentation.
E.g. "Bug Tracker"
version
Optional
public readonly version: string;
- Type: string
Version of the package (required).
dependencies
Optional
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" }
devDependencies
Optional
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.
Initializer
import { python } from 'projen'
const poetryPyprojectOptionsWithoutDeps: python.PoetryPyprojectOptionsWithoutDeps = { ... }
Properties
Name | Type | Description |
---|---|---|
| string[] | The authors of the package. |
| string[] | A list of PyPI trove classifiers that describe the project. |
| string | A short description of the package (required). |
| string | A URL to the documentation of the project. |
| string[] | A list of patterns that will be excluded in the final package. |
| {[ key: string ]: string[]} | Package extras. |
| string | A URL to the website of the project. |
| string[] | A list of patterns that will be included in the final package. |
| string[] | A list of keywords (max: 5) that the package is related to. |
| string | License of this package as an SPDX identifier. |
| string[] | the maintainers of the package. |
| string | Name of the package (required). |
| any[] | A list of packages and modules to include in the final distribution. |
| any | Plugins. |
| string | The name of the readme file of the package. |
| string | A URL to the repository of the project. |
| {[ key: string ]: any} | The scripts or executables that will be installed when installing the package. |
| any[] | Source registries from which packages are retrieved. |
| {[ key: string ]: string} | Project custom URLs, in addition to homepage, repository and documentation. |
| string | Version of the package (required). |
authors
Optional
public readonly authors: string[];
- Type: string[]
The authors of the package.
Must be in the form "name
classifiers
Optional
public readonly classifiers: string[];
- Type: string[]
A list of PyPI trove classifiers that describe the project.
description
Optional
public readonly description: string;
- Type: string
A short description of the package (required).
documentation
Optional
public readonly documentation: string;
- Type: string
A URL to the documentation of the project.
exclude
Optional
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).
extras
Optional
public readonly extras: {[ key: string ]: string[]};
- Type: {[ key: string ]: string[]}
Package extras.
homepage
Optional
public readonly homepage: string;
- Type: string
A URL to the website of the project.
include
Optional
public readonly include: string[];
- Type: string[]
A list of patterns that will be included in the final package.
keywords
Optional
public readonly keywords: string[];
- Type: string[]
A list of keywords (max: 5) that the package is related to.
license
Optional
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".
maintainers
Optional
public readonly maintainers: string[];
- Type: string[]
the maintainers of the package.
Must be in the form "name
name
Optional
public readonly name: string;
- Type: string
Name of the package (required).
packages
Optional
public readonly packages: any[];
- Type: any[]
A list of packages and modules to include in the final distribution.
plugins
Optional
public readonly plugins: any;
- Type: any
Plugins.
Must be specified as a table.
readme
Optional
public readonly readme: string;
- Type: string
The name of the readme file of the package.
repository
Optional
public readonly repository: string;
- Type: string
A URL to the repository of the project.
scripts
Optional
public readonly scripts: {[ key: string ]: any};
- Type: {[ key: string ]: any}
The scripts or executables that will be installed when installing the package.
source
Optional
public readonly source: any[];
- Type: any[]
Source registries from which packages are retrieved.
urls
Optional
public readonly urls: {[ key: string ]: string};
- Type: {[ key: string ]: string}
Project custom URLs, in addition to homepage, repository and documentation.
E.g. "Bug Tracker"
version
Optional
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
Name | Type | Description |
---|---|---|
| string | The name of the projenrc file. |
| string | The projen version to use. |
| string | Path to the python executable to use. |
filename
Optional
public readonly filename: string;
- Type: string
- Default: ".projenrc.py"
The name of the projenrc file.
projenVersion
Optional
public readonly projenVersion: string;
- Type: string
- Default: current version
The projen version to use.
pythonExec
Optional
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
Name | Type | Description |
---|---|---|
| number | Stop the testing process after the first N failures. |
| string | Location of sample tests. |
| string[] | List of paths to test files or directories. |
| string | Pytest version. |
maxFailures
Optional
public readonly maxFailures: number;
- Type: number
Stop the testing process after the first N failures.
testdir
Optional
testdir
- Deprecated: Reference
sampleTestdir
on the project instead; to change the directory where tests are discovered from, usetestMatch
.
public readonly testdir: string;
- Type: string
- Default: "tests"
Location of sample tests.
Typically the same directory where project tests will be located.
testMatch
Optional
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"]
version
Optional
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
Name | Type | Description |
---|---|---|
| string | Name of the python package as used in imports and filenames. |
| string | Test directory. |
moduleName
Required
public readonly moduleName: string;
- Type: string
Name of the python package as used in imports and filenames.
testdir
Required
public readonly testdir: string;
- Type: string
Test directory.
PythonExecutableOptions
Initializer
import { python } from 'projen'
const pythonExecutableOptions: python.PythonExecutableOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Path to the python executable to use. |
pythonExec
Optional
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
Name | Type | Description |
---|---|---|
| string | Author's e-mail. |
| string | Author's name. |
| string | Version of the package. |
| string[] | A list of PyPI trove classifiers that describe the project. |
| string | A short description of the package. |
| string | A URL to the website of the project. |
| string | License of this package as an SPDX identifier. |
| string | Package name. |
|
| Additional options to set for poetry if using poetry. |
| {[ key: string ]: any} | Additional fields to pass in the setup() function if using setuptools. |
authorEmail
Required
public readonly authorEmail: string;
- Type: string
- Default: $GIT_USER_EMAIL
Author's e-mail.
authorName
Required
public readonly authorName: string;
- Type: string
- Default: $GIT_USER_NAME
Author's name.
version
Required
public readonly version: string;
- Type: string
- Default: "0.1.0"
Version of the package.
classifiers
Optional
public readonly classifiers: string[];
- Type: string[]
A list of PyPI trove classifiers that describe the project.
description
Optional
public readonly description: string;
- Type: string
A short description of the package.
homepage
Optional
public readonly homepage: string;
- Type: string
A URL to the website of the project.
license
Optional
public readonly license: string;
- Type: string
License of this package as an SPDX identifier.
packageName
Optional
public readonly packageName: string;
- Type: string
Package name.
poetryOptions
Optional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;
Additional options to set for poetry if using poetry.
setupConfig
Optional
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
Name | Type | Description |
---|---|---|
| string | This is the name of your project. |
| boolean | Whether to commit the managed files by default. |
| projen.IgnoreFileOptions | Configuration options for .gitignore file. |
| projen.GitOptions | Configuration options for git. |
| projen.LoggerOptions | Configure logging options such as verbosity. |
| string | The root directory of the project. |
| projen.Project | The parent project, if this project is part of a bigger project. |
| string | The shell command to use in order to run the projen CLI. |
| boolean | Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation. |
| projen.ProjenrcJsonOptions | Options for .projenrc.json. |
| boolean | Use renovatebot to handle dependency upgrades. |
| projen.RenovatebotOptions | Options for renovatebot. |
| projen.github.AutoApproveOptions | Enable and configure the 'auto approve' workflow. |
| boolean | Enable automatic merging on GitHub. |
| projen.github.AutoMergeOptions | Configure options for automatic merging on GitHub. |
| boolean | Add a clobber task which resets the repo to origin. |
| boolean | Add a VSCode development environment (used for GitHub Codespaces). |
| boolean | Enable GitHub integration. |
| projen.github.GitHubOptions | Options for GitHub integration. |
| boolean | Add a Gitpod development environment. |
| boolean | Whether mergify should be enabled on this repository or not. |
| projen.github.MergifyOptions | Options for mergify. |
| projen.ProjectType | Which type of project this is (library/app). |
| projen.github.GithubCredentials | Choose a method of providing GitHub API access for projen workflows. |
| string | The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows. |
| projen.SampleReadmeProps | The README setup. |
| boolean | Auto-close of stale issues and pull request. |
| projen.github.StaleOptions | Auto-close stale issues and pull requests. |
| boolean | Enable VSCode integration. |
| string | Author's e-mail. |
| string | Author's name. |
| string | Version of the package. |
| string[] | A list of PyPI trove classifiers that describe the project. |
| string | A short description of the package. |
| string | A URL to the website of the project. |
| string | License of this package as an SPDX identifier. |
| string | Package name. |
|
| Additional options to set for poetry if using poetry. |
| {[ key: string ]: any} | Additional fields to pass in the setup() function if using setuptools. |
| string | Path to the python executable to use. |
| string | Name of the python package as used in imports and filenames. |
| string[] | List of runtime dependencies for this project. |
| string[] | List of dev dependencies for this project. |
| boolean | Use pip with a requirements.txt file to track project dependencies. |
| boolean | Use poetry to manage your project dependencies, virtual environment, and (optional) packaging/publishing. |
| boolean | Use projenrc in javascript. |
| projen.javascript.ProjenrcOptions | Options related to projenrc in JavaScript. |
| boolean | Use projenrc in Python. |
|
| Options related to projenrc in python. |
| boolean | Use projenrc in TypeScript. |
| projen.typescript.ProjenrcTsOptions | Options related to projenrc in TypeScript. |
| boolean | Include pytest tests. |
|
| pytest options. |
| boolean | Include sample code and test if the relevant directories don't exist. |
| string | Location of sample tests. |
| boolean | Use setuptools with a setup.py script for packaging and publishing. |
| boolean | Use venv to manage a virtual environment for installing dependencies inside. |
|
| Venv options. |
name
Required
public readonly name: string;
- Type: string
- Default: $BASEDIR
This is the name of your project.
commitGenerated
Optional
public readonly commitGenerated: boolean;
- Type: boolean
- Default: true
Whether to commit the managed files by default.
gitIgnoreOptions
Optional
public readonly gitIgnoreOptions: IgnoreFileOptions;
- Type: projen.IgnoreFileOptions
Configuration options for .gitignore file.
gitOptions
Optional
public readonly gitOptions: GitOptions;
- Type: projen.GitOptions
Configuration options for git.
logging
Optional
public readonly logging: LoggerOptions;
- Type: projen.LoggerOptions
- Default: {}
Configure logging options such as verbosity.
outdir
Optional
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.
parent
Optional
public readonly parent: Project;
- Type: projen.Project
The parent project, if this project is part of a bigger project.
projenCommand
Optional
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.
projenrcJson
Optional
public readonly projenrcJson: boolean;
- Type: boolean
- Default: false
Generate (once) .projenrc.json (in JSON). Set to false
in order to disable .projenrc.json generation.
projenrcJsonOptions
Optional
public readonly projenrcJsonOptions: ProjenrcJsonOptions;
- Type: projen.ProjenrcJsonOptions
- Default: default options
Options for .projenrc.json.
renovatebot
Optional
public readonly renovatebot: boolean;
- Type: boolean
- Default: false
Use renovatebot to handle dependency upgrades.
renovatebotOptions
Optional
public readonly renovatebotOptions: RenovatebotOptions;
- Type: projen.RenovatebotOptions
- Default: default options
Options for renovatebot.
autoApproveOptions
Optional
public readonly autoApproveOptions: AutoApproveOptions;
- Type: projen.github.AutoApproveOptions
- Default: auto approve is disabled
Enable and configure the 'auto approve' workflow.
autoMerge
Optional
public readonly autoMerge: boolean;
- Type: boolean
- Default: true
Enable automatic merging on GitHub.
Has no effect if github.mergify
is set to false.
autoMergeOptions
Optional
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.
clobber
Optional
public readonly clobber: boolean;
- Type: boolean
- Default: true, but false for subprojects
Add a clobber
task which resets the repo to origin.
devContainer
Optional
public readonly devContainer: boolean;
- Type: boolean
- Default: false
Add a VSCode development environment (used for GitHub Codespaces).
github
Optional
public readonly github: boolean;
- Type: boolean
- Default: true
Enable GitHub integration.
Enabled by default for root projects. Disabled for non-root projects.
githubOptions
Optional
public readonly githubOptions: GitHubOptions;
- Type: projen.github.GitHubOptions
- Default: see GitHubOptions
Options for GitHub integration.
gitpod
Optional
public readonly gitpod: boolean;
- Type: boolean
- Default: false
Add a Gitpod development environment.
mergify
Optional
mergify
- Deprecated: use
githubOptions.mergify
instead
public readonly mergify: boolean;
- Type: boolean
- Default: true
Whether mergify should be enabled on this repository or not.
mergifyOptions
Optional
mergifyOptions
- Deprecated: use
githubOptions.mergifyOptions
instead
public readonly mergifyOptions: MergifyOptions;
- Type: projen.github.MergifyOptions
- Default: default options
Options for mergify.
projectType
Optional
projectType
- 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).
projenCredentials
Optional
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.
projenTokenSecret
Optional
projenTokenSecret
- 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.
readme
Optional
public readonly readme: SampleReadmeProps;
- Type: projen.SampleReadmeProps
- Default: { filename: 'README.md', contents: '# replace this' }
The README setup.
Example
"{ filename: 'readme.md', contents: '# title' }"
stale
Optional
public readonly stale: boolean;
- Type: boolean
- Default: false
Auto-close of stale issues and pull request.
See staleOptions
for options.
staleOptions
Optional
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
.
vscode
Optional
public readonly vscode: boolean;
- Type: boolean
- Default: true
Enable VSCode integration.
Enabled by default for root projects. Disabled for non-root projects.
authorEmail
Required
public readonly authorEmail: string;
- Type: string
- Default: $GIT_USER_EMAIL
Author's e-mail.
authorName
Required
public readonly authorName: string;
- Type: string
- Default: $GIT_USER_NAME
Author's name.
version
Required
public readonly version: string;
- Type: string
- Default: "0.1.0"
Version of the package.
classifiers
Optional
public readonly classifiers: string[];
- Type: string[]
A list of PyPI trove classifiers that describe the project.
description
Optional
public readonly description: string;
- Type: string
A short description of the package.
homepage
Optional
public readonly homepage: string;
- Type: string
A URL to the website of the project.
license
Optional
public readonly license: string;
- Type: string
License of this package as an SPDX identifier.
packageName
Optional
public readonly packageName: string;
- Type: string
Package name.
poetryOptions
Optional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;
Additional options to set for poetry if using poetry.
setupConfig
Optional
public readonly setupConfig: {[ key: string ]: any};
- Type: {[ key: string ]: any}
Additional fields to pass in the setup() function if using setuptools.
pythonExec
Optional
public readonly pythonExec: string;
- Type: string
- Default: "python"
Path to the python executable to use.
moduleName
Required
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.
deps
Optional
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()
.
devDeps
Optional
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()
.
pip
Optional
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.
poetry
Optional
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
.
projenrcJs
Optional
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
.
projenrcJsOptions
Optional
public readonly projenrcJsOptions: ProjenrcOptions;
- Type: projen.javascript.ProjenrcOptions
- Default: default options
Options related to projenrc in JavaScript.
projenrcPython
Optional
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
.
projenrcPythonOptions
Optional
public readonly projenrcPythonOptions: ProjenrcOptions;
- Type: ProjenrcOptions
- Default: default options
Options related to projenrc in python.
projenrcTs
Optional
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.
projenrcTsOptions
Optional
public readonly projenrcTsOptions: ProjenrcTsOptions;
- Type: projen.typescript.ProjenrcTsOptions
- Default: default options
Options related to projenrc in TypeScript.
pytest
Optional
public readonly pytest: boolean;
- Type: boolean
- Default: true
Include pytest tests.
pytestOptions
Optional
public readonly pytestOptions: PytestOptions;
- Type: PytestOptions
- Default: defaults
pytest options.
sample
Optional
public readonly sample: boolean;
- Type: boolean
- Default: true
Include sample code and test if the relevant directories don't exist.
sampleTestdir
Optional
public readonly sampleTestdir: string;
- Type: string
- Default: "tests"
Location of sample tests.
Typically the same directory where project tests will be located.
setuptools
Optional
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.
venv
Optional
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.
venvOptions
Optional
public readonly venvOptions: VenvOptions;
- Type: VenvOptions
- Default: defaults
Venv options.
PythonSampleOptions
Options for python sample code.
Initializer
import { python } from 'projen'
const pythonSampleOptions: python.PythonSampleOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Sample code directory. |
dir
Required
public readonly dir: string;
- Type: string
Sample code directory.
RequirementsFileOptions
Initializer
import { python } from 'projen'
const requirementsFileOptions: python.RequirementsFileOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
|
| Provide a list of packages that can be dynamically updated. |
packageProvider
Optional
public readonly packageProvider: IPackageProvider;
- Type: IPackageProvider
Provide a list of packages that can be dynamically updated.
SetupPyOptions
Fields to pass in the setup() function of setup.py.
Initializer
import { python } from 'projen'
const setupPyOptions: python.SetupPyOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| {[ key: string ]: any} | Escape hatch to allow any value. |
| string | Author's e-mail. |
| string | Author's name. |
| string[] | A list of PyPI trove classifiers that describe the project. |
| string | A short project description. |
| string | Package's Homepage / Website. |
| string | The project license. |
| string | Name of the package. |
| string[] | List of submodules to be packaged. |
| string | Manually specify package version. |
additionalOptions
Optional
public readonly additionalOptions: {[ key: string ]: any};
- Type: {[ key: string ]: any}
Escape hatch to allow any value.
authorEmail
Optional
public readonly authorEmail: string;
- Type: string
Author's e-mail.
authorName
Optional
public readonly authorName: string;
- Type: string
Author's name.
classifiers
Optional
public readonly classifiers: string[];
- Type: string[]
A list of PyPI trove classifiers that describe the project.
description
Optional
public readonly description: string;
- Type: string
A short project description.
homepage
Optional
public readonly homepage: string;
- Type: string
Package's Homepage / Website.
license
Optional
public readonly license: string;
- Type: string
The project license.
name
Optional
public readonly name: string;
- Type: string
Name of the package.
packages
Optional
public readonly packages: string[];
- Type: string[]
List of submodules to be packaged.
version
Optional
public readonly version: string;
- Type: string
Manually specify package version.
SetuptoolsOptions
Initializer
import { python } from 'projen'
const setuptoolsOptions: python.SetuptoolsOptions = { ... }
Properties
Name | Type | Description |
---|---|---|
| string | Author's e-mail. |
| string | Author's name. |
| string | Version of the package. |
| string[] | A list of PyPI trove classifiers that describe the project. |
| string | A short description of the package. |
| string | A URL to the website of the project. |
| string | License of this package as an SPDX identifier. |
| string | Package name. |
|
| Additional options to set for poetry if using poetry. |
| {[ key: string ]: any} | Additional fields to pass in the setup() function if using setuptools. |
| string | Path to the python executable to use. |
authorEmail
Required
public readonly authorEmail: string;
- Type: string
- Default: $GIT_USER_EMAIL
Author's e-mail.
authorName
Required
public readonly authorName: string;
- Type: string
- Default: $GIT_USER_NAME
Author's name.
version
Required
public readonly version: string;
- Type: string
- Default: "0.1.0"
Version of the package.
classifiers
Optional
public readonly classifiers: string[];
- Type: string[]
A list of PyPI trove classifiers that describe the project.
description
Optional
public readonly description: string;
- Type: string
A short description of the package.
homepage
Optional
public readonly homepage: string;
- Type: string
A URL to the website of the project.
license
Optional
public readonly license: string;
- Type: string
License of this package as an SPDX identifier.
packageName
Optional
public readonly packageName: string;
- Type: string
Package name.
poetryOptions
Optional
public readonly poetryOptions: PoetryPyprojectOptionsWithoutDeps;
Additional options to set for poetry if using poetry.
setupConfig
Optional
public readonly setupConfig: {[ key: string ]: any};
- Type: {[ key: string ]: any}
Additional fields to pass in the setup() function if using setuptools.
pythonExec
Optional
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
Name | Type | Description |
---|---|---|
| string | Name of directory to store the environment in. |
| string | Path to the python executable to use. |
envdir
Optional
public readonly envdir: string;
- Type: string
- Default: ".env"
Name of directory to store the environment in.
pythonExec
Optional
public readonly pythonExec: string;
- Type: string
- Default: "python"
Path to the python executable to use.
Protocols
IPackageProvider
- Implemented By: IPackageProvider
Properties
Name | Type | Description |
---|---|---|
| projen.Dependency[] | An array of packages (may be dynamically generated). |
packages
Required
public readonly packages: Dependency[];
- Type: projen.Dependency[]
An array of packages (may be dynamically generated).
IPythonDeps
- Implemented By: Pip, Poetry, IPythonDeps
Methods
Name | Description |
---|---|
| Adds a runtime dependency. |
| Adds a dev dependency. |
| Installs dependencies (called during post-synthesis). |
addDependency
public addDependency(spec: string): void
Adds a runtime dependency.
spec
Required
- Type: string
Format <module>@<semver>
.
addDevDependency
public addDevDependency(spec: string): void
Adds a dev dependency.
spec
Required
- Type: string
Format <module>@<semver>
.
installDependencies
public installDependencies(): void
Installs dependencies (called during post-synthesis).
Properties
Name | Type | Description |
---|---|---|
| projen.Task | A task that installs and updates dependencies. |
installCiTask
Required
public readonly installCiTask: Task;
- Type: projen.Task
A task that installs and updates dependencies.
IPythonEnv
- Implemented By: Poetry, Venv, IPythonEnv
Methods
Name | Description |
---|---|
| 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
- Implemented By: Poetry, Setuptools, IPythonPackaging
Properties
Name | Type | Description |
---|---|---|
| projen.Task | A task that uploads the package to a package repository. |
publishTask
Required
public readonly publishTask: Task;
- Type: projen.Task
A task that uploads the package to a package repository.