Skip to content

Added: Possibility to specify extension modules.#640

Open
margru wants to merge 53 commits intopybuilder:masterfrom
margru:master
Open

Added: Possibility to specify extension modules.#640
margru wants to merge 53 commits intopybuilder:masterfrom
margru:master

Conversation

@margru
Copy link
Copy Markdown

@margru margru commented Aug 8, 2019

This is an improvement to fix #639. The extensions might be defined in project's distutils_ext_modules property as a list of dictionaries where each dictionary represents keyword arguments with values for a single Extension instance constructor. Multiple dictionaries mean multiple extensions to build. The extensions specifications are then rendered into the setup.py script via the template.

@esc
Copy link
Copy Markdown
Contributor

esc commented Aug 8, 2019

@margru thank you for you pull-request, we do appreciate it. Unfortunately, we don't have any resources at the moment to service it so please be patient.

@arcivanov
Copy link
Copy Markdown
Member

Thanks for the PR! I'm working on a major fix for the PyB with environment isolation and will look at this ASAP afterwards.

Python sources of cythonized modules can be removed from distribution.
@margru
Copy link
Copy Markdown
Author

margru commented Nov 4, 2019

this makes no sense ;)

What doesn't make sense? Can you please be more specific?

Edit: Sorry, I didn't notice that you are commenting just a specific line in the code. See my comment there...

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 4, 2019

Pull Request Test Coverage Report for Build 11064057482

