Graph-theoretic fragment generation
Project description
Fragmentation-nx
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
- Have an accessible Python runtime.
- Include
nxx.cpp
andnxx.h
files in your project. (Download from release). - 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();
}
- 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`
- 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
Built Distributions
Hashes for fragmentation_nx-0.1.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5574513617abd8290b0b33c6640c4783c311da70c80e61ec72ed2d68f304c11b |
|
MD5 | 5e671dc1680e1947959c598396d875bf |
|
BLAKE2b-256 | 8c66b1f02a77cc93fc90b682eb6b07a37cda1208db871de7a75a1cc5eb3afe94 |
Hashes for fragmentation_nx-0.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb606e799722aa8627947465dac87745f035373deacbfddd40d5c681f3ba8f64 |
|
MD5 | 82ba834e2dc3aa8730573f207bc10bd3 |
|
BLAKE2b-256 | 7e41466310f9b704a25f7b4a6749d8e320f1cc36af7619fa2a78d27334300dde |
Hashes for fragmentation_nx-0.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b63fa47a4031392a892ea93c4525ccc660b105875c6912908183614f44bd244 |
|
MD5 | 661e4399ddd6af2c298aed4bd662d044 |
|
BLAKE2b-256 | 18df8f297816ebd980f770d2be8495df9827fed3973f7e4ad15d7c69703e0d4d |
Hashes for fragmentation_nx-0.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aff74d13120d723c4fc1eb5743e98c194e2758b42d52f6ecbe256f9871a3cf98 |
|
MD5 | 2688d149313f5f415baf615937f7625d |
|
BLAKE2b-256 | 033ba0bea6943b10f3ab61088b828b95fc3a2e18b3d458a83fb2d486210880d0 |