|
| 1 | +# python-xmlsec |
| 2 | + |
| 3 | +[](https://pypi.python.org/pypi/xmlsec) |
| 4 | +[](https://results.pre-commit.ci/latest/github/xmlsec/python-xmlsec/master) |
| 5 | +[](https://github.com/xmlsec/python-xmlsec/actions/workflows/manylinux.yml) |
| 6 | +[](https://github.com/xmlsec/python-xmlsec/actions/workflows/macosx.yml) |
| 7 | +[](https://github.com/xmlsec/python-xmlsec/actions/workflows/linuxbrew.yml) |
| 8 | +[](https://codecov.io/gh/xmlsec/python-xmlsec) |
| 9 | +[](https://xmlsec.readthedocs.io/en/latest/?badge=latest) |
| 10 | + |
| 11 | +Python bindings for the [XML Security |
| 12 | +Library](https://www.aleksey.com/xmlsec/). |
| 13 | + |
| 14 | +## Documentation |
| 15 | + |
| 16 | +Documentation for `xmlsec` can be found at |
| 17 | +[xmlsec.readthedocs.io](https://xmlsec.readthedocs.io/). |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +Check the |
| 22 | +[examples](https://xmlsec.readthedocs.io/en/latest/examples.html) |
| 23 | +section in the documentation to see various examples of signing and |
| 24 | +verifying using the library. |
| 25 | + |
| 26 | +## Requirements |
| 27 | + |
| 28 | +- `libxml2 >= 2.9.1` |
| 29 | +- `libxmlsec1 >= 1.2.33` |
| 30 | + |
| 31 | +## Install |
| 32 | + |
| 33 | +`xmlsec` is available on PyPI: |
| 34 | + |
| 35 | +``` bash |
| 36 | +pip install xmlsec |
| 37 | +``` |
| 38 | + |
| 39 | +Depending on your OS, you may need to install the required native |
| 40 | +libraries first: |
| 41 | + |
| 42 | +### Linux (Debian) |
| 43 | + |
| 44 | +``` bash |
| 45 | +apt-get install pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl |
| 46 | +``` |
| 47 | + |
| 48 | +Note: There is no required version of LibXML2 for Ubuntu Precise, so you |
| 49 | +need to download and install it manually. |
| 50 | + |
| 51 | +``` bash |
| 52 | +wget http://xmlsoft.org/sources/libxml2-2.9.1.tar.gz |
| 53 | +tar -xvf libxml2-2.9.1.tar.gz |
| 54 | +cd libxml2-2.9.1 |
| 55 | +./configure && make && make install |
| 56 | +``` |
| 57 | + |
| 58 | +### Linux (CentOS) |
| 59 | + |
| 60 | +``` bash |
| 61 | +yum install libxml2-devel xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel |
| 62 | +``` |
| 63 | + |
| 64 | +### Linux (Fedora) |
| 65 | + |
| 66 | +``` bash |
| 67 | +dnf install libxml2-devel xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel |
| 68 | +``` |
| 69 | + |
| 70 | +### Mac |
| 71 | + |
| 72 | +``` bash |
| 73 | +brew install libxml2 libxmlsec1 pkg-config |
| 74 | +``` |
| 75 | + |
| 76 | +or |
| 77 | + |
| 78 | +``` bash |
| 79 | +port install libxml2 xmlsec pkgconfig |
| 80 | +``` |
| 81 | + |
| 82 | +### Alpine |
| 83 | + |
| 84 | +``` bash |
| 85 | +apk add build-base libressl libffi-dev libressl-dev libxslt-dev libxml2-dev xmlsec-dev xmlsec |
| 86 | +``` |
| 87 | + |
| 88 | +## Troubleshooting |
| 89 | + |
| 90 | +### Mac |
| 91 | + |
| 92 | +If you get any fatal errors about missing `.h` files, update your |
| 93 | +`C_INCLUDE_PATH` environment variable to include the appropriate files |
| 94 | +from the `libxml2` and `libxmlsec1` libraries. |
| 95 | + |
| 96 | +### Windows |
| 97 | + |
| 98 | +Starting with 1.3.7, prebuilt wheels are available for Windows, so |
| 99 | +running `pip install xmlsec` should suffice. If you want to build from |
| 100 | +source: |
| 101 | + |
| 102 | +1. Configure build environment, see |
| 103 | + [wiki.python.org](https://wiki.python.org/moin/WindowsCompilers) for |
| 104 | + more details. |
| 105 | + |
| 106 | +2. Install from source dist: |
| 107 | + |
| 108 | + ``` bash |
| 109 | + pip install xmlsec --no-binary=xmlsec |
| 110 | + ``` |
| 111 | + |
| 112 | +## Building from source |
| 113 | + |
| 114 | +1. Clone the `xmlsec` source code repository to your local computer. |
| 115 | + |
| 116 | + ``` bash |
| 117 | + git clone https://github.com/xmlsec/python-xmlsec.git |
| 118 | + ``` |
| 119 | + |
| 120 | +2. Change into the `python-xmlsec` root directory. |
| 121 | + |
| 122 | + ``` bash |
| 123 | + cd /path/to/xmlsec |
| 124 | + ``` |
| 125 | + |
| 126 | +3. Install the project and all its dependencies using `pip`. |
| 127 | + |
| 128 | + ``` bash |
| 129 | + pip install . |
| 130 | + ``` |
| 131 | + |
| 132 | +## Contributing |
| 133 | + |
| 134 | +### Setting up your environment |
| 135 | + |
| 136 | +1. Follow steps 1 and 2 of the [manual installation |
| 137 | + instructions](#building-from-source). |
| 138 | + |
| 139 | +2. Initialize a virtual environment to develop in. This is done so as |
| 140 | + to ensure every contributor is working with close-to-identical |
| 141 | + versions of packages. |
| 142 | + |
| 143 | + ``` bash |
| 144 | + mkvirtualenv xmlsec |
| 145 | + ``` |
| 146 | + |
| 147 | + The `mkvirtualenv` command is available from `virtualenvwrapper` |
| 148 | + package which can be installed by following |
| 149 | + [link](http://virtualenvwrapper.readthedocs.org/en/latest/install.html#basic-installation). |
| 150 | + |
| 151 | +3. Activate the created virtual environment: |
| 152 | + |
| 153 | + ``` bash |
| 154 | + workon xmlsec |
| 155 | + ``` |
| 156 | + |
| 157 | +4. Install `xmlsec` in development mode with testing enabled. This will |
| 158 | + download all dependencies required for running the unit tests. |
| 159 | + |
| 160 | + ``` bash |
| 161 | + pip install -r requirements-test.txt |
| 162 | + pip install -e "." |
| 163 | + ``` |
| 164 | + |
| 165 | +### Running the test suite |
| 166 | + |
| 167 | +1. [Set up your environment](#setting-up-your-environment). |
| 168 | + |
| 169 | +2. Run the unit tests. |
| 170 | + |
| 171 | + ``` bash |
| 172 | + pytest tests |
| 173 | + ``` |
| 174 | + |
| 175 | +3. Tests configuration |
| 176 | + |
| 177 | + Env variable `PYXMLSEC_TEST_ITERATIONS` specifies number of test |
| 178 | + iterations to detect memory leaks. |
| 179 | + |
| 180 | +### Reporting an issue |
| 181 | + |
| 182 | +Please attach the output of following information: |
| 183 | + |
| 184 | +- version of `xmlsec` |
| 185 | +- version of `libxmlsec1` |
| 186 | +- version of `libxml2` |
| 187 | +- output from the command |
| 188 | + |
| 189 | + ``` bash |
| 190 | + pkg-config --cflags xmlsec1 |
| 191 | + ``` |
| 192 | + |
| 193 | +## License |
| 194 | + |
| 195 | +Unless otherwise noted, all files contained within this project are |
| 196 | +licensed under the MIT open source license. See the included `LICENSE` |
| 197 | +file or visit [opensource.org](http://opensource.org/licenses/MIT) for |
| 198 | +more information. |
0 commit comments