Details

  • 76 of 91 (83.52%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 82.551%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/main/python/pybuilder/plugins/python/distutils_plugin.py 72 87 82.76%
Totals Coverage Status
Change from base Build 10380100976: -0.06%
Covered Lines: 5540
Relevant Lines: 6493

💛 - Coveralls

margru and others added 7 commits March 11, 2020 19:02
Before this, the options provided in the requirements.txt file appear
in the install_requires field which then causes errors (e.g. when
using cython extensions).
Change default value when ext_modules are empty and update to upstream v0.13.5 and
@arcivanov
Copy link
Copy Markdown
Member

Could you please rebase on current?

@arcivanov
Copy link
Copy Markdown
Member

@margru ?

@margru
Copy link
Copy Markdown
Author

margru commented Aug 8, 2022

@arcivanov Yeah, I will try but I don't have that much time right now to solve the conflicts. I didn't realize that the push will also update the PR...

margru and others added 23 commits June 16, 2023 12:03
Merge upstream to our patched code
Add Cython as a build dependency to setup.py
Add support for cython's compiler_directives
It contains necessary build requirements (currently only Cython if
cythonization is required).
(cherry picked from commit 0cc08a8)
It contains necessary build requirements (currently only Cython if
cythonization is required).

(cherry picked from commit 9565af3)
# Conflicts:
#	src/main/python/pybuilder/plugins/python/distutils_plugin.py
# Conflicts:
#	src/main/python/pybuilder/plugins/python/unittest_plugin.py
- Maybe related only to Win platform.
continue

with open(lic_file, "rt") as f:
with open(lic_file, "rt", encoding="utf8") as f:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really not necessary and works everywhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it worked everywhere, I wouldn't have to do this change ;) The original code was raising an error for me - UnicodeDecodeError regarding 'charmap' encoding...

Copy link
Copy Markdown
Member

@arcivanov arcivanov May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't do it in pristine test build environments though, including Windows on which we test. You can introduce terrible and intractable errors by forcing non-local file encoding the way you're doing it here.

Observe: https://github.com/pybuilder/pybuilder/actions/runs/9262689796/job/25480202283#step:3:1353

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but do you have any idea why it's raising the UnicodeDecode error in my environment? Or what settings should I check to get rid of it? Otherwise it's useless to know that it's working in the pristine build env if I cannot build it in my env... Of course, I tried to recreate the virtualenv I am using for PyBuilder development, still the same... I am working on Win64, Python 3.10.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no "Win64", except for a platform name, which doesn't say much - the CI tests also run on "Win64" and they are fine.

What version of Windows EXACTLY are you using?
Can you please run python -c 'import sys; print(sys.getdefaultencoding())' and post the output?
Can you please try using PYTHONIOENCODING=utf8 and run your pyb with this env var on and report whether it made a difference (you'd need to remove your encoding patches from your branch first though to see the effect )?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you get your Python from?

the output of the command: ascii

This isn't normal AT ALL. Windows is usually utf-16 (LE IIRC). But, more importantly, Python has been defaulting to UTF-8 since 3.6 for IO.

https://peps.python.org/pep-0528/
https://peps.python.org/pep-0529/
https://peps.python.org/pep-0540/
https://docs.python.org/3/using/windows.html#utf-8-mode
https://docs.python.org/3/library/os.html#utf8-mode

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, my fault, I launched the command in the default Python interpreter which is Python27 - I have multiple Python versions installed on my system. However, I have a virtualenv for building Pybuilder with Python310 and when I launch the command there, I get utf-8 even without setting the envvar. That, I think, makes the situation even more weird...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your source for Python? ActivePython?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, all my Python versions downloaded from https://www.python.org/.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? Any new hint on what to try?

Copy link
Copy Markdown
Author

@margru margru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merge caused that building with PyBuilder is broken:

Step #2 - "build_package_3.10": Traceback (most recent call last):
Step #2 - "build_package_3.10":   File "/usr/local/bin/pyb", line 5, in <module>
Step #2 - "build_package_3.10":     from pybuilder.cli import main
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/site-packages/pybuilder/cli.py", line 37, in <module>
Step #2 - "build_package_3.10":     from pybuilder.reactor import Reactor
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/site-packages/pybuilder/reactor.py", line 37, in <module>
Step #2 - "build_package_3.10":     from pybuilder.pluginloader import (BuiltinPluginLoader,
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/site-packages/pybuilder/pluginloader.py", line 33, in <module>
Step #2 - "build_package_3.10":     from pybuilder.pip_common import Version
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/site-packages/pybuilder/pip_common.py", line 20, in <module>
Step #2 - "build_package_3.10":     import pkg_resources
Step #2 - "build_package_3.10":   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
Step #2 - "build_package_3.10":   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
Step #2 - "build_package_3.10":   File "<frozen importlib._bootstrap>", line 672, in _load_unlocked
Step #2 - "build_package_3.10":   File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/site-packages/pybuilder/extern/__init__.py", line 74, in load_module
Step #2 - "build_package_3.10":     mod = import_module(extant)
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
Step #2 - "build_package_3.10":     return _bootstrap._gcd_import(name[level:], package, level)
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/site-packages/pybuilder/_vendor/pkg_resources/__init__.py", line 96, in <module>
Step #2 - "build_package_3.10":     from ..jaraco.text import (
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/site-packages/pybuilder/_vendor/jaraco/text/__init__.py", line 233, in <module>
Step #2 - "build_package_3.10":     files(__name__).joinpath('Lorem ipsum.txt').read_text(encoding='utf-8')
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/pathlib.py", line 1134, in read_text
Step #2 - "build_package_3.10":     with self.open(mode='r', encoding=encoding, errors=errors) as f:
Step #2 - "build_package_3.10":   File "/usr/local/lib/python3.10/pathlib.py", line 1119, in open
Step #2 - "build_package_3.10":     return self._accessor.open(self, mode, buffering, encoding, errors,
Step #2 - "build_package_3.10": FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.10/site-packages/pybuilder/_vendor/jaraco/text/Lorem ipsum.txt'
Step #2 - "build_package_3.10": Incorrect pybuilder version, expecting v0.13

@arcivanov
Copy link
Copy Markdown
Member

I dont think so - look at the local builds.

@margru
Copy link
Copy Markdown
Author

margru commented Sep 27, 2024

I didn't mean building PyBuilder, but building with PyBuilder. When I build PyBuilder based on this commit, it builds OK. But when I use that PyBuilder version to build another package, I get the mentioned error (that I don't get when using the previous commit).

EDIT: Just a note: I have set the PyBuilder version to 0.13.99.dev for my custom PyBuilder builds so that it doesn't interfere with the original PyBuilder. I don't know, if that might break something but it has been working OK for me so far...

@arcivanov
Copy link
Copy Markdown
Member

I didn't mean building PyBuilder, but building with PyBuilder.

Ah! A "couple of two" things 😄

  1. I'm always worried of the things installed in /usr because it's a system thing and who knows how it behaves.
  2. Integration tests use PyBuilder to build projects, i.e. this scenario should be covered.

Let me see if I can reproduce it locally with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to add extension modules

5 participants