Skip to content

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

Merged
scoder merged 2 commits into
lxml:masterfrom
etanol:master
May 19, 2021
Merged

scoder merged 2 commits into
lxml:masterfrom
etanol:master

Conversation

@etanol

@etanol etanol commented Jan 19, 2021 •

Copy link
Copy Markdown
Contributor

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

Comment thread setup.py Resolved
Comment thread setup.py Resolved
Comment thread setup.py Resolved

@etanol etanol left a comment •

Copy link
Copy Markdown
Contributor Author

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.
Comment thread setup.py Resolved
@scoder
scoder merged commit c9cf865 into lxml:master May 19, 2021
@scoder

scoder commented May 19, 2021

Copy link
Copy Markdown
Member

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

Development

Successfully merging this pull request may close these issues.

2 participants