Metadata-Version: 2.4
Name: fiftyone_ipintelligence_onpremise
Version: 4.6.2
Summary: IP Intelligence and IP geolocation for Python that finds an IP address's likely location (country, region, town, and coordinates), connection type, and network by reading a data file on your server. An alternative to MaxMind and IPinfo.
Author: 51Degrees Engineering
Author-email: engineering@51degrees.com
License: EUPL-1.2
Project-URL: Homepage, https://51degrees.com/ip-intelligence?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=homepage
Project-URL: Documentation, https://51degrees.com/documentation/_ip_intelligence__index.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=documentation
Project-URL: Source, https://github.com/51Degrees/51degrees-python
Keywords: 51degrees,ip-intelligence,ip-geolocation,geoip,ip-lookup,asn,ip-to-country,maxmind,ipinfo
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: fiftyone_ipintelligence_shared
Requires-Dist: fiftyone_pipeline_engines_fiftyone
Requires-Dist: fiftyone_pipeline_core>=4.5.44
Requires-Dist: fiftyone_pipeline_engines>=4.5.44
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: keywords
Dynamic: license
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 51Degrees IP Intelligence Engines - OnPremise

![51Degrees](https://raw.githubusercontent.com/51Degrees/51degrees-python/main/.github/images/logo-160.png "Data rewards the curious") **Python IP Intelligence**

[Developer Documentation](https://51degrees.com/documentation/_ip_intelligence__quickstart.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=51degrees-ip-intelligence-engines-onpremise "developer documentation")

## Introduction

This package resolves IP addresses to location, network and registration
information using a local `.ipi` data file and the
[51Degrees Pipeline API](https://51degrees.com/documentation/index.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=introduction).

The native [51degrees-cxx](https://github.com/51Degrees/51degrees-cxx/blob/main/docs/ipi/README.md)
library is included as a git submodule and wrapped with SWIG.

## Building

The SWIG generated wrapper (`ipi_python_wrap.cxx` and
`IpIntelligenceEngineModule.py`) is committed to the repository so SWIG is
only needed when regenerating it (run `PreBuild.bat` / `PreBuild.sh`).

A C++17 compiler is required to build the native extension:

```
git submodule update --init --recursive
python setup.py build_clib build_ext
```

## Data files

The on-premise engine requires a `.ipi` data file. The free Lite data file,
`51Degrees-LiteV41.ipi`, is linked from the
[data](https://github.com/51Degrees/data) repository, which is included as
the nested submodule `cxx/data` and contains evidence files for testing. From
the root of a checkout of
[51degrees-python](https://github.com/51Degrees/51degrees-python), download it
by running `sh cxx/data/get-data-files.sh 51Degrees-LiteV41.ipi`, or
`./cxx/data/get-data-files.ps1 51Degrees-LiteV41.ipi` in PowerShell. Without a
checkout, download it from
https://distributor.51degrees.com/api/v2/free/ipi-lite-v41, which sends it
gzip compressed.

## Usage

```python
from fiftyone_ipintelligence_onpremise.ipintelligence_onpremise_pipelinebuilder import IpIntelligenceOnPremisePipelineBuilder

pipeline = IpIntelligenceOnPremisePipelineBuilder(
    data_file_path="51Degrees-LiteV41.ipi",
    licence_keys="",
    usage_sharing=False).build()

flowdata = pipeline.create_flowdata()
flowdata.evidence.add("query.client-ip", "185.28.167.78")
flowdata.process()
print(flowdata.ip.registeredname.value())
```

## Free-threaded Python

The package is tested on the free-threaded builds of Python 3.13 and 3.14 on Linux, and of Python 3.14 on Windows. It is published as source, so installing it on a free-threaded build needs a C and C++ compiler that builds for that Python. Its native module does not declare that it can run without the global interpreter lock (GIL), so Python turns the GIL back on for the whole process when it loads the module, and prints this warning.

```
RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'fiftyone_ipintelligence_onpremise._IpIntelligenceEngineModule', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
```

From then on every thread in the program runs with the GIL, the package's native code included, as on the standard build of Python, so neither the package nor the rest of the program gains anything from free-threading. To start with the GIL on, and so without the warning, set the environment variable `PYTHON_GIL=1` or run Python with `-X gil=1`. The package has not been tested with the GIL kept off by `PYTHON_GIL=0`.

Whichever build of Python runs it, the results of one request are not safe to use from several threads at once. Give each thread its own Flow Data, or coordinate access with a lock of your own.

## Find out more

- [IP Intelligence](https://51degrees.com/ip-intelligence?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=find-out-more-ip-intelligence)
- [IP Intelligence documentation](https://51degrees.com/documentation/index.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=find-out-more-documentation)
- [Getting started](https://51degrees.com/documentation/_ip_intelligence__quickstart.html?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=find-out-more-getting-started)
- [Pricing](https://51degrees.com/pricing?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_onpremise&utm_term=find-out-more-pricing)
- https://github.com/51Degrees/51degrees-python
- https://github.com/51Degrees/51degrees-cxx
