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

Build: makerpms.sh generates Python 2 & 3 packages at the same time #272

Closed
wants to merge 3 commits into from

Conversation

pspacek
Copy link
Contributor

@pspacek pspacek commented Nov 24, 2016

Petr Viktorin recommended me to copy the whole build directory and run
configure twice, with different values for PYTHON variable.

After thinking a bit about that, it seems as cleanest approach.
Building for two versions of Python at the same time should be
temporary state so I decided not to complicate Autotools build system
with conditional spagetti for two versions of Python.

For proper Python2/3 distiction in the two separate builds, I added
find/grep/sed combo which replaces shebangs with system-wide Python
interpreter as necessary. This is workaround for the fact that FreeIPA
does not use setuptools properly. Honza told me that proper use of
setuptools is not trivial so we decided to go with this for now.

https://fedorahosted.org/freeipa/ticket/157

@tiran
Copy link
Member

tiran commented Nov 24, 2016

AFAIK the build won't run pylint twice with the correct Python version. You could replace the configure option for pylint and the pylint command with:

$(PYTHON) -m pylint

Requires: %{name}-server-common = %{version}-%{release}
Requires: %{name}-common = %{version}-%{release}
Requires: python3-ipaclient = %{version}-%{release}
Requires: python-pyldap >= 2.4.15
Copy link
Member

Choose a reason for hiding this comment

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

python3-pyldap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed.

@pspacek
Copy link
Contributor Author

pspacek commented Nov 24, 2016

It does not automatically run pylint at all. Isn't --with-pylint option for configure good enough?

@pspacek pspacek mentioned this pull request Nov 24, 2016
3 tasks
@MartinBasti
Copy link
Contributor

Shouldn't be there python3 in BuildRequires as well? At least with python3-pylint we need python3 dependencies to be able do pylint3 validation

@pspacek
Copy link
Contributor Author

pspacek commented Nov 30, 2016

Fixed. Now with_pylint section contains nested section with_python3.

@pspacek
Copy link
Contributor Author

pspacek commented Nov 30, 2016

@mbasti-rh @jcholast @tiran
If you want I can replace the --with-pytlint option with --enable-pylint option (without parameters) and use cheimes's trick with $(PYTHON) -m pylint so the Pylint always follows the Python version you used for particular build. Up to you.

(Just keep in mind that build needs to be done under Python 2 till samba-python bindings are ported to Python 3.)

@tiran
Copy link
Member

tiran commented Nov 30, 2016

+1 for my trick

Since I disabled the import warnings for samba bindings in fef6f18, pylint is passing under Python 3, too.

@MartinBasti
Copy link
Contributor

I would like rather explicit pylint version than autodetection

@tiran
Copy link
Member

tiran commented Dec 7, 2016

It makes more sense to follow the principal test what you build, build what you test.

@MartinBasti
Copy link
Contributor

But we build both 2/3 versions at once

@MartinBasti
Copy link
Contributor

Or we can run both pylints as far as we wants py2/3 compatible versions

@MartinBasti
Copy link
Contributor

I had discussion with Petr, and currently we cannot run both pylints in build system and it is not easy to add it there.

So we have to manually override pylint versions in travis tests, so I would stay with the current version of commits

@tiran
Copy link
Member

tiran commented Dec 7, 2016

It's easily possible with my proposal, just saying:

make pylint PYTHON=python3
make pylint PYTHON=python2

@tiran
Copy link
Member

tiran commented Dec 7, 2016

PS: I'd rather not run both linters in parallel. We use pylint in parallel mode, which runs as many workers as CPU cores. make pylint already uses up 90-100% CPU cycles on all cores.

@MartinBasti
Copy link
Contributor

Ok if Petr agree we can go with your proposal

@pspacek
Copy link
Contributor Author

pspacek commented Dec 8, 2016

I'm fine with make pylint PYTHON=python3 as long as you can agree on it :-)

@pspacek
Copy link
Contributor Author

pspacek commented Dec 8, 2016

I've implemented tiran's proposal and rebased the patchset.

#BuildRequires: python3-samba
BuildRequires: python3-setuptools
# 0.6: serialization.load_pem_private_key, load_pem_public_key
BuildRequires: python3-cryptography >= 0.6
Copy link
Member

Choose a reason for hiding this comment

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

>= 1.3.1

BuildRequires: python3-setuptools
# 0.6: serialization.load_pem_private_key, load_pem_public_key
BuildRequires: python3-cryptography >= 0.6
BuildRequires: python3-gssapi
Copy link
Member

Choose a reason for hiding this comment

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

>= 1.2.0

Requires: python3-ipaclient = %{version}-%{release}
Requires: python3-pyldap >= 2.4.15
Requires: python3-lxml
Requires: python3-gssapi >= 1.1.2
Copy link
Member

Choose a reason for hiding this comment

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

>= 1.2.0

@tiran
Copy link
Member

tiran commented Dec 8, 2016

  • CI is failing: 12-08 10:53 ipadocker.cli ERROR Command echo Secret123 | kinit admin && ipa ping failed (exit code 1). I have kicked Travis. Let's see if the problem persists.
  • please sync the version requirements of python3-cryptography and python3-gssapi with Python 2 versions.
  • Regarding your workaround and setuptools comment: I have been meaning to move all scripts to setuptools' entry points for a while. Setuptools only supports one script directory, which defaults to PREFIX/bin. I need to come up with a workaround. But that's a topic for another PR.

@pspacek
Copy link
Contributor Author

pspacek commented Dec 8, 2016

I've synchronized python-cryptography and python-gssapi versions. Thank you for noticing. Let's see if CI tests pass or not.

