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

Added: Possibility to specify extension modules. #640

Open
wants to merge 51 commits into
base: master
Choose a base branch
from

Conversation

margru
Copy link

@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
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
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
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

coveralls commented Nov 4, 2019

Pull Request Test Coverage Report for Build 9289125205

Details

  • 77 of 92 (83.7%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 82.51%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/main/python/pybuilder/plugins/python/distutils_plugin.py 73 88 82.95%
Totals Coverage Status
Change from base Build 9262689796: -0.05%
Covered Lines: 5528
Relevant Lines: 6481

💛 - 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
Member

Could you please rebase on current?

@arcivanov
Copy link
Member

@margru ?

@margru
Copy link
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...

chylek and others added 29 commits August 26, 2022 09:27
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.
@@ -91,12 +91,12 @@ def vendorize(project, reactor, logger):
logger.warn("No license file found in package %r", package_name)
continue

with open(lic_file, "rt") as f:
with open(lic_file, "rt", encoding="utf8") as f:
Copy link
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
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
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
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
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
Author

@margru margru Jun 3, 2024

Choose a reason for hiding this comment

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

  • Windows 10 Home (10.0.19045 Build 19045), Python 3.10.4
  • the output of the command: ascii (running it after setting the PYTHONIOENCODING envvar gives utf-8)
  • I tried to set PYTHONIOENCODING=utf8 and to run build.py (not pyb as this happens when building PyBuilder locally) - the result was the same.
  • attaching the error message:
Traceback (most recent call last):
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\cli.py", line 506, in main
    summary = reactor.build(
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\reactor.py", line 234, in build
    execution_summary = self.build_execution_plan(tasks, execution_plan)
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\reactor.py", line 271, in build_execution_plan
    task_execution_summaries = self.execution_manager.execute_execution_plan(
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\execution.py", line 393, in execute_execution_plan
    summaries.append(self.execute_task(task, **kwargs))
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\execution.py", line 340, in execute_task
    task.execute(self.logger, kwargs, _executable=_executable)
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\execution.py", line 179, in execute
    executable.execute(argument_dict)
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\execution.py", line 95, in execute
    self.callable(*arguments)
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\plugins\python\vendorize_plugin.py", line 95, in vendorize
    licenses_content += "%s\n==========\n%s\n\n" % (package_name, f.read())
  File "C:\Programs\Python310\lib\encodings\cp1250.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x83 in position 64: character maps to <undefined>
F
======================================================================
FAIL: test_smoke_analyze_publish_no_integration_no_coverage (__main__.VendorizeSmokeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "d:\projectssrc\_private\pybuilder\src\integrationtest\python\smoke_itest_support.py", line 72, in smoke_test
    return run_path(self.build_py, run_name="__main__")
  File "C:\Programs\Python310\lib\runpy.py", line 269, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Programs\Python310\lib\runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Programs\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\MARTIN~1\AppData\Local\Temp\IntegrationTestSupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\build.py", line 31, in <module>
    bootstrap()
  File "c:\users\martin~1\appdata\local\temp\integrationtestsupport73nd1aq48f34ff654aaf4b3ebff1ffcf34f7d991\src\main\python\pybuilder\__init__.py", line 34, in bootstrap
    sys.exit(pybuilder.cli.main(*sys.argv[1:]))
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\projectssrc\_private\pybuilder\src\integrationtest\python\smoke_vendorize_tests.py", line 28, in test_smoke_analyze_publish_no_integration_no_coverage
    self.smoke_test("-v", "-X", "vendorize")
  File "d:\projectssrc\_private\pybuilder\src\integrationtest\python\smoke_itest_support.py", line 74, in smoke_test
    self.assertEqual(e.code, 0, "Test did not exit successfully")
AssertionError: 1 != 0 : Test did not exit successfully

----------------------------------------------------------------------
Ran 1 test in 140.909s

FAILED (failures=1)

Copy link
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
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
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
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/.

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