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

Improve wheel building and provide ipaserver wheel for local testing #397

Closed
wants to merge 4 commits into from

Conversation

tiran
Copy link
Member

@tiran tiran commented Jan 17, 2017

The PR improve wheel bundle building and allows ipaserver bundles for local testing
with instrumented build of Python. Debug builds and instrumented builds can have a different binary interface (ABI). For example it is useful for dtrace or test installations in a virtual env. ipaplatform and ipaserver will not be uploaded to PyPI, though.

@MartinBasti MartinBasti self-assigned this Jan 20, 2017
@@ -210,7 +215,7 @@

register = Registry()

def convert_to_ipa_rule(rule):
def _convert_to_ipa_rule(rule):
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is not related to pyhbac, should be in separate patch

Copy link
Member Author

Choose a reason for hiding this comment

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

I made the function a private function because it uses pyhbac internally. Since it's only used internally, I figured out that it makes more sense to make it private than to add a check for pyhbac is not None here, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

I included a comment in the commit message.

@pvoborni
Copy link
Member

@tiran I have very vague idea how this is helpful. You have mentioned it during post-devconf "API meeting". But I no longer remember it and description of this PR is very general.

In order to move all the pypi patches forward, we need to document(maybe design) the whole pypi workflow. This is not mentioned in http://www.freeipa.org/page/V4/Build_system_refactoring nor in http://www.freeipa.org/page/V4/Integration_Improvements I.e. how FreeIPA project will work/supply packages to PYPI and what are actually the requirements for these packages. What is expected to work and what not (like everything related to pyhbac).

Right now I have no idea what are the missing blocker parts and what are just nice-to-have things.

Also I don't really like the part that the patches use custom repo of python-nss. But I'm glad that you are working with @jdennis to improve it. @stlaz, with PR #367 what are the remaining usages of python-nss? Could we actually get rid of python-nss completely?

@stlaz
Copy link
Contributor

stlaz commented Feb 15, 2017

@pvoborni The remaining usages are server/CA certificates verification in certdb.py and apparently some encryption/decryption actions in the Vault plugin. @HonzaCholasta already has patches for the former and getting rid of the latter should not be that hard as well.

@tiran
Copy link
Member Author

tiran commented Feb 21, 2017

@pvoborni The main reason for this PR is explained in the initial PR message. I like to run an IPA framework server with specially instrumented Python builds for profiling or for debugging. The special builds are powerful and incredible useful tools to find bugs or hot spots.

Profile and debug builds have a different ABI than standard builds. Therefore I have to compile all C extensions myself to make them compatible with the new ABI. It is much easier than it sounds, because distutils, setuptools and pip just take care of all the complicated bits and pieces. But this works only for native Python packages. SSSD uses its own build system and has no packages on PyPI. It would take too much time and effort to change SSSD now. Commits 1f195bb and c69c30c make pyhbac and other SSSD components optional.

Commit 905118a allows me to build all ipaserver wheel and full ipaclient wheels with install subpackage for local testing. These packages are not meant to be uploaded to PyPI. They are really just for local testing.

Last but not least 5710587 is a workaround for a python-nss packaging issue. @jdennis is aware of the problem and will address it in due time. We can't get rid of python-nss. Dogtag PKI's Python modules depend on python-nss.

@tiran
Copy link
Member Author

tiran commented Feb 21, 2017

To clarify and emphasis, this PR has nothing to do with the PyPI packaging effort. Zero. Zip. Nada. Nilch!

The sole intent of this PR is debugging and profiling. It gives us tools to find bugs, to increase performance and to reduce memory usage.

@HonzaCholasta
Copy link
Contributor

I can't say I agree with this approach. If this is just for testing, surely you can work around the missing pyhbac in some isolated spot rather than make the import optional all over the place, when it is in fact required. Maybe inject an empty module into sys.modules if it's missing? Or reach out to the SSSD guys and help them add pyhbac to PyPI?

