Skip to main content

Graph-theoretic fragment generation

Project description

Fragmentation-nx

PyPI version

Graph-theoretic fragment generation with weight calculation, given a set of nodes. This is a Python library based on NetworkX, providing ease of graph editing. A few high-level APIs are exported for C++ through Cython.

Install as a Python library

pip install fragmentation-nx

Check out example usage in the example-py directory.

Integrate into a C++ project

  1. Have an accessible Python runtime.
  2. Include nxx.cpp and nxx.h files in your project. (Download from release).
  3. Add headers, initialization, and finalization in your main function:
#include <Python.h>
#include "nxx.h"

// For Python 3.x runtime
int main() {
	auto err = PyImport_AppendInittab("nxx", PyInit_nxx);
	if (err) { return 1; }
	Py_Initialize();
	auto _ = PyImport_ImportModule("nxx");

	// Call any exported functions defined in nxx.h

	Py_Finalize();
}

// For Python 2.7.x runtime
int main() {
	Py_Initialize();
	initnxx();

	// Call any exported functions defined in nxx.h

	Py_Finalize();
}
  1. Add information on your Python runtime for compilation. For example:
g++ main.cpp ../nxx.cpp -o executable -L`python3-config --prefix`/lib `python3-config --includes --libs`
  1. Run your compiled executable with:
# Depend on your local settings, you need to figure out a way to inform the executable of the Python runtime.
# It could be something like ...
PYTHONHOME=`python3-config --prefix` ./executable
# Or ...
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`python3-config --prefix`/lib ./executable

A complete example is in the example-cpp directory.

Compile from source and install for Python

It is fine to modify nxx.py and drop it into your Python project, as it is a single file, but if you want to enjoy the ~2x performance boost from Cython, you need to compile and install it. This requires Cython installed.

make

make install
# or if your want --user
make install_user

Compile from source for C++

Released .cpp and .h files are enough for normal usage, but if you want to adopt new modifications, you may want to generate the .cpp and .h files yourself. This requires Cython installed.

make

Build Python wheels and release to PyPI

The script build-wheels.sh runs in Python's official manylinux Docker images and produce wheels installable in almost all Linux distros. You will also need twine to upload the wheels.

We need Docker image quay.io/pypa/manylinux1_x86_64 (e.g. With Carbonate's Singularity module we can run singularity run docker://quay.io/pypa/manylinux1_x86_64)

./build-wheels.sh

Once its done we have wheels in ./dist. Upload them with:

twine upload dist/*manylinux*
# username: __token__
# password: [Paste your token here]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fragmentation-nx, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size fragmentation_nx-0.1.0-cp36-cp36m-manylinux1_x86_64.whl (342.9 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size fragmentation_nx-0.1.0-cp37-cp37m-manylinux1_x86_64.whl (336.7 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size fragmentation_nx-0.1.0-cp38-cp38-manylinux1_x86_64.whl (353.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size fragmentation_nx-0.1.0-cp39-cp39-manylinux1_x86_64.whl (333.5 kB) File type Wheel Python version cp39 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page