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