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

support building against mingw headers #147

Closed
totaam opened this issue Mar 18, 2018 · 4 comments
Closed

support building against mingw headers #147

totaam opened this issue Mar 18, 2018 · 4 comments

Comments

@totaam
Copy link
Contributor

totaam commented Mar 18, 2018

Building on MSYS2 requires some minor changes, please consider merging them:

  • only include gss.h as the other header files don't exist - this can easily be IFDEFed (I just hacked it)
  • gss_mech_krb5 is not defined in those header files, I used python struct.pack to generate the value
  • I provided environment variables to skip detection, alternatively the detection can be enhanced to detect the mingw paths
  • skip running krb5-config gssapi which is not installed - it would error out

To test, just install msys2, then install gss: pacman -S mingw-w64-x86_64-gss and then try to build python-gssapi.

To see the exact changes that I made to get it to build, please see:
xpra ticket 1691 - comment 7

@DirectXMan12
Copy link
Member

Awesome, can you submit a PR with your chances? Some initial feedback based on the linked bug:

  • only include gss.h as the other header files don't exist - this can easily be IFDEFed (I just hacked it)

Yep, the three header files are already designed to conditionalize logic like that (they currently do it for OSX strangeness). You'd just need to modify setup.py to populate a constant to indicate that we need gss.h if gssapi.h, etc are missing on Windows.

  • gss_mech_krb5 is not defined in those header files, I used python struct.pack to generate the value.

There's a method on the OID class itself that should do that for you (from_int_seq if you have numbers, or use the elements argument to the constructor if you have bytes).

However, those constants shouldn't strictly be necessary to compile, and the compilation of that file can be disabled by setting the GSSAPI_MECHS environment variable to an empty string at build time:

python-gssapi/setup.py

Lines 195 to 203 in 7018e58

MECHS_SUPPORTED = os.environ.get('GSSAPI_MECHS', 'krb5').split(',')
for mech in MECHS_SUPPORTED:
res.append(Extension('gssapi.raw.mech_%s' % mech,
extra_link_args=link_args,
extra_compile_args=compile_args,
library_dirs=library_dirs,
sources=['gssapi/raw/mech_%s.%s' % (mech,
SOURCE_EXT)]))

  • I provided environment variables to skip detection, alternatively the detection can be enhanced to detect the mingw paths

I'd prefer to see if we can detect mingw, but an environment variable is fine for a first pass if you don't have time.

@totaam
Copy link
Contributor Author

totaam commented Mar 21, 2018

Here's the pull request for the first part:
#149

I'm a little bit nervous about the gss_mech_krb5 change: do you mean using gb.MechType.kerberos or using gb.OID(elements=kerberos_bytes) and getting the list of bytes from somewhere?
This part could potentially break python-gssapi so I've not included in the pull request.

For the record, here's the build error due to the missing definition for gss_mech_krb5 on a 32-bit system:

running build_ext
building 'gssapi.raw.mech_krb5' extension
C:\msys32\mingw32\bin/i686-w64-mingw32-gcc.exe -fno-strict-aliasing -march=i686 -mtune=generic -O2 -pipe -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -DNDEBUG -DNDEBUG -Igssapi/raw -I./gssapi/raw -IC:/msys32/mingw32/include/python2.7 -c gssapi/raw/mech_krb5.c -o build/temp.mingw-2.7/gssapi/raw/mech_krb5.o -fPIC
gssapi/raw/mech_krb5.c: In function 'initmech_krb5':
gssapi/raw/mech_krb5.c:1557:80: error: 'gss_mech_krb5' undeclared (first use in this function); did you mean 'initmech_krb5'?
   __pyx_t_4 = ((PyObject *)__pyx_f_6gssapi_3raw_17cython_converters_c_make_oid(gss_mech_krb5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 21, __pyx_L1_error)
                                                                                ^~~~~~~~~~~~~
                                                                                initmech_krb5
gssapi/raw/mech_krb5.c:1557:80: note: each undeclared identifier is reported only once for each function it appears in
Building from Cython files...
error: command 'C:\\msys32\\mingw32\\bin/i686-w64-mingw32-gcc.exe' failed with exit status 1

@totaam
Copy link
Contributor Author

totaam commented Mar 21, 2018

Fix for the pedantic python syntax checkers which didn't like the "bare except" statement:
a9c3c44

@frozencemetery
Copy link
Member

I believe this was addressed in #149.

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

No branches or pull requests

3 participants