@@ -76,4 +70,12 @@
'IPASecStore = ipaserver.secrets.store:IPASecStore',
],
},
extras_require={
# These packages are currently not available on PyPI.
"caacl": ["pyhbac"],
Copy link
Contributor

Choose a reason for hiding this comment

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

The missing pyhbac does not actually affect caacl, but cert - cert-request is the only place where the acl_evaluate function is called.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, thx

@tiran
Copy link
Member Author

tiran commented Feb 22, 2017

@HonzaCholasta FreeIPA has conditional imports for SSSD modules in several places, e.g. in the trust plugin. 96f614e closes the gap and applies the same technique to the last unconditional import from SSSD.

@HonzaCholasta
Copy link
Contributor

The trust plugin and other trust bits are optional. The cert plugin, which depends on pyhbac, is not optional, so you can't apply the same logic to it.

An acceptable compromise would be to skip the cert plugin entirely if pyhbac is not available:

try:
    import pyhbac
except ImportError:
    raise errors.SkipPluginModule(reason=_('pyhbac is not installed'))

@tiran
Copy link
Member Author

tiran commented Feb 23, 2017

I didn't know about the SkipPluginModule feature. I agree with you, your solution is more elegant.

@tiran tiran force-pushed the ipaserver_bundle branch 2 times, most recently from e51fe8b to ab6d1f1 Compare March 1, 2017 08:18
@tiran
Copy link
Member Author

tiran commented Mar 1, 2017

@jdennis released python-nss 1.0.1. I removed my workaround.

@MartinBasti
Copy link
Contributor

needs rebase

try:
import pyhbac
except ImportError:
pyhbac = None
Copy link
Contributor

Choose a reason for hiding this comment

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

SkipPluginModule should be raised here as well. Alternatively, you could move acl_evaluate and this import to cert.py, since that the only place where it's used, and raise SkipPluginModule there.

@tiran
Copy link
Member Author

tiran commented Mar 14, 2017

I've moved the code to cert.py and raise SkipPluginModule from there.

@tiran
Copy link
Member Author

tiran commented Mar 22, 2017

PR is blocked by #613

@MartinBasti
Copy link
Contributor

Please rebase, it is ok to me, I see potential for future server unit testing. I will test when rebased. If somebody is against this please say it now.

@HonzaCholasta
Copy link
Contributor

LGTM.

@tiran
Copy link
Member Author

tiran commented Mar 31, 2017

Thanks @MartinBasti

I rebased the PR and added a small workaround for dbus-python. The package uses make to compile some of its internal dependencies. It looks like there is a bug in dbus-python's makefile. It sometimes fails to compile with my MAKEFLAGS=-j4 env var. Makefile.am line 253 sets MAKEFLAGS to empty value for pip wheel.

@MK_ENDIF@

# additional wheels for bundle, e.g. IPA_EXTRA_WHEELS="ipatests[webui] pylint"
IPA_EXTRA_WHEELS=
Copy link
Member Author

Choose a reason for hiding this comment

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

I added these two lines to document the intent of IPA_EXTRA_WHEELS.

$(PYTHON) -m pip wheel \
rm -f $(foreach item,$(IPA_WHEEL_PACKAGES) ipatests,$(WHEELBUNDLEDIR)/$(item)-*.whl)
@# dbus-python sometimes fails when MAKEFLAGS is set to -j2 or higher
MAKEFLAGS= $(PYTHON) -m pip wheel \
Copy link
Member Author

Choose a reason for hiding this comment

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

That's the workaround for dbus-python.

@MartinBasti
Copy link
Contributor

Build failed:

make wheel_bundle IPA_SERVER_WHEELS=1
...
  checking for DBUS... no
  configure: error: Package requirements (dbus-1 >= 1.6) were not met:
  
  No package 'dbus-1' found
  
  Consider adjusting the PKG_CONFIG_PATH environment variable if you
  installed software in a non-standard prefix.
  
  Alternatively, you may set the environment variables DBUS_CFLAGS
  and DBUS_LIBS to avoid the need to call pkg-config.
  See the pkg-config man page for more details.
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-l97uxR/dbus-python/setup.py", line 106, in <module>
      'build_ext': BuildExt,
    File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
      dist.run_commands()
    File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/usr/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 199, in run
      self.run_command('build')
    File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-l97uxR/dbus-python/setup.py", line 62, in run
      cwd=builddir)
    File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/tmp/pip-build-l97uxR/dbus-python/configure', '--disable-maintainer-mode', 'PYTHON=/usr/bin/python', '--prefix=/tmp/pip-build-l97uxR/dbus-python/build/temp.linux-x86_64-2.7/prefix']' returned non-zero exit status 1
  
  ----------------------------------------
  Failed building wheel for dbus-python
  Running setup.py clean for dbus-python
  Running setup.py bdist_wheel for MarkupSafe ... done
  Stored in directory: /tmp/freeipa/dist/bundle
  Running setup.py bdist_wheel for pycparser ... done
  Stored in directory: /tmp/freeipa/dist/bundle
  Running setup.py bdist_wheel for configparser ... done
  Stored in directory: /tmp/freeipa/dist/bundle
