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.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

fragmentation_nx-0.1.0-cp39-cp39-manylinux1_x86_64.whl (333.5 kB view hashes)

Uploaded CPython 3.9

fragmentation_nx-0.1.0-cp38-cp38-manylinux1_x86_64.whl (353.1 kB view hashes)

Uploaded CPython 3.8

fragmentation_nx-0.1.0-cp37-cp37m-manylinux1_x86_64.whl (336.7 kB view hashes)

Uploaded CPython 3.7m

fragmentation_nx-0.1.0-cp36-cp36m-manylinux1_x86_64.whl (342.9 kB view hashes)

Uploaded CPython 3.6m

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page