Coder Social home page Coder Social logo

nx-plugins's People

Contributors

ap0nia avatar bbrandt avatar dependabot[bot] avatar kylebjordahl avatar lucasvieirasilva avatar niall-madecurious avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nx-plugins's Issues

Check Poetry Command Exit Code

Currently, all the commands that run poetry CLI use spawn.sync which does not throw an exception when the exit code is not zero,

The correct behavior is when the command returns an exit code different than zero, throws an exception.

Migrating nrwl to nx

  • I'd be willing to implement this feature

Description

So I'm using @nxlv/python. Just want to know if you were considering to update your nx packages

https://blog.nrwl.io/nx-16-is-here-69584ec87053

Motivation

 >  NX   Cannot find module '@nrwl/devkit'

   Require stack:
   - /project/node_modules/@nxlv/python/src/graph/dependency-graph.js
   - /project/node_modules/@nxlv/python/src/index.js
   - /project/node_modules/nx/src/utils/nx-plugin.js

Local dependency error when building project

Current Behavior

In our project we created a python application and a library using the @nxlv/python plugin.

When adding the library as a local dependency the application stops building.

Error message:

 • Adding pylib1 local dependency

   ERROR  Cannot read properties of undefined (reading 'push')


 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Running target build for project query_api and 1 task it depends on failed

   Failed tasks:
   
   - query_api:build
   
   Hint: run the command with --verbose for more details.

Commands I ran>

npx nx generate @nxlv/python:poetry-project pylib1 --projectType library --directory libs/pylib1 --description='My Library 1' --packageName=pylib1 --moduleName=pylib1
npx nx run query_api:add --name pylib1 --local
npx nx run query_api:build

Expected Behavior

Build should work fine after referencing the local library.

Steps to Reproduce

  1. In an existing nx typescript monorepo project create a python project. npx nx generate @nxlv/python:poetry-project query_api --directory apps/python --description "New AI Project" --linter flake8 --unitTestRunner pytest --unitTestHtmlReport true --verbose
  2. Migrate to shared venv npx nx generate @nxlv/python:migrate-to-shared-venv
  3. Create a lib npx nx generate @nxlv/python:poetry-project pylib1 --projectType library --directory libs/pylib1 --description='My Library 1' --packageName=pylib1 --moduleName=pylib1
  4. Reference the lib in the project npx nx run query_api:add --name pylib1 --local
  5. Try to build the project npx nx run query_api:build --verbose

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.11.0
   OS     : darwin-arm64
   npm    : 10.2.4
   
   nx                 : 17.2.8
   @nx/js             : 17.2.8
   @nx/jest           : 17.2.8
   @nx/linter         : 17.2.8
   @nx/eslint         : 17.2.8
   @nx/workspace      : 17.2.8
   @nx/angular        : 17.2.8
   @nx/cypress        : 17.2.8
   @nx/devkit         : 17.2.8
   @nx/esbuild        : 17.2.8
   @nx/eslint-plugin  : 17.2.8
   @nx/nest           : 17.2.8
   @nx/node           : 17.2.8
   @nrwl/tao          : 17.2.8
   @nx/web            : 17.2.8
   @nx/webpack        : 17.2.8
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @nxlv/python : 17.0.0
   ng-mocks     : 14.12.1

Failure Logs

[NX CLOUD] Verifying current cloud bundle
[NX CLOUD] A local bundle currently exists:  {
  version: '2402.08.4',
  fullPath: 'CENSORED'
}
[NX CLOUD] Last verification was more than 30 minutes ago, verifying bundle is still valid
[NX CLOUD] Currently installed bundle is invalid, downloading version 2402.08.4  from  https://cloud.nx.app/nx-cloud/static/client-bundle
[NX CLOUD] Done:  CENSORED

 >  NX   Running target build for project query_api and 1 task it depends on:

 
[Nx Cloud] Unable to detect a VCS context from the environment.

 >  NX   RunStart

   
{
  "meta": {},
  "branch": null,
  "runGroup": "3535a7c27d6c226e3d0ab7ed81d8b3604f04d90e",
  "ciExecutionId": null,
  "ciExecutionEnv": "",
  "hashes": [
    "13006758906256864853",
    "15094654139077721979"
  ],
  "machineInfo": {
    "machineId": "vs+wz8RinmFRAylcXFOK0g==",
    "platform": "darwin",
    "version": "Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:59 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6030",
    "cpuCores": 11
  },
  "vcsContext": null
}


 >  NX   Connection to Nx Cloud failed with status code 401

   This workspace is more than a week old and is not connected. Workspaces must be connected within 7 days of creation. Claim your workspace at https://cloud.nx.app


 >  NX   Nx Cloud: Cache miss 15094654139077721979.

/Users/vszm/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
Warning: poetry-plugin-export will not be installed by default in a future version of Poetry.
In order to avoid a breaking change and make your automation forward-compatible, please install poetry-plugin-export explicitly. See https://python-poetry.org/docs/plugins/#using-plugins for details on how to install a plugin.
To disable this warning run 'poetry config warnings.export false'.
/Users/vszm/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
Building pylib1 (1.0.0)
  - Building sdist
fatal: not a git repository (or any of the parent directories): .git
  - Built pylib1-1.0.0.tar.gz
  - Building wheel
fatal: not a git repository (or any of the parent directories): .git
  - Built pylib1-1.0.0-py3-none-any.whl

> nx run pylib1:build


shared virtual environment detected and not activated, activating...



  Building project  pylib1 ...

  Copying project files to a temporary folder
  Resolving dependencies...
  Generating sdist and wheel artifacts
Running command: poetry build at /var/folders/4j/hyq8n58s6f9gg8_t857xfh5m0000gn/T/nx-python/build/a8398f44-718e-4bf6-9366-e0d1cc960db7 folder

  Artifacts generated at libs/pylib1/dist folder

 >  NX   Nx Cloud: Cache miss 13006758906256864853.


> nx run query_api:build 2


shared virtual environment detected and not activated, activating...



  Building project  query_api ...

  Copying project files to a temporary folder
  Resolving dependencies...
