Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nx-python): handle "from" for packages in pyproject.toml during the build process #184

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

ap0nia
Copy link
Contributor

@ap0nia ap0nia commented Nov 9, 2023

Current Behavior

The build breaks when I depend on a local package with a src directory.

Expected Behavior

If I correctly specify from="src" in the local package's pyproject.toml, the build should succeed. When using a typical flat package structure, it works fine. i.e. like this

../lib
├── pyproject.toml
└── awesome_package/
    └── __init__.py

More Details

I have a package: my_package. A snippet of its pyproject.toml is here:

[tool.poetry.dependencies.awsome_package]
path = "../lib"
develop = true

The local package that's being referred to has a directory structure like this.

../lib
├── pyproject.toml
└── src/
     └── awesome_package/
        └── __init__.py

The local package also has this snippet in its pyproject.toml

[[tool.poetry.packages]]
include = "awesome_package"
from = "src"

I think it would be correct behavior for the build process, i.e. nx build my_package to find the awesome_package from the ../lib/src directory.

Miscellaneous

src vs. flat layout details

Packages in the pyproject.yml can have a "from" property, which is used to accomodate the "src"
layout instead of the "flat" or "adhoc" layout. This change attempts to add prepend any
specified "from" directory to the package name.
@lucasvieirasilva
Copy link
Owner

Hey @ap0nia many thanks for the contribution, really appreciate that.
The CI is failing because it's missing code coverage for your changes, could add a test case to the build executor when the from is provided?

Here's an example: https://github.com/lucasvieirasilva/nx-plugins/blob/main/packages/nx-python/src/executors/build/executor.spec.ts#L702-L883

Thanks again!

@lucasvieirasilva lucasvieirasilva self-requested a review November 10, 2023 09:30
@lucasvieirasilva lucasvieirasilva added the bug Something isn't working label Nov 10, 2023
@ap0nia
Copy link
Contributor Author

ap0nia commented Nov 10, 2023

I copied the test case you referenced and removed some of the stuff that didn't need to be tested again. Let me know if you'd like me to trim it down anymore, or anything!

@lucasvieirasilva lucasvieirasilva merged commit 5d9a99f into lucasvieirasilva:main Nov 10, 2023
3 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 10, 2023
## [16.3.1](nx-python-v16.3.0...nx-python-v16.3.1) (2023-11-10)

### Bug Fixes

* **nx-python:** handle "from" for packages in pyproject.toml during the build process ([#184](#184)) ([5d9a99f](5d9a99f))
Copy link

🎉 This PR is included in version 16.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants