Skip to content

Commit 3652f69

Browse files
committed
fixup! Fix the packaging?
1 parent 9e60b70 commit 3652f69

File tree

10 files changed

+50
-38
lines changed

10 files changed

+50
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.pyc
2+
.eggs/
23
.coverage
34
.cache/*
45
build/*

include/routing_table.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,37 +58,5 @@ typedef struct _table_t
5858
entry_t *entries; // Entries in the table
5959
} table_t;
6060

61-
62-
// Table management methods (mostly here for the CFFI wrapper)
63-
static table_t *new_table(unsigned int size)
64-
{
65-
// Malloc space for the table and associated entries
66-
table_t *table = MALLOC(sizeof(table_t));
67-
table->size = 0;
68-
table->entries = NULL;
69-
70-
if (table != NULL)
71-
{
72-
table->entries = MALLOC(sizeof(entry_t) * size);
73-
74-
if (table->entries != NULL)
75-
{
76-
table->size = size;
77-
return table;
78-
}
79-
}
80-
81-
return NULL;
82-
}
83-
84-
static void free_table(table_t *table)
85-
{
86-
// Free the entries and then the table
87-
FREE(table->entries);
88-
table->entries = NULL;
89-
table->size = 0;
90-
FREE(table);
91-
}
92-
9361
#define __ROUTING_TABLE_H__
9462
#endif // __ROUTING_TABLE_H__

rig_routing_tables/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Faster C implementation of common routing table minimisers."""
22
from rig_routing_tables.version import __version__
33

4-
from rig_routing_tables._rig_routing_tables import ffi, lib
54
from rig_routing_tables import utils

rig_routing_tables/cffi_compile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
#include "mtrie.h"
1313
#include "routing_table.h"
1414
#include "ordered_covering.h"
15+
#include "cffi_utils.h"
1516
""",
16-
include_dirs=[include_dir]
17+
include_dirs=[include_dir, os.path.dirname(__file__)],
18+
sources=[os.path.join(os.path.dirname(__file__), "cffi_utils.c")],
1719
)
1820

1921
ffi.cdef("""

rig_routing_tables/cffi_utils.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdlib.h>
2+
#include <stddef.h>
3+
#include "cffi_utils.h"
4+
5+
table_t *new_table(unsigned int size)
6+
{
7+
// Malloc space for the table and associated entries
8+
table_t *table = malloc(sizeof(table_t));
9+
table->size = 0;
10+
table->entries = NULL;
11+
12+
if (table != NULL)
13+
{
14+
table->entries = malloc(sizeof(entry_t) * size);
15+
16+
if (table->entries != NULL)
17+
{
18+
table->size = size;
19+
return table;
20+
}
21+
}
22+
23+
return NULL;
24+
}
25+
26+
void free_table(table_t *table)
27+
{
28+
// Free the entries and then the table
29+
free(table->entries);
30+
table->entries = NULL;
31+
table->size = 0;
32+
free(table);
33+
}

rig_routing_tables/cffi_utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "routing_table.h"
2+
3+
// Table management methods (mostly here for the CFFI wrapper)
4+
table_t *new_table(unsigned int size);
5+
void free_table(table_t *table);

rig_routing_tables/mtrie.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from rig.routing_table import MinimisationFailedError
22
from rig_routing_tables.utils import rig_to_c_table, c_to_rig_table
3-
from rig_routing_tables._rig_routing_tables import lib
3+
from _rig_routing_tables import lib
44

55

66
def minimise(table, target_length):

rig_routing_tables/ordered_covering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from rig.routing_table import MinimisationFailedError
22
from rig_routing_tables.utils import rig_to_c_table, c_to_rig_table
3-
from rig_routing_tables._rig_routing_tables import lib
3+
from _rig_routing_tables import lib
44

55

66
def minimise(table, target_length, no_raise=False):

rig_routing_tables/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Utilities for converting routing tables between different formats."""
22
from rig.routing_table import RoutingTableEntry, Routes
3-
from rig_routing_tables import ffi, lib
3+
from _rig_routing_tables import ffi, lib
44

55

66
def rig_to_c_table(table):

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
packages=find_packages(),
1010

1111
# Files required by CFFI wrapper
12-
package_data={'rig_routing_tables': ['../include/*.h']},
12+
package_data={
13+
'rig_routing_tables': ['../include/*.h',
14+
'rig_routing_tables/cffi_utils.c',
15+
'rig_routing_tables/cffi_utils.h']
16+
},
1317

1418
# Metadata for PyPi
1519
url="https://github.com/project-rig/rig_routing_tables",

0 commit comments

Comments
 (0)