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

Jenkins node 4 has problem with Python 3.6 and locales #642

Closed
mauritsvanrees opened this issue Feb 26, 2020 · 8 comments
Closed

Jenkins node 4 has problem with Python 3.6 and locales #642

mauritsvanrees opened this issue Feb 26, 2020 · 8 comments

Comments

@mauritsvanrees
Copy link
Member

See for example this Plone 5.2 Python 3.6 job:

Getting distribution for 'buildout.requirements==0.2.2'.
WARNING: The easy_install command is deprecated and will be removed in a future version.
Traceback (most recent call last):
  File "/home/jenkins/shiningpanda/jobs/65a48de5/virtualenvs/d41d8cd9/lib/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
    yield saved
  File "/home/jenkins/shiningpanda/jobs/65a48de5/virtualenvs/d41d8cd9/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
    yield
  File "/home/jenkins/shiningpanda/jobs/65a48de5/virtualenvs/d41d8cd9/lib/python3.6/site-packages/setuptools/sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
  File "/home/jenkins/shiningpanda/jobs/65a48de5/virtualenvs/d41d8cd9/lib/python3.6/site-packages/setuptools/sandbox.py", line 45, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-pi5g09vi/buildout.requirements-0.2.2/setup.py", line 11, in <module>
    description='Plone Core Development Buildout',
  File "/tmp/easy_install-pi5g09vi/buildout.requirements-0.2.2/setup.py", line 7, in read
    
  File "/home/jenkins/shiningpanda/jobs/65a48de5/virtualenvs/d41d8cd9/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 35: ordinal not in range(128)

This is because the setup.py of this package reads a CONTRIBUTORS.rst which contains non-ascii code. But locally I can read it just fine with Python 3.6. And usually Jenkins has no problems with it either.

Any idea?
I am half inclined to just remove it in the Jenkins config, if possible.

@mauritsvanrees
Copy link
Member Author

I see this always happens on Jenkins Node 4 (syslab). See also older job.

Maybe something is configured differently there, only on Python 3.6?
Or there is a bad download of this package somewhere.

@gforcada @ale-rt Is this something you can take a look at?

@ale-rt
Copy link
Member

ale-rt commented Feb 27, 2020

Not sure how to proceed debugging.
The list of installed python3.6 packages looks identica on both node 3 and 4 (the one I can ssh into).
Should I temporarily shut down node4?
Or is there a way to not use it for the Python3. jobs?

mauritsvanrees added a commit that referenced this issue Mar 4, 2020
This replaces the buildout.requirements extension.
Good points for this extension:
- It is a proper buildout extension.
Bad points for this extension:
- It cannot be run standalone: it only gathers information while buildout is running.
- It ignores version pins for packages that buildout does not use in this run:
  if you run `bin/buildout install part1`, then version pins for other parts are ignored.
- On Jenkins node 4 with Python 3.6 the package is broken.
  #642

Good points for the new script:
- It can be run as a standalone script.
  You just need any Python with any zc.buildout version.
- It is fast: it takes maybe two seconds.
- It reports *all* version pins, not just the ones that got installed.
Bad points for the new script:
- It is not a proper buildout extension.
  We want to run it from buildout, so we need a separate section/part for it,
  using plone.recipe.command (which is even older than buildout.requirements, though it works fine on Python 3).
  But it should be fairly easy to turn this into an extension (or recipe).
- It is hardcoded to read `buildout.cfg`, including its extends.
  Should be easy enough to make this configurable with argparse/optparse/whatever.

Script adapted from: https://gist.github.com/mauritsvanrees/c47e974e418c707a626200cb6561405b
See also https://community.plone.org/t/creating-constraints-and-requirements-from-buildout-config/10296

We cannot use configparser, because buildout configs contain 'duplicate' options:

    $ grep -i chameleon versions.cfg
    Chameleon = 3.6.2
    chameleon = 3.6.2

So we use the buildout configparser.
Bonus: we automatically use the section expressions, like `[versions:python27]`.
So the end result of running this script can be different per Python version.
That is something to remember.
mauritsvanrees added a commit that referenced this issue Mar 4, 2020
This replaces the buildout.requirements extension.

Good points for this extension:
- It is a proper buildout extension.

Bad points for this extension:
- It cannot be run standalone: it only gathers information while buildout is running.
- It ignores version pins for packages that buildout does not use in this run:
  if you run `bin/buildout install part1`, then version pins for other parts are ignored.
- On Jenkins node 4 with Python 3.6 the package is broken.
  #642