/Users/vszm/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
Warning: poetry-plugin-export will not be installed by default in a future version of Poetry.
In order to avoid a breaking change and make your automation forward-compatible, please install poetry-plugin-export explicitly. See https://python-poetry.org/docs/plugins/#using-plugins for details on how to install a plugin.
To disable this warning run 'poetry config warnings.export false'.
    • Adding aniso8601==9.0.1  dependency
    • Adding annotated-types==0.6.0  dependency
    • Adding anyio==4.2.0  dependency
    • Adding blinker==1.7.0  dependency
    • Adding certifi==2023.11.17  dependency
    • Adding click==8.1.7  dependency
    • Adding colorama==0.4.6  dependency
    • Adding distro==1.9.0  dependency
    • Adding dnspython==2.5.0  dependency
    • Adding et-xmlfile==1.1.0  dependency
    • Adding exceptiongroup==1.2.0  dependency
    • Adding flake8==7.0.0  dependency
    • Adding flask-restful==0.3.10  dependency
    • Adding flask==3.0.1  dependency
    • Adding h11==0.14.0  dependency
    • Adding httpcore==1.0.2  dependency
    • Adding httpx==0.26.0  dependency
    • Adding idna==3.6  dependency
    • Adding importlib-metadata==7.0.1  dependency
    • Adding itsdangerous==2.1.2  dependency
    • Adding jinja2==3.1.3  dependency
    • Adding markupsafe==2.1.4  dependency
    • Adding mccabe==0.7.0  dependency
    • Adding numpy==1.26.3  dependency
    • Adding openai==1.10.0  dependency
    • Adding openpyxl==3.1.2  dependency
    • Adding pandas==2.2.0  dependency
    • Adding pino==0.6.0  dependency
    • Adding pycodestyle==2.11.1  dependency
    • Adding pydantic-core==2.16.1  dependency
    • Adding pydantic==2.6.0  dependency
    • Adding pyflakes==3.2.0  dependency
    • Adding pylib1 local dependency

   ERROR  Cannot read properties of undefined (reading 'push')


 

 >  NX   Running target build for project query_api and 1 task it depends on failed

   Failed tasks:
   
   - query_api:build
   
   Hint: run the command with --verbose for more details.


 >  NX   Nx Cloud Problems

   - 401: Unable to connect to Nx Cloud.

Additional Information

No response

fs_extra_1.rmSync is not a function

Current Behavior

Looks like rmSync is not found when called upon during the build process

npm run build <app_name>

| => npm run build <app_name>

> [email protected] build ...
> nx build "<app_name>"


> nx run app-name:build


  Building project  app-name ...

  Copying project files to a temporary folder
  Resolving dependencies...
The lock file does not exist. Locking.
The currently activated Python version 3.10.9 is not supported by the project (>=3.8,<3.10).
Trying to find and use a compatible version. 
Using python3.9 (3.9.16)
Creating virtualenv app-name in /app-name/.venv
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file


   ERROR  (0 , fs_extra_1.rmSync) is not a function


 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target build for project app-name (1s)
 
    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]
 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `nx build "app-name"`
npm ERR! Exit status 1

Build command:

"build": {
      "executor": "@nxlv/python:build",
      "outputs": ["apps/app-name/dist"],
      "options": {
        "outputPath": "apps/app-name/dist",
        "publish": true,
        "lockedVersions": true,
        "bundleLocalDependencies": true
      }
    },

node_modules/fs-extra/lib/remove/index.js

'use strict'

const fs = require('graceful-fs')
const u = require('universalify').fromCallback

function remove (path, callback) {
  fs.rm(path, { recursive: true, force: true }, callback)
}

function removeSync (path) {
  fs.rmSync(path, { recursive: true, force: true })
}

module.exports = {
  remove: u(remove),
  removeSync
}

package.json

...
  "devDependencies": {
    "@nrwl/cli": "14.8.5",
    "@nrwl/devkit": "^15.7.2",
    "@nrwl/workspace": "14.8.5",
    "@nxlv/python": "^15.5.0",
    "nx": "14.8.5",
    "prettier": "^2.6.2",
    "typescript": "~4.8.2"
  },
  "dependencies": {
    "fs-extra": "^11.1.0"
  }
| => poetry --version
Poetry (version 1.3.2)

Expected Behavior

npm run build app-name for a python app should build correctly.

Steps to Reproduce

  1. npx create-nx-workspace project-name --empty
  2. npm install @nxlv/python --save-dev
  3. curl -sSL https://install.python-poetry.org | python3 -
  4. nx generate @nxlv/python:project app-name
  5. npm run build app-name

Nx Report

| => nx report

 >  NX   Report complete - copy this into the issue template

   Node : 19.6.0
   OS   : darwin x64
   npm  : 9.4.0
   
   nx : 14.8.5
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.7.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.8.5
   @nrwl/js : Not Found
   @nrwl/linter : 14.8.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 14.8.5
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
   	 @nxlv/python: 15.5.0

Failure Logs

No response

Additional Information

No response

Support for ruff

  • I'd be willing to implement this feature

Description

I see flake8 is supported - would be good to have ruff support as well

Motivation

ruff is becoming popular and much faster than flake8 :)

Suggested Implementation

Im not too good with nx plugins ... but I think a new "executor" which handles ruff ?

Alternate Implementations

use the ol' run-command in nx would be an alternative that works

Build fails on requirements.txt schema not followed correctly

Current Behavior

Since python-poetry/poetry-plugin-export#258 was merged, the temporary requirements.txt format's changed. This makes local project dependencies unparseable, making the build fail.

Relevant snippets

tailored output

npx nx run myapp:build --skip-nx-cache

   ⠸    Nx is waiting on 1 dependent project tasks before running tasks from myapp...
  - Built mylib-1.0.0.tar.gz

   ✔    1/1 dependent project tasks succeeded [0 read from cache]