Successfully built cryptography python-yubico pyusb python-nss pyldap netifaces gssapi MarkupSafe pycparser configparser
Failed to build dbus-python
ERROR: Failed to build one or more wheels
Makefile:1222: recipe for target 'wheel_bundle' failed

@tiran
Copy link
Member Author

tiran commented Mar 31, 2017

You need dbus-devel package.

I opened https://pagure.io/freeipa/issue/6842 to track lack of documentation.

@MartinBasti
Copy link
Contributor

So put it into specfile to with_wheels section

@MartinBasti
Copy link
Contributor

And document in BUILD.txt how to build wheels

@tiran
Copy link
Member Author

tiran commented Mar 31, 2017

@MartinBasti dbus-devel is in the with_wheels section. Documentation is part of https://pagure.io/freeipa/issue/6842 .

@MartinBasti
Copy link
Contributor

@tiran sorry, but then something doesn't work as expected

$ dnf builddep -b -D "with_wheels 1" --spec freeipa.spec.in
<everything already installed>

$ make wheel_bundle IPA_SERVER_WHEELS=1
...
  Failed building wheel for dbus-python

$ git grep -in  dbus-devel freeipa.spec.in 
freeipa.spec.in:149:BuildRequires:  dbus-devel

$ rpm -q dbus-devel
package dbus-devel is not installed

Probably because %global with_wheels 0 is defined in the spec file, so it always overrides my CLI settings

@tiran tiran force-pushed the ipaserver_bundle branch 2 times, most recently from 8764e8d to 60f2d3c Compare April 3, 2017 08:04
@MartinBasti
Copy link
Contributor

Missing dependency dbus-glib-devel otherwise it works

@tiran
Copy link
Member Author

tiran commented Apr 3, 2017

Sigh, I got it.

@MartinBasti
Copy link
Contributor

Can you rebase please? I see Ben's commits in this PR

The pyhbac module is part of SSSD. It's not available as stand-alone
PyPI package. It would take a lot of effort to package it because the
code is deeply tight into SSSD.

Let's follow the example of other SSSD Python packages and make the
import of pyhbac conditionally. It's only necessary for caacl and
hbactest plugins.

I renamed convert_to_ipa_rule() to _convert_to_ipa_rule() because it
does not check for presence of pyhbac package itself. The check is
performed earlier in execute(). The prefix indicates that it is an
internal function and developers have to think twice before using it
in another place.

This makes it much easier to install ipaserver with instrumented build
of Python with a different ABI or in isolated virtual envs to profile
and debug the server.

Signed-off-by: Christian Heimes <cheimes@redhat.com>
ipaserver did not have extra_requires to state additional dependencies.

Signed-off-by: Christian Heimes <cheimes@redhat.com>
To create a wheel bundle with ipaserver and its dependencies:

    make wheel_bundle IPA_SERVER_WHEELS=1

To include additional dependencies:

    make wheel_bundle IPA_EXTRA_WHEELS=ipatests[webui]

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Signed-off-by: Christian Heimes <cheimes@redhat.com>
@tiran tiran force-pushed the ipaserver_bundle branch 2 times, most recently from 9b753e5 to c8c9450 Compare April 3, 2017 10:37
@MartinBasti MartinBasti added the ack Pull Request approved, can be merged label Apr 3, 2017
@MartinBasti
Copy link
Contributor

master:

  • 3064b89 Conditionally import pyhbac
  • 7c9df35 Add extra_requires for additional dependencies
  • ae1c208 Add an option to build ipaserver wheels
  • 40a6067 Don't hard-code with_wheels

@MartinBasti MartinBasti added the pushed Pull Request has already been pushed label Apr 3, 2017
@MartinBasti MartinBasti closed this Apr 3, 2017
@tiran tiran deleted the ipaserver_bundle branch April 4, 2017 07:33
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
5 participants