Good points for the new script:
- It can be run as a standalone script.
  You just need any Python with any zc.buildout version.
- It is fast: it takes maybe two seconds.
- It reports *all* version pins, not just the ones that got installed.

Bad points for the new script:
- It is not a proper buildout extension.
  We want to run it from buildout, so we need a separate section/part for it,
  using plone.recipe.command (which is even older than buildout.requirements, though it works fine on Python 3).
  But it should be fairly easy to turn this into an extension (or recipe).
- It is hardcoded to read `buildout.cfg`, including its extends.
  Should be easy enough to make this configurable with argparse/optparse/whatever.

Script adapted from: https://gist.github.com/mauritsvanrees/c47e974e418c707a626200cb6561405b
See also https://community.plone.org/t/creating-constraints-and-requirements-from-buildout-config/10296

We cannot use configparser, because buildout configs contain 'duplicate' options:

    $ grep -i chameleon versions.cfg
    Chameleon = 3.6.2
    chameleon = 3.6.2

So we use the buildout configparser.
Bonus: we automatically use the section expressions, like `[versions:python27]`.
So the end result of running this script can be different per Python version.
That is something to remember.
@mauritsvanrees
Copy link
Member Author

I have removed the buildout.requirements extension, so this is solved now.
Replaced with an easy script.
Done on 5.2. I will do the same on 6.0.

Eventually, like spoken about in that PR, plone.versioncheck could be extended instead of using the script.

mauritsvanrees added a commit that referenced this issue Mar 5, 2020
This replaces the buildout.requirements extension.

Good points for this extension:
- It is a proper buildout extension.

Bad points for this extension:
- It cannot be run standalone: it only gathers information while buildout is running.
- It ignores version pins for packages that buildout does not use in this run:
  if you run `bin/buildout install part1`, then version pins for other parts are ignored.
- On Jenkins node 4 with Python 3.6 the package is broken.
  #642

Good points for the new script:
- It can be run as a standalone script.
  You just need any Python with any zc.buildout version.
- It is fast: it takes maybe two seconds.
- It reports *all* version pins, not just the ones that got installed.

Bad points for the new script:
- It is not a proper buildout extension.
  We want to run it from buildout, so we need a separate section/part for it,
  using plone.recipe.command (which is even older than buildout.requirements, though it works fine on Python 3).
  But it should be fairly easy to turn this into an extension (or recipe).
- It is hardcoded to read `buildout.cfg`, including its extends.
  Should be easy enough to make this configurable with argparse/optparse/whatever.

Script adapted from: https://gist.github.com/mauritsvanrees/c47e974e418c707a626200cb6561405b
See also https://community.plone.org/t/creating-constraints-and-requirements-from-buildout-config/10296

We cannot use configparser, because buildout configs contain 'duplicate' options:

    $ grep -i chameleon versions.cfg
    Chameleon = 3.6.2
    chameleon = 3.6.2

So we use the buildout configparser.
Bonus: we automatically use the section expressions, like `[versions:python27]`.
So the end result of running this script can be different per Python version.
That is something to remember.
@mauritsvanrees
Copy link
Member Author

Found it I think. The same problem happens with plone.app.locales on Python 3.6 on this node, see job 1 and job 2:

Traceback (most recent call last):
  File "/tmp/tmp_oacv4nx", line 14, in <module>
    exec(compile(f.read(), '/home/jenkins/workspace/plone-6.0-python-3.6/src/plone.app.locales/setup.py', 'exec'))
  File "/home/jenkins/workspace/plone-6.0-python-3.6/src/plone.app.locales/setup.py", line 11, in <module>
    long_description=(open('README.rst').read() + '\n' +
  File "/home/jenkins/shiningpanda/jobs/641b788a/virtualenvs/d41d8cd9/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 111: ordinal not in range(128)

I can reproduce this locally on my Mac. I have this in a shell:

$ echo $LANG 
en_GB.UTF-8
$ echo $LC_CTYPE 
UTF-8
$ echo $LC_ALL 
en_GB.UTF-8

With that it works fine on all Python versions (specifically 2.7, 3.6, 3.7).

When I call unset on these three environment variables, it still works on 2.7 and 3.7, but not on 3.6:

$ python3.6
Python 3.6.10 (default, Feb  8 2020, 17:39:49) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = open("README.rst").read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/maurits/.pyenv/versions/3.6.10/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 111: ordinal not in range(128)

So on Jenkins node 4, some locale settings should be configured.
Some hints from the wiki page of a customer:

  • In /etc/environment add the following lines:

    LC_ALL=en_US.UTF-8
    LANG=en_US.UTF-8
    
  • (Dutch specific: )There has to be a locale nl_NL.utf8. Check wih locale -a if this is in the list. Otherwise: sudo locale-gen nl_NL.utf8.

Meanwhile, I will make a PR for plone.app.locales to catch the error. It looks like open("README.rst", "rb") helps.

@ale-rt
Copy link
Member

ale-rt commented Mar 10, 2020

It seems it is like that since quite some time:

root@jenkins-plone:~# grep en_US /etc/environment 
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
root@jenkins-plone:~# locale -a | grep nl_NL
nl_NL@euro
nl_NL.iso885915@euro

I anyway ran:

Generating locales (this might take a while)...
  nl_NL.UTF-8... done
Generation complete.
root@jenkins-plone:~# locale -a | grep nl_NL
nl_NL@euro
nl_NL.iso885915@euro
nl_NL.utf8

mister-roboto pushed a commit that referenced this issue Mar 10, 2020
Branch: refs/heads/master
Date: 2020-03-10T11:37:59+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/plone.dexterity@7ccb5a0

Fixed package install error with Python 3.6 without system locale.

See #642 (comment)

Files changed:
A news/642.bugfix
M setup.py
Repository: plone.dexterity

Branch: refs/heads/master
Date: 2020-03-10T15:12:23+01:00
Author: Maurits van Rees (mauritsvanrees) <m.van.rees@zestsoftware.nl>
Commit: plone/plone.dexterity@b61d09f

Merge pull request #128 from plone/maurits/fix-long-description-on-py36

Fixed package install error with Python 3.6 without system locale.

Files changed:
A news/642.bugfix
M setup.py
@mauritsvanrees
Copy link
Member Author

Well, the Dutch locale is not needed, it was just meant as an example of how to set locales. But anyway, it looks okay. So maybe there is something else that unsets these variables at some point.

But I have merged the two PRs (plone.app.locales and plone.dexterity), so it should be fine now.

mauritsvanrees added a commit to plone/plone.outputfilters that referenced this issue Mar 10, 2020
mister-roboto pushed a commit that referenced this issue Mar 10, 2020
Branch: refs/heads/master
Date: 2020-03-10T15:57:47+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/plone.outputfilters@f18f90b

Fixed possible package install error with Python 3.6 when no system locale is set.

See #642 (comment)

Files changed:
M CHANGES.rst
M setup.py
mauritsvanrees added a commit that referenced this issue Mar 10, 2020
Needed to fix the hopefully last problems on Jenkins node 4 with Python 3.6, which seems to have no locale setting.
See #642 (comment)

Sample traceback (local):

```
While:
  Installing releaser.
Traceback (most recent call last):
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 2174, in main
    getattr(buildout, command)(args)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 817, in install
    installed_files = self[part]._call(recipe.install)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 1603, in _call
    return f()
  File "/Users/maurits/shared-eggs/cp36m/zc.recipe.egg-2.0.7-py3.6.egg/zc/recipe/egg/egg.py", line 263, in install
    relative_paths=self._relative_paths,
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1219, in scripts
    _distutils_script(spath, sname, contents, initialization, rpsetup)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1346, in _distutils_script
    return _create_script(contents, dest)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1384, in _create_script
    f.write(contents)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 96: ordinal not in range(128)
```

This is while generating the `bin/rst2html5.py` script, which fails because it contains this text:

    Copyright: © 2015 Günter Milde.
mauritsvanrees added a commit that referenced this issue Mar 10, 2020
Needed to fix the hopefully last problems on Jenkins node 4 with Python 3.6, which seems to have no locale setting.
See #642 (comment)

Sample traceback (local):

```
While:
  Installing releaser.
Traceback (most recent call last):
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 2174, in main
    getattr(buildout, command)(args)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 817, in install
    installed_files = self[part]._call(recipe.install)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 1603, in _call
    return f()
  File "/Users/maurits/shared-eggs/cp36m/zc.recipe.egg-2.0.7-py3.6.egg/zc/recipe/egg/egg.py", line 263, in install
    relative_paths=self._relative_paths,
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1219, in scripts
    _distutils_script(spath, sname, contents, initialization, rpsetup)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1346, in _distutils_script
    return _create_script(contents, dest)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1384, in _create_script
    f.write(contents)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 96: ordinal not in range(128)
```

This is while generating the `bin/rst2html5.py` script, which fails because it contains this text:

    Copyright: © 2015 Günter Milde.
@mauritsvanrees mauritsvanrees changed the title buildout.requirements sometimes fails to build on Jenkins Jenkins node 4 has problem with Python 3.6 and locales Mar 10, 2020
@mauritsvanrees
Copy link
Member Author

mauritsvanrees commented Mar 10, 2020

Update: there are still more packages that give problems.

Okay, that actually seems to be the last one. I have cleaned my egg cache locally, and with the above, it all works again.
I will make Jenkins jobs with the last remaining PRs

mister-roboto pushed a commit that referenced this issue Mar 10, 2020
Branch: refs/heads/master
Date: 2020-03-10T16:02:28+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/plone.restapi@344c4f8

Fixed package install error with Python 3.6 without locale.

See #642 (comment)

Files changed:
A news/642.bugfix
M setup.py
Repository: plone.restapi

Branch: refs/heads/master
Date: 2020-03-10T18:14:46+01:00
Author: Maurits van Rees (mauritsvanrees) <m.van.rees@zestsoftware.nl>
Commit: plone/plone.restapi@5e50f5b

Merge pull request #879 from plone/maurits/fix-long-description-on-py36

Fixed package install error with Python 3.6 without locale.

Files changed:
A news/642.bugfix
M setup.py
mister-roboto pushed a commit that referenced this issue Mar 10, 2020
Branch: refs/heads/master
Date: 2020-03-10T16:51:13+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/plone.app.robotframework@f61bcc7

Fixed package install error with Python 3.6 without locale.

See #642 (comment)

Files changed:
A news/642.bugfix
M setup.py
Repository: plone.app.robotframework

Branch: refs/heads/master
Date: 2020-03-10T18:15:16+01:00
Author: Maurits van Rees (mauritsvanrees) <m.van.rees@zestsoftware.nl>
Commit: plone/plone.app.robotframework@fb810e8

Merge pull request #119 from plone/maurits/jenkins-node-4-py36

Fixed package install error with Python 3.6 without locale.

Files changed:
A news/642.bugfix
M setup.py
mauritsvanrees added a commit that referenced this issue Mar 10, 2020
Needed to fix the hopefully last problems on Jenkins node 4 with Python 3.6, which seems to have no locale setting.
See #642 (comment)

Sample traceback (local):

```
While:
  Installing releaser.
Traceback (most recent call last):
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 2174, in main
    getattr(buildout, command)(args)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 817, in install
    installed_files = self[part]._call(recipe.install)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 1603, in _call
    return f()
  File "/Users/maurits/shared-eggs/cp36m/zc.recipe.egg-2.0.7-py3.6.egg/zc/recipe/egg/egg.py", line 263, in install
    relative_paths=self._relative_paths,
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1219, in scripts
    _distutils_script(spath, sname, contents, initialization, rpsetup)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1346, in _distutils_script
    return _create_script(contents, dest)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1384, in _create_script
    f.write(contents)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 96: ordinal not in range(128)
```

This is while generating the `bin/rst2html5.py` script, which fails because it contains this text:

    Copyright: © 2015 Günter Milde.
mauritsvanrees added a commit that referenced this issue Mar 10, 2020
Needed to fix the hopefully last problems on Jenkins node 4 with Python 3.6, which seems to have no locale setting.
See #642 (comment)

Sample traceback (local):

```
While:
  Installing releaser.
Traceback (most recent call last):
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 2174, in main
    getattr(buildout, command)(args)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 817, in install
    installed_files = self[part]._call(recipe.install)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/buildout.py", line 1603, in _call
    return f()
  File "/Users/maurits/shared-eggs/cp36m/zc.recipe.egg-2.0.7-py3.6.egg/zc/recipe/egg/egg.py", line 263, in install
    relative_paths=self._relative_paths,
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1219, in scripts
    _distutils_script(spath, sname, contents, initialization, rpsetup)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1346, in _distutils_script
    return _create_script(contents, dest)
  File "/Users/maurits/community/plone-coredev/py3/lib/python3.6/site-packages/zc/buildout/easy_install.py", line 1384, in _create_script
    f.write(contents)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in position 96: ordinal not in range(128)
```

This is while generating the `bin/rst2html5.py` script, which fails because it contains this text:

    Copyright: © 2015 Günter Milde.
@mauritsvanrees
Copy link
Member Author

Checked: all PRs have been merged last month, and I have not seen the problem anymore. Closing the issue.

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

No branches or pull requests

2 participants