
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@nxlv/python
Advanced tools
@nxlv/python
plugin is designed to extend the Nx features to work with Python projects based on Poetry.
Check this article for more details: https://lucasvieirasilva.medium.com/poetry-python-nx-monorepo-5750d8627024
🔎 Extensible Dev Tools for Monorepos.
🔎 An Nx Custom Plugin to generate Python projects using Poetry, Tox and a custom dependency tree plugin
Install the npm dependency
npm install @nxlv/python --save-dev
nx.json
to add the property plugins
with @nxlv/python
value.Example:
{
...
"plugins": [
"@nxlv/python"
]
...
}
nx generate @nxlv/python:project myproject
Option | Type | Description | Required | Default |
---|---|---|---|---|
--type | string | Project type application or library | true | application |
--description | string | Project description | false | |
--directory | string | A directory where the project is placed | false | |
--packageName | string | Package name | true | |
--publishable | boolean | Speficies if the project is publishable or not | false | true |
--customSource | boolean | Speficies if the project uses custom PyPi registry | false | false |
--sourceName | string | Custom PyPi registry name | only if the --customSource is true | |
--sourceUrl | string | Custom PyPi registry url | only if the --customSource is true | |
--sourceSecondary | boolean | Custom PyPi registry secondary flag | only if the --customSource is true | true |
--tags | string | Add tags to the project | false |
nx run {project}:add --name {projectName} --local
To add a new dependency to the project use the nx run {project}:add
command detailed below. This ensures that any dependent projects are updated.
nx run {project}:add --name {dependencyName}
The @nxlv/python:sls-deploy
executor handles npx sls deploy
command for serverless framework projects.
This executor uses the @nxlv/python:build
artifacts to generate a requirements.txt
and to be used with serverless-python-requirements
plugin.
Serverless YAML example:
service: myservice
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
usePoetry: false
The property usePoetry
must be false
, so, the serverless-python-requirements
uses the requirements.txt
file generated by this executor, this is required when the project has more than 2 levels of local dependencies.
Example:
- root:
- sls-app
- local-lib1
- local-lib2
Using the native serverless-python-requirements
plugin with poetry
the 2 levels of local dependencies are not supported.
project.json
example:
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/myapp/lambda_functions",
"targets": {
"deploy": {
"executor": "@nxlv/python:sls-deploy",
"dependsOn": ["build"],
"options": {}
},
"package": {
"executor": "@nxlv/python:sls-package",
"dependsOn": ["build"],
"options": {}
},
...
"build": {
"executor": "@nxlv/python:build",
"outputs": ["apps/myapp/dist"],
"options": {
"outputPath": "apps/myapp/dist",
"publish": false
}
},
}
}
Option | Type | Description | Required | Default |
---|---|---|---|---|
--stage | string | Serverless Framework stahe name | true | |
--verbose | boolean | Serverless Framework CLI verbose flag | false | true |
--force | boolean | Serverless Framework CLI force flag | false | false |
The @nxlv/python:add
executor handles poetry add
command to provide a level of abstraction and control in the monorepo projects.
Both features updates the local workspace dependency tree to keep the lock/venv updated.
Option | Type | Description | Required | Default |
---|---|---|---|---|
--name | string | Dependency name (if local dependency use the Nx project name) | true | |
--args | string | Custom args to be used in the poetry add command | false | |
--local | boolean | Specifies if the dependency is local | false (only if the --name is a local dependency) |
The @nxlv/python:update
executor handles poetry update
command to provide a level of abstraction and control in the monorepo projects.
Both features updates the local workspace dependency tree to keep the lock/venv updated.
Option | Type | Description | Required | Default |
---|---|---|---|---|
--name | string | Dependency name (if local dependency use the Nx project name) | false | |
--args | string | Custom args to be used in the poetry update command | false | |
--local | boolean | Specifies if the dependency is local | false (only if the --name is a local dependency) |
The @nxlv/python:remove
executor handles poetry remove
command to provide a level of abstraction and control in the monorepo projects.
Both features updates the local workspace dependency tree to keep the lock/venv updated.
Option | Type | Description | Required | Default |
---|---|---|---|---|
--name | string | Dependency name (if local dependency use the Nx project name) | true | |
--args | string | Custom args to be used in the poetry remove command | false | |
--local | boolean | Specifies if the dependency is local | false (only if the --name is a local dependency) |
The @nxlv/python:build
command handles the sdist
and wheel
build generation. When the project has local dependencies the executor copies the package/dependencies recursively.
Option | Type | Description | Required | Default |
---|---|---|---|---|
--silent | boolean | Hide output text | false | false |
--outputPath | string | Output path for the python tar/whl files | true | |
--keepBuildFolder | boolean | Keep build folder | false | false |
--ignorePaths | array | Ignore folder/files on build process | false | [".venv", ".tox", "tests"] |
The @nxlv/python:flake8
handles the flake8
linting tasks and reporting generator.
Option | Type | Description | Required | Default |
---|---|---|---|---|
--silent | boolean | Hide output text | false | false |
--outputFile | string | Output pylint file path | true |
The @nxlv/python:install
handles the poetry install
command for a project.
Option | Type | Description | Required | Default |
---|---|---|---|---|
--silent | boolean | Hide output text | false | false |
--args | string | Custom arguments (e.g --group dev ) | false | |
--cacheDir | string | Custom poetry install cache directory | false | |
--verbose | boolean | Use verbose mode in the install poetry install -vv | false | false |
--debug | boolean | Use debug mode in the install poetry install -vvv | false | false |
The @nxlv/python:tox
handles tox executions for a project.
Option | Type | Description | Required | Default |
---|---|---|---|---|
--silent | boolean | Hide output text | false | false |
--args | string | Custom arguments (e.g -e py38 ) | false |
By default, the @nxlv/python
manages the projects individually, so, all the projects have their one set of dependencies and virtual environments.
However, In some cases, we want to use a shared virtual environment for the entire workspace to save some installation time in your local environment and CI tool, we use this mode when the workspace contains many projects with the same dependencies and versions that don't conflict in the workspace level.
To migrate to this mode, run the following command:
npx nx generate @nxlv/python:migrate-to-shared-venv
Option | Type | Description | Required | Default |
---|---|---|---|---|
--moveDevDependencies | boolean | Specifies if migration moves the dev dependencies from the projects to the root pyproject.toml | true | true |
FAQs
Custom NX Plugin to support the Python language
The npm package @nxlv/python receives a total of 28,562 weekly downloads. As such, @nxlv/python popularity was classified as popular.
We found that @nxlv/python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.