> nx run myapp:build


  Building project  myapp ...

  Copying project files to a temporary folder
  Resolving dependencies...
    • Adding -e file:///Users/user/path-to-project/libs/mylib ==undefined dependency

   ERROR  Package -e file:///Users/user/path-to-project/libs/mylib  not found in poetry.lock


 >  NX   Ran target build for project myapp and 1 task(s) they depend on (1s)
 
    ✖    1/2 failed
    ✔    1/2 succeeded [0 read from cache]
 

requirements.txt with [email protected]

aniso8601==9.0.1 ; python_version >= "3.9" and python_version < "3.11"
mylib @ file:///Users/user/path-to-project/libs/mylib ; python_version >= "3.9" and python_version < "3.11"
annotated-types==0.6.0 ; python_version >= "3.9" and python_version < "3.11"
anyio==4.3.0 ; python_version >= "3.9" and python_version < "3.11"
.
.
.

requirements.txt with [email protected]

-e file:///Users/user/path-to-project/libs/mylib ; python_version >= "3.9" and python_version < "3.11"
aniso8601==9.0.1 ; python_version >= "3.9" and python_version < "3.11"
annotated-types==0.6.0 ; python_version >= "3.9" and python_version < "3.11"
anyio==4.3.0 ; python_version >= "3.9" and python_version < "3.11"
.
.
.

Expected Behavior

build succeeds

Steps to Reproduce

1. install latest poetry-export-plugin

poetry self add  poetry-plugin-export@latest

2. watch the build fail

npx nx run myapp:build

Nx Report

Node   : 20.10.0
   OS     : darwin-arm64
   npm    : 10.2.3
   
   nx                 : 17.2.8
   @nx/js             : 17.2.8
   @nx/jest           : 17.2.8
   @nx/linter         : 17.2.8
   @nx/eslint         : 17.2.8
   @nx/workspace      : 17.2.8
   @nx/angular        : 17.2.8
   @nx/cypress        : 17.2.8
   @nx/devkit         : 17.2.8
   @nx/esbuild        : 17.2.8
   @nx/eslint-plugin  : 17.2.8
   @nx/nest           : 17.2.8
   @nx/node           : 17.2.8
   @nrwl/tao          : 17.2.8
   @nx/web            : 17.2.8
   @nx/webpack        : 17.2.8
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @nxlv/python : 18.0.1
   ng-mocks     : 14.12.2

Failure Logs

No response

Additional Information

The error is in:
packages/nx-python/src/executors/build/resolvers/locked.ts:67

strategy of parsing local dependencies from requirements.txt must be rewritten.

shared migration pyproject.toml clarification

Documentation issue

I am Having a hard time understanding this line.

Does this mean that there should not be a pyproject.toml in the workspace root after the migration?

After the migration is completed, the workspace does not have the pyproject.toml in the root directory, and all the local projects are referencing the root pyproject.toml file.

  • Reporting a typo
  • Reporting a documentation bug
  • Documentation improvement
  • Documentation feedback

Is there a specific documentation page you are reporting?

https://github.com/lucasvieirasilva/nx-plugins/blob/main/packages/nx-python/README.md?plain=1#L92

Additional context or description

Provide any additional details here as needed.

The automated release is failing 🚨

🚨 The automated release from the main branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Missing package.json file.

A package.json file at the root of your project is required to release on npm.

Please follow the npm guideline to create a valid package.json file.


Good luck with your project ✨

Your semantic-release bot 📦🚀

The automated release is failing 🚨

🚨 The automated release from the main branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Cannot push to the Git repository.

semantic-release cannot push the version tag to the branch main on the remote Git repository with URL https://x-access-token:[secure]@github.com/lucasvieirasilva/nx-plugins.

This can be caused by:


Good luck with your project ✨

Your semantic-release bot 📦🚀

NX Cannot find project

Current Behavior

I'm working in a project that will have couple of Python API's, so I was searching for a way to integrate the Python to NX and I found this great plugin, but I'm facing an issue.

I created an app through the command line

pnpm exec nx generate @nxlv/python:poetry-project --name=agents --directory=src/apis --moduleName=apis-agents --packageName=apis-agents --no-interactive 


>  NX  Generating @nxlv/python:poetry-project

CREATE src/apis/agents/project.json
CREATE src/apis/agents/README.md
CREATE src/apis/agents/.python-version
CREATE src/apis/agents/apis-agents/__init__.py
CREATE src/apis/agents/apis-agents/hello.py
CREATE src/apis/agents/poetry.toml
CREATE src/apis/agents/pyproject.toml
CREATE src/apis/agents/tests/__init__.py
CREATE src/apis/agents/tests/conftest.py
CREATE src/apis/agents/tests/test_hello.py
CREATE src/apis/agents/.flake8

Everything seems to went well, with the exception that the project did not get the name I gave, instead, it changed to

{
  "name": "src-apis-agents",
  "$schema": "../../../node_modules/nx/schemas/project-schema.json",
  "projectType": "application",
  ...
}

But this is not the reason I'm here. The problem happens when I try to add a package to Poetry by running the command

pnpx nx run src-apis-agents:add os                 
.../Library/pnpm/store/v3/tmp/dlx-40561  | +111 +++++++++++
.../Library/pnpm/store/v3/tmp/dlx-40561  | Progress: resolved 120, reused 111, downloaded 0, added 111, done

 >  NX   Cannot find project 'src-apis-agents'

 ERROR  Command failed with exit code 1: nx run src-apis-agents:add os

