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

preliminary windows support via some new flags #164

Merged
merged 5 commits into from
Jan 9, 2016

Conversation

reaperhulk
Copy link
Member

PYNACL_SODIUM_LIBRARY_NAME lets you set what it should be trying to link against.

PYNACL_SODIUM_STATIC will define SODIUM_STATIC before include to set the proper dllexport visibility for static linking on windows.

This PR also should be tested by a new jenkins job... let's see if it works.

PYNACL_SODIUM_LIBRARY_NAME lets you set what it should be trying to link
against

PYNACL_SODIUM_STATIC will define SODIUM_STATIC before include to set the
proper dllexport visibility for static linking on windows
@reaperhulk reaperhulk added this to the v0.4.0 milestone Jan 9, 2016
source.append("#include <sodium.h>")

if os.getenv("PYNACL_SODIUM_LIBRARY_NAME") is not None:
libraries = [os.getenv("PYNACL_SODIUM_LIBRARY_NAME")]
Copy link
Member

Choose a reason for hiding this comment

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

Why would someone need a custom name?

Copy link
Member Author

Choose a reason for hiding this comment

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

The Windows library naming scheme makes this somewhat useful. When you ask for "sodium" on linux/OS X it gets translated to "libsodium.so" or "libsodium.dylib" but on windows it just looks for "sodium.lib". The libsodium precompiled libraries, however, call it "libsodium" on windows. We could just rename it to "sodium" but it's nice to be able to use the libsodium.org download without renaming a bunch of files.

Alternately we could just define the library name to be "libsodium" on Windows, but that does mean windows users (at least the ones who want to compile it themselves) need to know that we require the library to be named that.

I'm neutral on which approach we take here (although there is a reasonable argument to be made that it's unlikely anyone on Windows is going to name it anything other than "libsodium")

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, if the libsodium binaries name it libsodium, why can't we just write "libsodium" here and be happy?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you compile it yourself it won't necessarily be named that, but as I said before, if anyone is compiling it themselves it is perhaps reasonable to state that they need to learn what the expected name is for linking.

Copy link
Member

Choose a reason for hiding this comment

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

Why wouldn't it be named that -- is there a different default for
self-compiled, no default, or just "someone might change it"?

On Sat, Jan 9, 2016 at 10:53 AM, Paul Kehrer notifications@github.com
wrote:

In src/bindings/build.py
#164 (comment):

@@ -34,6 +34,17 @@
with open(header, "r") as hfile:
ffi.cdef(hfile.read())

+# we need to easily control a few values for Windows builds
+source = []
+if os.getenv("PYNACL_SODIUM_STATIC") is not None:

  • source.append("#define SODIUM_STATIC")

+source.append("#include <sodium.h>")
+
+if os.getenv("PYNACL_SODIUM_LIBRARY_NAME") is not None:

  • libraries = [os.getenv("PYNACL_SODIUM_LIBRARY_NAME")]

If you compile it yourself it won't necessarily be named that, but as I
said before, if anyone is compiling it themselves it is perhaps reasonable
to state that they need to learn what the expected name is for linking.


Reply to this email directly or view it on GitHub
https://github.com/pyca/pynacl/pull/164/files#r49265121.

"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084

Copy link
Member Author

Choose a reason for hiding this comment

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

Since there's no suffix difference for static vs dynamic vs link time compile optimization library types Windows people appear to sometimes totally rename their libraries. We saw this with the slproweb OpenSSL library names before we switched to our own for cryptography. In this case there are vcxproj files (at least in the git tree, they don't appear to actually ship in the tarball) for the various VS201X releases that probably do give the "libsodium" name by default.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I think just hardcode it to libsodium and we can do something
different if someone complains.

On Sat, Jan 9, 2016 at 10:59 AM, Paul Kehrer notifications@github.com
wrote:

In src/bindings/build.py
#164 (comment):

@@ -34,6 +34,17 @@
with open(header, "r") as hfile:
ffi.cdef(hfile.read())

+# we need to easily control a few values for Windows builds
+source = []
+if os.getenv("PYNACL_SODIUM_STATIC") is not None:

  • source.append("#define SODIUM_STATIC")

+source.append("#include <sodium.h>")
+
+if os.getenv("PYNACL_SODIUM_LIBRARY_NAME") is not None:

  • libraries = [os.getenv("PYNACL_SODIUM_LIBRARY_NAME")]

Since there's no suffix difference for static vs dynamic vs link time
compile optimization library types Windows people appear to sometimes
totally rename their libraries. We saw this with the slproweb OpenSSL
library names before we switched to our own for cryptography. In this case
there are vcxproj files (at least in the git tree, they don't appear to
actually ship in the tarball) for the various VS201X releases that probably
do give the "libsodium" name by default.


Reply to this email directly or view it on GitHub
https://github.com/pyca/pynacl/pull/164/files#r49265169.

"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084

@reaperhulk
Copy link
Member Author

jenkins, retest this please

# we need to easily control a few values for Windows builds
source = []
if os.getenv("PYNACL_SODIUM_STATIC") is not None:
source.append("#define SODIUM_STATIC")
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining that what this does is cause libsodium to be a static lib... or whatever this define does?


source.append("#include <sodium.h>")

if sys.platform == "windows":
Copy link
Member

Choose a reason for hiding this comment

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

pretty sure this should be "win32"

Copy link
Member Author

Choose a reason for hiding this comment

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

yup

@reaperhulk
Copy link
Member Author

jenkins retest this please

@reaperhulk
Copy link
Member Author

jenkins, retest this please

3 similar comments
@reaperhulk
Copy link
Member Author

jenkins, retest this please

@reaperhulk
Copy link
Member Author

jenkins, retest this please

@reaperhulk
Copy link
Member Author

jenkins, retest this please

alex added a commit that referenced this pull request Jan 9, 2016
preliminary windows support via some new flags
@alex alex merged commit ebbffde into pyca:master Jan 9, 2016
@reaperhulk reaperhulk deleted the prelim-windows branch January 9, 2016 19:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants