Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ before_install:
- yes | sudo certmgr -ssl -m https://nuget.org
install:
- pip install six
- pip install pycparser
- python setup.py build_ext --inplace
script:
- export PYTHONPATH=`pwd`:$PYTHONPATH
Expand Down
24 changes: 23 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,20 @@ def build_extension(self, ext):
if "u" in sys.abiflags:
defines.append("PYTHON_WITH_WIDE_UNICODE")

# check the interop file exists, and create it if it doesn't
interop_file = _get_interop_filename()
if not os.path.exists(interop_file):
geninterop = os.path.join("tools", "geninterop", "geninterop.py")
_check_output([sys.executable, geninterop, interop_file])

cmd = [
_xbuild,
"pythonnet.sln",
"/p:Configuration=%s" % _config,
"/p:Platform=%s" % PLATFORM,
"/p:DefineConstants=\"%s\"" % _defines_sep.join(defines),
"/p:PythonBuildDir=\"%s\"" % os.path.abspath(dest_dir),
"/p:PythonInteropFile=\"%s\"" % os.path.basename(interop_file),
"/verbosity:%s" % VERBOSITY,
]

Expand Down Expand Up @@ -272,6 +279,15 @@ def _check_output(*popenargs, **kwargs):
return output.decode("ascii")
return output

def _get_interop_filename():
"""interopXX.cs is auto-generated as part of the build.
For common windows platforms pre-generated files are included
as most windows users won't have Clang installed, which is
required to generate the file.
"""
interop_file = "interop%d%s%s.cs" % (sys.version_info[0], sys.version_info[1], getattr(sys, "abiflags", ""))
return os.path.join("src", "runtime", interop_file)


if __name__ == "__main__":
setupdir = os.path.dirname(__file__)
Expand All @@ -292,6 +308,11 @@ def _check_output(*popenargs, **kwargs):
for filename in fnmatch.filter(filenames, "*" + ext):
sources.append(os.path.join(root, filename))

setup_requires = []
interop_file = _get_interop_filename()
if not os.path.exists(interop_file):
setup_requires.append("pycparser")

setup(
name="pythonnet",
version="2.1.0.dev1",
Expand Down Expand Up @@ -325,5 +346,6 @@ def _check_output(*popenargs, **kwargs):
"build_ext" : PythonNET_BuildExt,
"install_lib" : PythonNET_InstallLib,
"install_data": PythonNET_InstallData,
}
},
setup_requires=setup_requires
)
3 changes: 3 additions & 0 deletions src/runtime/Python.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
<Compile Include="typemanager.cs" />
<Compile Include="typemethod.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(PythonInteropFile)' != '' ">
<Compile Include="$(PythonInteropFile)" />
</ItemGroup>
<ItemGroup>
<None Include="buildclrmodule.bat" />
<None Include="clrmodule.il" />
Expand Down
214 changes: 0 additions & 214 deletions src/runtime/interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,220 +160,6 @@ public static int Size()
}
#endif

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
internal class TypeOffset {

static TypeOffset() {
Type type = typeof(TypeOffset);
FieldInfo[] fi = type.GetFields();
int size = IntPtr.Size;
for (int i = 0; i < fi.Length; i++) {
fi[i].SetValue(null, i * size);
}
}

public static int magic() {
return ob_size;
}

/* The *real* layout of a type object when allocated on the heap */
//typedef struct _heaptypeobject {
#if (Py_DEBUG) // #ifdef Py_TRACE_REFS
/* _PyObject_HEAD_EXTRA defines pointers to support a doubly-linked list of all live heap objects. */
public static int _ob_next = 0;
public static int _ob_prev = 0;
#endif
// PyObject_VAR_HEAD {
// PyObject_HEAD {
public static int ob_refcnt = 0;
public static int ob_type = 0;
// }
public static int ob_size = 0; /* Number of items in _VAR_iable part */
// }
public static int tp_name = 0; /* For printing, in format "<module>.<name>" */
public static int tp_basicsize = 0; /* For allocation */
public static int tp_itemsize = 0;

/* Methods to implement standard operations */
public static int tp_dealloc = 0;
public static int tp_print = 0;
public static int tp_getattr = 0;
public static int tp_setattr = 0;
public static int tp_compare = 0; /* tp_reserved in Python 3 */
public static int tp_repr = 0;

/* Method suites for standard classes */
public static int tp_as_number = 0;
public static int tp_as_sequence = 0;
public static int tp_as_mapping = 0;

/* More standard operations (here for binary compatibility) */
public static int tp_hash = 0;
public static int tp_call = 0;
public static int tp_str = 0;
public static int tp_getattro = 0;
public static int tp_setattro = 0;

/* Functions to access object as input/output buffer */
public static int tp_as_buffer = 0;

/* Flags to define presence of optional/expanded features */
public static int tp_flags = 0;

public static int tp_doc = 0; /* Documentation string */

/* Assigned meaning in release 2.0 */
/* call function for all accessible objects */
public static int tp_traverse = 0;
/* delete references to contained objects */
public static int tp_clear = 0;

/* Assigned meaning in release 2.1 */
/* rich comparisons */
public static int tp_richcompare = 0;
/* weak reference enabler */
public static int tp_weaklistoffset = 0;

/* Added in release 2.2 */
/* Iterators */
public static int tp_iter = 0;
public static int tp_iternext = 0;
/* Attribute descriptor and subclassing stuff */
public static int tp_methods = 0;
public static int tp_members = 0;
public static int tp_getset = 0;
public static int tp_base = 0;
public static int tp_dict = 0;
public static int tp_descr_get = 0;
public static int tp_descr_set = 0;
public static int tp_dictoffset = 0;
public static int tp_init = 0;
public static int tp_alloc = 0;
public static int tp_new = 0;
public static int tp_free = 0; /* Low-level free-memory routine */
public static int tp_is_gc = 0; /* For PyObject_IS_GC */
public static int tp_bases = 0;
public static int tp_mro = 0; /* method resolution order */
public static int tp_cache = 0;
public static int tp_subclasses = 0;
public static int tp_weaklist = 0;
public static int tp_del = 0;
#if (PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
/* Type attribute cache version tag. Added in version 2.6 */
public static int tp_version_tag;
#endif
#if (PYTHON34)
public static int tp_finalize = 0;
#endif
// COUNT_ALLOCS adds some more stuff to PyTypeObject
#if (Py_COUNT_ALLOCS)
/* these must be last and never explicitly initialized */
public static int tp_allocs = 0;
public static int tp_frees = 0;
public static int tp_maxalloc = 0;
public static int tp_prev = 0;
public static int tp_next = 0;
#endif
//} PyTypeObject;

//typedef struct {
public static int nb_add = 0;
public static int nb_subtract = 0;
public static int nb_multiply = 0;
#if !(PYTHON32 || PYTHON33 || PYTHON34)
public static int nb_divide = 0;
#endif
public static int nb_remainder = 0;
public static int nb_divmod = 0;
public static int nb_power = 0;
public static int nb_negative = 0;
public static int nb_positive = 0;
public static int nb_absolute = 0;
public static int nb_nonzero = 0;
public static int nb_invert = 0;
public static int nb_lshift = 0;
public static int nb_rshift = 0;
public static int nb_and = 0;
public static int nb_xor = 0;
public static int nb_or = 0;
#if !(PYTHON32 || PYTHON33 || PYTHON34)
public static int nb_coerce = 0;
#endif
public static int nb_int = 0;
public static int nb_long = 0;
public static int nb_float = 0;
#if !(PYTHON32 || PYTHON33 || PYTHON34)
public static int nb_oct = 0;
public static int nb_hex = 0;
#endif
/* Added in release 2.0 */
public static int nb_inplace_add = 0;
public static int nb_inplace_subtract = 0;
public static int nb_inplace_multiply = 0;
#if !(PYTHON32 || PYTHON33 || PYTHON34)
public static int nb_inplace_divide = 0;
#endif
public static int nb_inplace_remainder = 0;
public static int nb_inplace_power = 0;
public static int nb_inplace_lshift = 0;
public static int nb_inplace_rshift = 0;
public static int nb_inplace_and = 0;
public static int nb_inplace_xor = 0;
public static int nb_inplace_or = 0;
/* Added in release 2.2 */
/* The following require the Py_TPFLAGS_HAVE_CLASS flag */
public static int nb_floor_divide = 0;
public static int nb_true_divide = 0;
public static int nb_inplace_floor_divide = 0;
public static int nb_inplace_true_divide = 0;
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
/* Added in release 2.5 */
public static int nb_index = 0;
#endif
//} PyNumberMethods;
//typedef struct {
public static int mp_length = 0;
public static int mp_subscript = 0;
public static int mp_ass_subscript = 0;
//} PyMappingMethods;
//typedef struct {
public static int sq_length = 0;
public static int sq_concat = 0;
public static int sq_repeat = 0;
public static int sq_item = 0;
public static int sq_slice = 0;
public static int sq_ass_item = 0;
public static int sq_ass_slice = 0;
public static int sq_contains = 0;
/* Added in release 2.0 */
public static int sq_inplace_concat = 0;
public static int sq_inplace_repeat = 0;
//} PySequenceMethods;
//typedef struct {
#if !(PYTHON32 || PYTHON33 || PYTHON34)
public static int bf_getreadbuffer = 0;
public static int bf_getwritebuffer = 0;
public static int bf_getsegcount = 0;
public static int bf_getcharbuffer = 0;
#endif
#if (PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34)
// This addition is not actually noted in the 2.6.5 object.h
public static int bf_getbuffer = 0;
public static int bf_releasebuffer = 0;
//} PyBufferProcs;
#endif
//PyObject *ht_name, *ht_slots;
public static int name = 0;
public static int slots = 0;

#if (PYTHON33 || PYTHON34)
public static int qualname = 0;
public static int cached_keys;
#endif

/* here are optional user slots, followed by the members. */
public static int members = 0;
}

#if (PYTHON32 || PYTHON33 || PYTHON34)
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
Expand Down
Loading