pnpm: Command failed with exit code 1: nx run src-apis-agents:add os
    at makeError (/Users/griiettner/.cache/node/corepack/pnpm/8.6.11/dist/pnpm.cjs:24890:17)
    at handlePromise (/Users/griiettner/.cache/node/corepack/pnpm/8.6.11/dist/pnpm.cjs:25461:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler [as dlx] (/Users/griiettner/.cache/node/corepack/pnpm/8.6.11/dist/pnpm.cjs:210334:7)
    at async /Users/griiettner/.cache/node/corepack/pnpm/8.6.11/dist/pnpm.cjs:219737:21
    at async main (/Users/griiettner/.cache/node/corepack/pnpm/8.6.11/dist/pnpm.cjs:219704:34)
    at async runPnpm (/Users/griiettner/.cache/node/corepack/pnpm/8.6.11/dist/pnpm.cjs:219960:5)
    at async /Users/griiettner/.cache/node/corepack/pnpm/8.6.11/dist/pnpm.cjs:219952:7

As you can see, it start running and it fails.

For some reason, it does not understand the project exists, but if I go to the NX Console in VSCode, I can see the project there

image

Expected Behavior

Expect the package to be installed correctly without error

Steps to Reproduce

Nx Report

NX   Report complete - copy this into the issue template

   Node   : 18.12.0
   OS     : darwin-arm64
   pnpm   : 8.6.11
   
   nx (global)    : 17.0.2
   nx             : 17.0.2
   @nx/js         : 17.0.2
   @nx/workspace  : 17.0.2
   @nx/devkit     : 17.0.2
   @nrwl/tao      : 17.0.2
   typescript     : 5.1.6


### Failure Logs

_No response_

### Additional Information

_No response_

Need new version for Nx@18

Current Behavior

Cannot add @nxlv/python plugin to workspace with Nx 18

Expected Behavior

Plugin installs

Steps to Reproduce

  1. npm install @nxlv/[email protected]

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.11.1
OS     : darwin-arm64
npm    : 10.2.4

nx                 : 18.0.6
@nx/js             : 18.0.6
@nx/linter         : 18.0.6
@nx/eslint         : 18.0.6
@nx/workspace      : 18.0.6
@nx/cypress        : 18.0.6
@nx/devkit         : 18.0.6
@nx/eslint-plugin  : 18.0.6
@nx/react          : 18.0.6
@nx/remix          : 18.0.6
@nrwl/tao          : 18.0.6
@nx/vite           : 18.0.6
@nx/web            : 18.0.6
typescript         : 5.3.3

Failure Logs

Executing task: npm install  @nxlv/[email protected] 

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @kb_nx_architect/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/nx
npm ERR!   dev nx@"18.0.6" from the root project
npm ERR!   peer nx@">= 16 <= 18" from @nx/[email protected]
npm ERR!   node_modules/@nx/devkit
npm ERR!     peer @nx/devkit@"^17.0.0" from @nxlv/[email protected]
npm ERR!     node_modules/@nxlv/python
npm ERR!       @nxlv/python@"17.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer nx@"^17.0.0" from @nxlv/[email protected]
npm ERR! node_modules/@nxlv/python
npm ERR!   @nxlv/python@"17.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /Users/kyle/.npm/_logs/2024-03-03T00_35_14_316Z-eresolve-report.txt

Additional Information

Per release notes, v18 was a major release due to Project Crystal, but contains no breaking changes. Support for v18 in this plugin should be a simple as fixing the peer dependency.

While this can be circumvented with --force that leads to errors/warnings on subsequent NPM installs.

Python 3.10 and 3.11 not working with Tox, Python environment not created

Current Behavior

Tox fails with more recent Python versions.

[Errno 2] No such file or directory: '<REDACTED>/nx-experiment-2/packages/example/.venv/bin/python'

Expected Behavior

Tox runs successfully on more recent versions of Python.

Steps to Reproduce

  1. configure a project from scratch exactly as in https://betterprogramming.pub/poetry-python-nx-monorepo-5750d8627024
  2. apply the diff below (use example as package name) to change to Python 3.10, 3.11:
diff --git a/packages/example/pyproject.toml b/packages/example/pyproject.toml
index 6022c95..ae3ee66 100644
--- a/packages/example/pyproject.toml
+++ b/packages/example/pyproject.toml
@@ -21,7 +21,7 @@ readme = 'README.md'
   include = "example"
 
   [tool.poetry.dependencies]
-  python = ">=3.8,<3.10"
+  python = ">=3.10,<3.12"
 

 
diff --git a/packages/example/tox.ini b/packages/example/tox.ini
index a57f2cd..5d5f203 100644
--- a/packages/example/tox.ini
+++ b/packages/example/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 isolated_build = True
-envlist = py38
+envlist = py310, py311
 
 [testenv]
 whitelist_externals =

Tox runs without the diff, but fails with it.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 16.16.0
   OS   : darwin x64
   npm  : 8.11.0
   
   nx            : 15.8.6
   @nrwl/cli     : 15.8.6
   @nrwl/devkit  : 15.8.6
   @nrwl/tao     : 15.8.6
   typescript    : 4.9.5
   ---------------------------------------
   Community plugins:
   @nxlv/python : 15.5.1

Failure Logs

No response

Additional Information

Doing a delta of the logs, we can see that without the diff above (when it works) it shows:

py38 create: (...)

But with the diff, the logs don't show a py310 create and instead it goes immediately to:

py310 inst-nodeps

I'm using Poetry 1.3.2.

Add executor does not update root lock if project is in dependency group

Current Behavior

If a project is listed in the root pyproject.toml as part of a dependency group (not in the rootPyprojectToml.tool.poetry.dependencies collection) then updateDependencyTree fails to detect that the root pyproject requires re-locking when running the add target

Expected Behavior

Running the add target for any python project depended on in the root pyproject causes that pyproject to be relocked.

Steps to Reproduce

  1. Create new shared venv workspace
  2. add new python project with a root dependency group (anything other than blank)
  3. add a non-local dependency to the app
  4. see that root poetry.lock does not contain the added non-local dependency

Nx Report

Node   : 20.11.1
OS     : darwin-arm64
npm    : 10.2.4

nx             : 18.1.2
@nx/js         : 18.1.2
@nx/workspace  : 18.1.2
@nx/devkit     : 18.1.2
@nrwl/tao      : 18.1.2
typescript     : 5.4.3
---------------------------------------
Community plugins:
@nxlv/python : 18.0.0

Failure Logs

No response

Additional Information

I have a fix, PR coming shortly

nx/python: --lock option missing in remove executor when shared environment is used

Current Behavior

When using the remove executor with the nx/python plugin with shared environment activated, the executor install de dependencies in project virtual environment.

Expected Behavior

The behavior should be the same as with the add and update executor. They both use the --lock on their underlying poetry command. The remove executor do not.

Code for remove:

const removeArgs = ['remove', dependencyName].concat(
  options.args ? options.args.split(' ') : []
);
runPoetry(removeArgs, { cwd: projectConfig.root });

Code for add:

const installArgs = ['add', options.name]
        .concat(options.group ? ['--group', options.group] : [])
        .concat(options.args ? options.args.split(' ') : [])
        .concat(
          options.extras ? options.extras.map((ex) => `--extras=${ex}`) : []
        )
        .concat(rootPyprojectToml ? ['--lock'] : []);
runPoetry(installArgs, { cwd: projectConfig.root });

Steps to Reproduce

  1. Run remove executor with shared environment activated

Nx Report

Not applicable

Failure Logs

No response

Additional Information

No response

Cannot install @nx-tools/nx-container due to conflicting [email protected] dependency

Current Behavior

When trying to install @nx-tools/nx-container installation fails due to conflicting dependency.

Expected Behavior

Installation should succeed.

Steps to Reproduce

  1. npm install @nxlv/python --save-dev
  2. npm install -D @nx-tools/nx-container

Nx Report

Node   : 20.8.0
   OS     : linux-x64
   npm    : 10.1.0
   
   nx             : 16.10.0
   @nx/js         : 16.10.0
   @nx/workspace  : 16.10.0
   @nx/devkit     : 16.10.0
   @nrwl/tao      : 16.10.0
   typescript     : 5.2.2
   ---------------------------------------
   Community plugins:
   @nx-tools/nx-container : 5.0.3
   @nxlv/python           : 16.1.2

Failure Logs

~/R/my-package (main|✚1) $ npm install -D @nx-tools/nx-container
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/tslib
npm ERR!   tslib@"^2.3.0" from @nrwl/[email protected]
npm ERR!   node_modules/@nrwl/tao
npm ERR!     @nrwl/tao@"16.10.0" from [email protected]
npm ERR!     node_modules/nx
npm ERR!       nx@"16.10.0" from @nrwl/[email protected]
npm ERR!       3 more (@nx/devkit, @nx/workspace, the root project)
npm ERR!   tslib@"^2.3.0" from @nx/[email protected]
npm ERR!   node_modules/@nx/devkit
npm ERR!     @nx/devkit@"16.10.0" from @nrwl/[email protected]
npm ERR!     node_modules/@nrwl/devkit
npm ERR!       @nrwl/devkit@"16.10.0" from @nx/[email protected]
npm ERR!     @nx/devkit@"16.10.0" from @nx/[email protected]
npm ERR!     node_modules/@nx/js
npm ERR!       @nx/js@"16.10.0" from @nrwl/[email protected]
npm ERR!       node_modules/@nrwl/js
npm ERR!         @nrwl/js@"16.10.0" from @nx/[email protected]
npm ERR!       1 more (the root project)
npm ERR!     2 more (@nx/workspace, @nxlv/python)
npm ERR!   6 more (@nx/js, @nx/workspace, @nxlv/python, @yarnpkg/parsers, nx, rxjs)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @nx-tools/nx-container@"*" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/tslib
npm ERR!   peer tslib@"^2.5.3" from @nx-tools/[email protected]
npm ERR!   node_modules/@nx-tools/nx-container
npm ERR!     dev @nx-tools/nx-container@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Additional Information

No response

Incompatible default for pydoc-markdown and tomli

Current Behavior

With the default tomli created by the generator:
tomli = "1.2.2"

Installing pydoc-markdown is unable to solve for versions:

Because no versions of pydoc-markdown match >4.8.0,<5.0.0
 and pydoc-markdown (4.8.0) depends on tomli (>=2.0.0,<3.0.0), pydoc-markdown (>=4.8.0,<5.0.0) requires tomli (>=2.0.0,<3.0.0).

Expected Behavior

The out-of-the-box package version defaults should work together.

Steps to Reproduce

  1. Create a new library project
  2. npx nx run new-project:install --name pydoc-markdown

Nx Report

Node : 16.14.2
   OS   : darwin arm64
   npm  : 8.5.0

   nx : 15.6.2
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.6.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.6.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.6.3
   @nrwl/js : 15.9.2
   @nrwl/linter : Not Found
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.9.2
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.6.2
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.9.2
   @nrwl/web : 15.6.2
   @nrwl/webpack : 15.9.2
   @nrwl/workspace : 15.6.2
   @nrwl/vite : Not Found
   typescript : 5.0.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
   	 @nxlv/python: 15.9.1

Failure Logs

No response

Additional Information

tomli = ">=1.2.2" works, or pydoc-markdown could be set along with the other default dev dependencies to something that works.

Support custom source dependencies when build local dependencies

  • I'd be willing to implement this feature

Description

Currently, when nx-python plugin can build workspace dependencies in 2 ways (#24) by adding bundling all the dependencies and referencing the version (this approach requires all the local dependencies to be published to a PyPI repo).

However, in some cases, also described in this comment #24 (comment) the local dependencies needs to reference a custom source (name, URL) in order to poetry resolve the dependency from the correct location.

Motivation

This change is motivated by this suggestion: #24 (comment)

Suggested Implementation

@niall-mediasuite already did some coding regarding it: niall-madecurious@2288669, should be pretty much it with a few adjustments.

Paid Support?

Does anyone offer any paid support? I am looking to integrate this into our current monorepo but we have been having some issues with our CI (Github Actions) and could use a bit help

  • I'd be willing to implement this feature

I am currently working to get NXPython integrated into an existing monorepo that has some frontend react and typescript projects. We are pretty close to getting it working but could use a bit of help to get it working. I just wanted to see if anyone does any consulting on this

Motivation

Trying to get this integrated into our production environment and could use some help

Suggested Implementation

Alternate Implementations

Add a `serve` target

  • I'd be willing to implement this feature

(I would definitely be willing to help implement this feature. But, there are a couple of things I'm not sure how to accomplish)

Description

For local development, it would be very helpful to have a "watch" mode. Other plugins generally name this target serve.

Motivation

Being able to run a script, such as a REST API, with a single command from the workspace root and have it re-run when file contents change would speed up development in workspaces using this plugin.

Suggested Implementation

I'm able to manually add a serve target that uses nodemon to the generated project.json like so:

"serve": {
    "executor": "@nxlv/python:run-commands",
    "options": {
        "command": "npx nodemon -e py --exec \"poetry run python my_project/__init__.py\"",
        "cwd": "my-project"
    }
}

I also modified __init__.py to look like this:

"""Automatically generated by Nx."""

from hello import hello

if __name__ == "__main__":
    print(hello())

But, I'm not sure that would also watch library code. I'm also not sure if nodemon is the right tool for this job or not. Since it's able to run with npx, it would prevent users from having to install additional tooling.

Alternate Implementations

A "more correct" approach would probably be to use watchmedo or something similar. nodemon has worked in my testing. But, that may not be true for everyone.

The build command makes assumptions about how to include dependnecies.

  • I'd be willing to implement this feature My current time commitments within my organisation will potentially limit my involvement. I do have some time at the moment to work on this but other priorities may change things.

Description

I'm currently looking to use this plugin to manage internal libraries within our organisation. The structure is such that we have some base libraries that most other libraries depend on and then we have applications. We don't plan on storing the applications within the nx monorepo, only the libraries. Therefore libraries will need to be built and pushed to a pypi registry to be consumed by our applications.

The current challenge I have is that because some of the libraries depend on other libraries the current implementation of this plugin results in the whole code from the base library being included in the higher level library.

The other thing I have noticed is that version numbers get re-written with specific values. Instead of the original dependency requirements such as =~2.3.0 being included, they get overridden with the values from the lock file.

Motivation

This behaviour would be beneficial because I think it results in a simpler implementation that could be useful for many members of the Python community, my organisation included.

Suggested Implementation

Ideally for our use case the implementation would be a lot simpler. Instead of copying in local dependencies they would be added as normal dependencies by looking up the package name in the pyproject.toml then injecting the current version from the pyproject.toml or using a configured version string e.g. =~2.1.0.

I'm not sure how to handle the current implementation. It could either be implemented as an arg / config option on the current build command or added as a new command all together. I have prototyped what would be required for the solution I suggested and it makes most of the current build command redundant.

I have created a branch here which supports the changes I have addressed but at the expense of all currently functionality. I don't expect it to be used in its current state but as a tool for me to test and to provide context on the changes I'm requesting.

Alternate Implementations

Adding depdendencies without poetry installed reports it was successful.

Issue
I forgot to install poetry before attempting to follow the guide. Installing a dependency for the library I created reported to work, however it then failed to build with an error about requirements.txt.

Installing poetry correctly resolved the issue.

Ideally it should fail at the dependency install step reporting the failture to run poetry.

Logs

npx nx run monorepo-test-lib1:add --name django

> nx run monorepo-test-lib1:add --name django


  Adding  django  dependency...

Running command: poetry add django at packages/monorepo-test-lib1 folder


  'django' dependency has been successfully added to the project


 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target add for project monorepo-test-lib1 (292ms)

         With additional flags:
           --name=django

npx nx run monorepo-test-lib1:build

> nx run monorepo-test-lib1:build


  Building project  monorepo-test-lib1 ...

  Copying project files to a temporary folder
  Resolving dependencies...

   ERROR  ENOENT: no such file or directory, open '/var/folders/j3/_kvfnczj74v0rmswcszb3qxm0000gn/T/nx-python/build/95d0b3e4-90a8-42fa-98a0-814f685e12f6/requirements.txt'


 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target undefined for project monorepo-test-lib1 (289ms)

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

error Command failed with exit code 1.

Chained library dependencies break `pip download`

Current Behavior

AWS SAM's build command downloads everything in the requirements.txt to a temporary directory, then runs its build over that directory when it creates the deployment package.

The current setup for the pyproject.toml files use ../some-lib as the dependency path between local libraries, which can't be resolved by pip when it's doing a download when there is more than one level of local library dependencies. If I change these references to the wheel files (eg. ../../libs/test_two/dist/test_two-1.0.0-py3-none-any.whl) then the pip error goes away, but changes to the local libraries are not reflected after builds because pip thinks that the wheels haven't changed based on the version number of the wheel.

If the application references a local library that does not have any upstream local libraries, pip download does not fail.

Expected Behavior

Chained local library dependencies should work for pip download and other pip commands that use pyproject.toml to resolve dependencies.

Steps to Reproduce

$ npx nx generate @nxlv/python:project test-one --type library --packageName=test-one --moduleName=test_one
$ npx nx generate @nxlv/python:project test-two --type library --packageName=test-two --moduleName=test_two
$ npx nx run test-two:add --name test-one --local
$ npx nx generate @nxlv/python:project test-app --type application --packageName=test-app --moduleName=test_app
$ npx nx run test-app:add --name test-two --local
$ cd apps/test-app
$ poetry export -f requirements.txt --without-hashes --output requirements.txt
$ cat requirements.txt
test-one @ file:///Users/me/src/test-python/libs/test-one ; python_version >= "3.8" and python_version < "3.11"
test-two @ file:///Users/me/src/test-python/libs/test-two ; python_version >= "3.8" and python_version < "3.11"

$ pip download -r requirements.txt --dest tmp
Processing /Users/me/src/test-python/libs/test-one (from -r requirements.txt (line 1))
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Processing /Users/me/src/test-python/libs/test-two (from -r requirements.txt (line 2))
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3108, in _dep_map
    return self.__dep_map
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2901, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 169, in exc_logging_wrapper
    status = run_func(*args)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 248, in wrapper
    return func(self, options, args)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/commands/download.py", line 132, in run
    requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 427, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 239, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 229, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 244, in get_dependencies
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 244, in <listcomp>
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 241, in iter_dependencies
    requires = self.dist.iter_dependencies() if with_requires else ()
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_internal/metadata/pkg_resources.py", line 216, in iter_dependencies
    return self._dist.requires(extras)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2821, in requires
    dm = self._dep_map
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3110, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3121, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3174, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/Users/me/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pip/_vendor/packaging/requirements.py", line 118, in __init__
    raise InvalidRequirement(f"Invalid URL: {req.url}")
pip._vendor.packaging.requirements.InvalidRequirement: Invalid URL: ../test-one

Nx Report

Node : 16.14.2
   OS   : darwin arm64
   npm  : 8.5.0

   nx : 15.6.2
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.6.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.6.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.6.3
   @nrwl/js : 15.9.2
   @nrwl/linter : Not Found
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.9.2
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.6.2
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.9.2
   @nrwl/web : 15.6.2
   @nrwl/webpack : 15.9.2
   @nrwl/workspace : 15.6.2
   @nrwl/vite : Not Found
   typescript : 5.0.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
   	 @nxlv/python: 15.7.0

Failure Logs

No response

Additional Information

As a workaround, pip download works if I remove the lines referencing the local library wheels from the exported requirements.txt.

EDIT: I thought was working but it turns out it isn't. I don't have a workaround at this point.

Support to Semantic Release

  • I'd be willing to implement this feature

Description

This is by far the best python monorepo solution that exists out there. However, the automation to release a package by updating the package versions and then publishing to a repo is not supported.

Motivation

It will automate the last piece that I think this plugin is missing: release

Suggested Implementation

I would suggest to use this: https://python-semantic-release.readthedocs.io/en/latest/ So it can detects the next version of each package.

automatically activate shared virtual environment

  • I'd be willing to implement this feature

Description

Currently, all the @nxlv/python executors (add, update, remove, build and flake8) just run poetry commands without any activation logic and let poetry decide which virtual environment to use.

However, when the workspace uses the shared virtual environment, to run all the commands the developer needs to manually activate the virtual environment.

With that being said, @nxlv/python should identify if a virtual environment is not activated and the workspace is configured to use a shared virtual environment, if yes and no virtual environment is activated, the @nxlv/python should be activated before running the poetry commands.

Motivation

Result of this discussion: #128

No license on the @nxlv/python plugin.

I have noticed there is an MIT license on the top level but this is not present in the individual package and therefore doesn't show up on NPM. I would appreciate if you could clarify the licensing on the @nxlv/python package.

Cannot set python version to 3.11 with shared-env

Current Behavior

I am trying to use python 3.11 with shared-env, I have updated the pyproject and .python-version to use ~=3.11.5 but whenever I run nx generate @nxlv/python:migrate-to-shared-venv, it will change the version in pyproject.toml into python = ">=3.9,<3.11" and .python-version to 3.9.5 and failed the command since I don't have 3.9.5 installed locally

Expected Behavior

To use 3.11.5 when running nx generate @nxlv/python:migrate-to-shared-venv

Steps to Reproduce

None

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.16.0
   OS     : darwin-arm64
   npm    : 9.5.1
   
   nx (global)  : 16.7.4
   nx           : 16.7.3
   @nx/devkit   : 16.7.4
   @nrwl/tao    : 16.7.3
   ---------------------------------------
   Community plugins:
   @nxlv/python : 16.1.2
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nx/[email protected]
     - @nrwl/[email protected]
   
   To fix this, run `nx migrate [email protected]`

Failure Logs

No response

Additional Information

No response

Shared virtual environment cannot install

Current Behavior

When installing the root directory to provide the shared virtual environment, poetry complains because I don't have an actuall root module to install (the root directory doesn't have any actual code)

The Nx workspace is named ohm in my failure logs

I believe the missing piece would be to add --no-root as a flag to the install for the shared virtual environment. Perhaps this can be an optional config somehow

Expected Behavior

Install of virtual environment should work without error.

Steps to Reproduce

Set up a shared virtual environment without any [tool.poetry.packages] entry in the root pyproject.toml

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.20.2
   OS     : linux-arm64
   npm    : 8.19.4
   
   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/cypress        : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nx/plugin         : 16.7.4
   @nx/react          : 16.7.4
   @nx/storybook      : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/web            : 16.7.4
   @nx/webpack        : 16.7.4
   nx-cloud           : 16.3.0
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @nxlv/python : 16.1.2
   nx-stylelint : 15.0.0
   ---------------------------------------
   Local workspace plugins:
         @ohm/nx-helpers

Failure Logs

UPDATE pyproject.toml
  Updating root poetry.lock...
Resolving dependencies... (5.1s)

Writing lock file
Running command: poetry install 

Installing dependencies from lock file

No dependencies to install or update

Installing the current project: ohm (1.0.0)
The current project could not be installed: No file/folder found for package ohm
If you do not want to install the current project use --no-root

  poetry.lock updated.

Additional Information

No response

Plan to Publish? Taking PR's?

Hello @lucasvieirasilva,

I have been looking for a Nx Plugin for Python development, but most plugins seems to no longer be supported. What's your outlook on this repository? I like your approach of using Poetry for dependency management. Are you accepting pull requests if I work up the courage to be able to contribute anything?

Thanks!

Local intra-project dependencies not registered

Current Behavior

Dependencies between local projects do not appear in the Nx graph.

Expected Behavior

Dependencies between projects (when added with nx run myapp:add --name=mylib --local) should result in dependencies in the output of the Nx graph.

Steps to Reproduce

  1. Scaffold two projects, myapp and mylib
  2. add one project to the other: nx run myapp:add --name=mylib --local
  3. run nx graph --file=output.json && cat output.json and inspect the graph.dependencies section
  4. No dependencies listed for myapp

Nx Report

Node   : 20.11.1
OS     : linux-arm64
npm    : 10.2.4

nx                 : 18.0.7
@nx/js             : 18.0.7
@nx/jest           : 18.0.7
@nx/linter         : 18.0.7
@nx/eslint         : 18.0.7
@nx/workspace      : 18.0.7
@nx/cypress        : 18.0.7
@nx/devkit         : 18.0.7
@nx/eslint-plugin  : 18.0.7
@nx/plugin         : 18.0.7
@nx/react          : 18.0.7
@nx/remix          : 18.0.7
@nx/storybook      : 18.0.7
@nrwl/tao          : 18.0.7
@nx/vite           : 18.0.7
@nx/web            : 18.0.7
typescript         : 5.3.3
---------------------------------------
Community plugins:
@nxlv/python : 18.0.0

Failure Logs

No response

Additional Information

Its possible that something broke as part of the change to Project Crystal in Nx@18. I'll see if I can get anything working on a fork for now.

Supporting non-poetry projects

  • I'd be willing to implement this feature

Description

I do not use poetry as of now, and just use normal python with a central venv.

So, I have a project structure as:

apps/
    my-pkg/
        project.json
        mypkg/
             __init__.py
        tests/
             __init__.py
    my-pkg2/
        project.json
        mypkg2/
             __init__.py
        tests/
             __init__.py

And in my project.json I have something like:

{
  "projectType": "application",
  "targets": {
    "install": {
      "executor": "nx:run-commands",
      "options": {
        "command": "python -m venv venv && venv/bin/pip install -e {projectRoot}"
      }
    },
    "lint": {
      "executor": "nx:run-commands",
      "options": {
        "commands": [
          "venv/bin/ruff {projectRoot}",
          "venv/bin/black --config .black.toml --check {projectRoot}",
          "node_modules/.bin/prettier --check {projectRoot}"
        ]
      }
    },
   ...
}

I would love to make this more "nx-ey" instead of using nx in this hacky way of just running commands for me.
I am trying to figure out if your python plugin could be used to handle this - or not ?

Motivation

Looking to clean up the way I use nx to leverage nx better.
I have tried https://github.com/hogarthww-labs/nx-python
and https://github.com/nx-python/PyNX
both seem to be unmaintained.

Suggested Implementation

Not sure - if there is a clear pat in your mind, I can spend some time in trying to implement it.
But note that I am pretty new to nx pugins...

Alternate Implementations

Keep using run-commands 😞

Allow overriding or customizing the template files

  • [x ] I'd be willing to implement this feature

Description

Allowing the generator files to be modified automatically to include or omit features.

Motivation

There are any number of customizations we'd like to make to the project generators, such as creating a SAM template.yaml, adding specific sections or configuration to pyproject.toml, adding or modifying tasks in project.json, and so on. We could create our own generator that calls the @nxlv generator, but that seems wasteful and somewhat difficult if all we need to do is, for example, change the pytest configuration.

Suggested Implementation

Passing in a simple --template-files-dir that overrides the location of the template files. Or somewhat more complicated, only overrides the files that are present in the additional directory. This would introduce a minimal maintenance burden.

Alternate Implementations

There may be nx conventions for generators of which I am unaware, but some other approaches are:

  • Add a features parameter to the generators that is used to toggle the presence of sections of the files or modify behavior, similar to addDevDependencies but generalized. Additional features would require code additions though.
  • Ensure that each of the functions used to perform actions in the current generator are exported and composable by another generator. An example would be the project configuration object, which is both created and directly used in the project generator function. An exported function that returns a default configuration suitable for modification would be useful to call from another generator.

Migrate to Nx V2 plugin

>  NX   @nxlv/python is a v1 plugin.

   Nx has recently released a v2 model for project graph plugins. The `processProjectGraph` method is deprecated. Plugins should use some combination of `createNodes` and `createDependencies` instead.

Setup suggestions for VSCode

Documentation issue

  • Reporting a typo
  • Reporting a documentation bug
  • [ x ] Documentation improvement
  • Documentation feedback

Is there a specific documentation page you are reporting?

We're looking for suggestions on setting up VSCode with the pyproject.toml-per-project approach. Since there isn't a single .venv for the workspace Pylance doesn't seem to quite know what to do with the individual libraries and their imports, as you can see here:

image

Pylance can't find the import, and there are no linting errors for the types on the functions.

Build errors when using dependencies from git paths.

Current Behavior

nx run test-package-django:build
  Building project  test-package-django ...

  Copying project files to a temporary folder
  Resolving dependencies...
    • Adding asgiref==3.6.0  dependency
    • Adding boto3==1.26.51  dependency
    • Adding botocore==1.29.51  dependency
    • Adding certifi==2022.12.7  dependency
    • Adding charset-normalizer==3.0.1  dependency
    • Adding django-storages==1.13.2  dependency
    • Adding django==3.2.16  dependency

  ERROR  must pass in a file:// URI to convert to a file path

Expected Behavior

I expect the build to succeed.

Steps to Reproduce

Add a dependency with a git url in the pyproject.toml e.g.

[tool.poetry.dependencies.django]
git = "https://github.com/django/django.git"
rev = "d54717118360e8679aa2bd0c5a1625f3e84712ba"

Nx Report

yarn nx report
yarn run v1.22.19
$ node_modules/.bin/nx report

 >  NX   Report complete - copy this into the issue template

   Node : 19.4.0
   OS   : darwin arm64
   yarn : 1.22.19

   nx : 15.4.5
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.4.5
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.5
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.5
   @nrwl/js : 15.4.5
   @nrwl/linter : 15.4.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : 15.4.5
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.4.5
   @nrwl/vite : Not Found
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
         @mediasuitenz/poetry-version
   ---------------------------------------
   Community plugins:
         @nxlv/python: 15.1.0

✨  Done in 4.07s.

Failure Logs

No response

Additional Information

As far as I can tell its the check that resolves local dependencies is failing using uri2path. The solution would be to only perform this resolution if the line starts with file://. This would filter out any that start with git+http:// as git repositories do.

Support Django

Hello!
Nice plugin!
Does this plugin have the ability to add Django?

docs(nx-python): how to contribute

Documentation issue

I am trying to setup nx-python locally in dev mode (npm/yarn link) but am running into issues. I think it would be beneficial for the project to add a How to contribute chapter in the docs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.