@MartinBasti
Copy link
Contributor

MartinBasti commented Dec 9, 2016

ACK, but travis runs tests under PY3 and should not, I tried locally and tests works for me (ipa-run-tests is still py2 by default), so there is an issue with travis tests. I prefer to fix travis first before pushing this to not blocking tests for other PRs.

@pspacek
Copy link
Contributor Author

pspacek commented Dec 9, 2016

@martbab Can I do something in the build system to make your CI implementation easier?

@MartinBasti
Copy link
Contributor

make install put #!/usr/bin/python into ipa-run-tests and it causes that on F25 our tests are running by default under PY3

Probably travis tests uses make install (haven't looked)

@martbab
Copy link
Contributor

martbab commented Dec 9, 2016

Travis installs the built RPMs and then runs server install and outoftree test suite. It does not use make install.

BTW does this mean that Travis is actually running tests using Py3? Sorry but I am just trying to get up to speed.

@pspacek
Copy link
Contributor Author

pspacek commented Dec 9, 2016

make install will install whatever is auto-detected during configure (or overriden by $PYTHON variable while calling make install).

So, how are you caling the stuff? If you want to always run Python 2 tests, specify PYTHON=/usr/bin/python2.

@pspacek
Copy link
Contributor Author

pspacek commented Dec 9, 2016

Relevant parts of SPEC file are here:
684f4f5#diff-021f8f69d8c0598dcead3341b439283aR778

@MartinBasti
Copy link
Contributor

MartinBasti commented Dec 9, 2016

@martbab Yes for this PR travis run tests under PY3, see tracebacks they are from python3.5 site-packages

@pspacek
Copy link
Contributor Author

pspacek commented Dec 9, 2016

To be sure I re-built RPMs from this PR using makerpms.sh script. My findings are:

  • /usr/bin/ipa-run-tests is a symlink to /usr/bin/ipa-run-tests-2.7
  • /usr/bin/ipa-run-tests-2.7 has shebang #!/usr/bin/python2

I have no idea why it should fail in Travis.

@MartinBasti
Copy link
Contributor

Have you tried on F25? it might be related to it

@martbab
Copy link
Contributor

martbab commented Dec 9, 2016

I have re-built RPMs in the F25 image and found out that the /usr/bin/ipa command has the following shebang:

#!/usr/bin/python3

so this one is the culprit. ipa-run-tests has python2 shebang. Keep in mind that before running tests ipa ping is called to a) test the functionality of the installation and b) to prepare ~/.ipa directory for tests. I can remove this call if needed but IMHO it is a bug.

@martbab
Copy link
Contributor

martbab commented Dec 9, 2016

Yep, running ipa ping on Fedora 25 confirms this:

# ipa ping
ipa: ERROR: AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/ipaclient/remote_plugins/__init__.py", line 109, in get_package
    plugins = api._remote_plugins
AttributeError: 'API' object has no attribute '_remote_plugins'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/ipalib/cli.py", line 1348, in run
    api.finalize()
  File "/usr/lib/python3.5/site-packages/ipalib/plugable.py", line 714, in finalize
    self.__do_if_not_done('load_plugins')
  File "/usr/lib/python3.5/site-packages/ipalib/plugable.py", line 421, in __do_if_not_done
    getattr(self, name)()
  File "/usr/lib/python3.5/site-packages/ipalib/plugable.py", line 592, in load_plugins
    for package in self.packages:
  File "/usr/lib/python3.5/site-packages/ipalib/__init__.py", line 919, in packages
    ipaclient.remote_plugins.get_package(self),
  File "/usr/lib/python3.5/site-packages/ipaclient/remote_plugins/__init__.py", line 111, in get_package
    server_info = ServerInfo(api)
  File "/usr/lib/python3.5/site-packages/ipaclient/remote_plugins/__init__.py", line 25, in __init__
    hostname = DNSName(api.env.server).ToASCII()
  File "/usr/lib/python3.5/site-packages/ipapython/dnsutil.py", line 74, in ToASCII
    return self.to_text().decode('ascii')  # must be unicode string
AttributeError: 'str' object has no attribute 'decode'
ipa: ERROR: an internal error has occurred

Petr Viktorin recommended me to copy the whole build directory and run
configure twice, with different values for PYTHON variable.

After thinking a bit about that, it seems as cleanest approach.
Building for two versions of Python at the same time should be
temporary state so I decided not to complicate Autotools build system
with conditional spagetti for two versions of Python.

For proper Python2/3 distiction in the two separate builds, I added
find/grep/sed combo which replaces shebangs with system-wide Python
interpreter as necessary. This is workaround for the fact that FreeIPA
does not use setuptools properly. Honza told me that proper use of
setuptools is not trivial so we decided to go with this for now.

https://fedorahosted.org/freeipa/ticket/157
python3-samba is intentionally ommited because it is not in Fedora repos.
Pylint somehow magically ignores this missing package.
Keep in mind that server will not work until this this solved.

https://fedorahosted.org/freeipa/ticket/157
configure option --with/without-pylint was replaced by
--enable/disable-pylint. Pylint is always called as $(PYTHON) -m python.

If you need to override Pylint version, use command "make pylint PYTHON=xxx".

https://fedorahosted.org/freeipa/ticket/157
@pspacek
Copy link
Contributor Author

pspacek commented Dec 12, 2016

I've found the root cause - incorrect order of operations in freeipa.spec.in. Now it should work.

@MartinBasti MartinBasti added ack Pull Request approved, can be merged pushed Pull Request has already been pushed labels Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
4 participants