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

Make it possible to control STATIC_* setup variables from the environ… #314

Merged
merged 2 commits into from May 19, 2021

Conversation

etanol
Copy link
Contributor

@etanol etanol commented Jan 19, 2021

When trying to build lxml with a statically linked libxml, the setup.py file needs to be edited or else successfully building lxml is impossible.

This PR tries to provide a way to give more control over the static build settings from environment variables.

For example, assume that libxml and libxslt have been statically built and installed under /my/salsa and we want to build lxml so that libxml and libxslt are embedded into the extension modules. With the suggested changes to the setup.py file applied, it should be possible to do it with a single pip command:

STATIC=true \
LXML_STATIC_INCLUDE_DIRS="/my/salsa/include/libxml2" \
LXML_STATIC_LIBRARY_DIRS="/my/salsa/lib" \
LXML_STATIC_BINARIES="/my/salsa/lib/libxslt.a:/my/salsa/lib/libexslt.a:/my/salsa/lib/libxml2.a" \
WITH_XML2_CONFIG="/my/salsa/bin/xml2-config" \
WITH_XSLT_CONFIG="/my/salsa/bin/xslt-config" \
      pip install --no-binary=:all: lxml

setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@etanol etanol force-pushed the master branch 2 times, most recently from cae52a0 to 59b37c3 Compare May 2, 2021 08:37
setup.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@etanol etanol left a comment

Choose a reason for hiding this comment

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

I thought of using | instead of , because compiler CFLAGS usually rely on the comma. For example, when passing linker flags through the front end, e.g. -Wl,-s.

…ment.

For very customized static builds of lxml, the only way to succeed is by
patching the setup.py file.  This change makes it a little more convenient to
make static builds directly from the pip command line.
setup.py Outdated Show resolved Hide resolved
@scoder scoder merged commit c9cf865 into lxml:master May 19, 2021
@scoder
Copy link
Member

scoder commented May 19, 2021

Thanks

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