-
Notifications
You must be signed in to change notification settings - Fork 251
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
Feature: Declare ext_modules and libraries in pyproject.toml #262
Feature: Declare ext_modules and libraries in pyproject.toml #262
Conversation
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
The checks are no longer working but all tests should be passing now. It would be great if someone can review this PR. |
Very nice, does it handle cython extensions? |
Not in its current format. I would be welcome to suggestions. |
Hey @bostonrwalker, I'm going to go ahead and convert this to a draft for now as the history is very messy and makes review difficult. Once you've rebased this/cleaned up history and have finalized your proposed design, please mark it as ready for review. |
Thanks. FYI the design has been finalized for a long time, I have only working through integrating changes for the past several months as well as pushing it through tests which are failing on Windows. As you can see that's been difficult from working on a Mac! |
tests/masonry/builders/fixtures/ext_pyproj_lib_build_py/README.rst
Outdated
Show resolved
Hide resolved
bfd85f8
to
65a2f2f
Compare
Add test fixture for package with C/C++ extension modules defined entirely in pyproject.toml Add test case for C/C++ extension defined entirely in pyproject.toml Add new fields to pyproject.toml; Add definitions for tool.poetry.libraries and tool.poetry.ext_modules Corrected C library build info schema Edit descriptions to allow globs for certain properties Add convert_libraries() and convert_ext_modules() methods; refactor source file validation Add libraries and ext_modules to build_setup() method Add libraries and ext_modules to package factory Fixed glob expansion logic Move initialization of Extension module to setup.py Move initialization of Extension module to setup.py Add libraries and extension modules to ProjectPackage; Add should_build_libs_and_extensions() method Fix definition of Python module Add library and ext_module files to find_files_to_add() Add validation of include_dirs Add extra_includes to find_files_to_add() to accomodate includes from C/C++/Obj-C modules; Revert validation/normalization of include_dirs in convert_libraries() and convert_ext_modules() Process library and ext_modules includes using same mechanism as tool.poetry.include; Rename extension in test case to 'extension.extension'; Use package.should_build_libs_and_extensions() instead of package.build_script Add case of mixed build.py and extension defined in pyproject.toml; Parameterize test Added test case of mixed lib declaration with build.py usage Invalid configuration when mixing build script with declared libraries/extensions Remove redundant imports Remove redundant import Clean up commented lines Clean up test case Add simple C extension test case Revert initialization of additional_files Restore setup.py [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Fix glob resolution for Python <3.10 Remove comment Remove unused import Add custom ExtBuilder Simplify source path resolution logic and correct treatment of globs Fixed compat issue with Python <3.7
for more information, see https://pre-commit.ci
* factory: merge legacy dependencies and groups This change ensures that existence of legacy "dev-dependency" section does not break when "dev" group is added for new dependencies. * package: remove redundant filtering * fix typing for `ProjectPackage.python_versions`
typechecking poetry.core.masonry Fix bugs causing tests to fail [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Add missing imoports to build.py; Use dict instead of toml.items.Table to store intermediate build info in build_ext_modules process [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Move distutils.extension.Extension import into type-checking block Fix mypy errors Define missing BuildFailed exception in setup.py; Rename test fixtures to avoid errors with Windows filenames being too long Add get_export_symbols() function to ExtBuilder in setup.py for Windows compat [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Try another fix to Windows build errors Try another fix to Windows build errors [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Remove get_export_symbols() function; Add stub functions to init C libs (for Windows compat) Add libraries to export_symbols (for Windows) [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Rename folders to avoid path length limit when compiling/linking; Fix typos Fix linking issues on Windows Removed generated binary files Revert changes to extended_no_setup test fixture Rename ext_pyproj_lib_build_py fixture Clarify module descriptions in README.rst files Fix 'extended is not a package' errors when attempting to build extended_no_setup test fixture Fix paths Fix call to SdistBuilder.build() Clean up rebase [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Fix exception message
65a2f2f
to
5a0a5c1
Compare
Hey @neersighted, I'm marking the PR as ready to review now. I mucked up the history a bit - sorry for the rookie mistakes. It's my first time making such a major contribution to a public project and also using git rebase. |
FYI we're very interested in this, but it's meaty and none of the core team yet has bandwidth to look at it. |
While I like the idea, I am concerned with how this uses
|
…n_pyproject_setuptools Migrate from distutils to setuptools
for more information, see https://pre-commit.ci
@Secrus Great feedback.
I was able to migrate the build process from
|
…nto feature_extensions_defined_in_pyproject
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Hi @bostonrwalker. After some internal discussion, the Poetry team has decided not to proceed with the proposed feature. The most serious concerns were:
Thank you for your contribution anyway. In the future, please consider discussing features with maintainers to avoid a similar situation. You can reach us on Poetry Discord or via issues/discussions in the main Poetry repo. |
PR summary
A declarative approach to extensions using pyproject.toml. Eliminates the need for build.py in many cases.
How to use
Extension modules can now be declared in pyproject.toml:
The new logic will validate this config and use it to construct a
distutils.extension.Extension
object to be passed todistutils.setup()
Config properties
The new logic adds support for all options normally passed to
distutils.extension.Extension()
, and also within the libraries argument todistutils::setup()
. The full list of supported config properties are:Extension modules [tool.poetry.ext_modules]
'c'
,'c++'
,'objc'
)C libraries [tool.poetry.libraries]
Why?
By eliminating the need for build.py in many cases, this PR better accomplishes the stated intent of Poetry (reducing project complexity).
What if I still want to use build.py?
This doesn't stop you, it just gives you another option. If your build logic is too complex (e.g. moving files around), the declarative approach may not be sufficient.
To promote clarity and to reduce the complexity of build logic, this PR doesn't allow you to mix both approaches.