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
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ language: python

matrix:
include:
- os: linux
python: 2.7
- os: linux
python: 3.6
- os: osx
Expand All @@ -21,8 +19,6 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
curl https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh > miniconda.sh;
export TRAVIS_PYTHON_VERSION="3.6";
elif [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# You can set these variables from the command line.
SPHINXOPTS = -W
SPHINXBUILD = sphinx-build
SPHINXBUILD = python3 -m sphinx
SOURCEDIR = .
BUILDDIR = _build

Expand Down
8 changes: 6 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __getattr__(cls, name):
# -- Project information -----------------------------------------------------

project = 'tskit'
copyright = '2018, Tskit developers'
copyright = '2018-2019, Tskit developers'
author = 'Tskit developers'

# The short X.Y version
Expand Down Expand Up @@ -76,7 +76,7 @@ def handle_item(fieldarg, content):
# inconsistencies later when references are resolved
fieldtype = types.pop(fieldarg)
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
typename = u''.join(n.astext() for n in fieldtype)
typename = ''.join(n.astext() for n in fieldtype)
par.extend(self.make_xrefs(self.typerolename, domain, typename,
addnodes.literal_emphasis))
else:
Expand Down Expand Up @@ -117,8 +117,12 @@ def handle_item(fieldarg, content):
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'breathe',
'sphinx_issues',
]

# Github repo
issues_github_path = "tskit-dev/tskit"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down
3 changes: 1 addition & 2 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Quickstart

- Install the Python development requirements using
``pip install -r python/requirements/development.txt``.
- Build the low level module by running ``make`` in the ``python`` directory. Python 3.x
is the default for developement (Python 2.x is discouraged).
- Build the low level module by running ``make`` in the ``python`` directory.
- Run the tests to ensure everything has worked: ``python -m nose -vs``. These should
all pass.
- Make your changes in a local branch, and open a pull request on GitHub when you
Expand Down
2 changes: 1 addition & 1 deletion docs/rtd_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy
six
svgwrite
jsonschema
h5py
breathe
sphinx-issues
12 changes: 12 additions & 0 deletions python/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
--------------------
[0.1.5] - 2019-XX-XX
--------------------

Under development.

This release removes support for Python 2.

**New features**

- Remove support for Python 2 (:user:`hugovk`). See :issue:`137` and :pr:`140`.

--------------------
[0.1.4] - 2019-02-01
--------------------
Expand Down
3 changes: 0 additions & 3 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ allchecks: _tskitmodule.c
ext3: _tskitmodule.c
python3 setup.py build_ext --inplace

ext2: _tskitmodule.c
python2 setup.py build_ext --inplace

ctags:
ctags lib/*.c lib/*.h tskit/*.py

Expand Down
112 changes: 43 additions & 69 deletions python/_tskitmodule.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
/*
** Copyright (C) 2014-2018 University of Oxford
**
** This file is part of tskit.
**
** tskit is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** tskit is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with tskit. If not, see <http://www.gnu.org/licenses/>.
*/
* MIT License
*
* Copyright (c) 2019 Tskit Developers
* Copyright (c) 2015-2018 University of Oxford
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#define PY_SSIZE_T_CLEAN
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
Expand All @@ -28,13 +34,6 @@
#include "kastore.h"
#include "tskit.h"

#if PY_MAJOR_VERSION >= 3
#define IS_PY3K
#endif

#define MODULE_DOC \
"Low level interface for tskit"

#define SET_COLS 0
#define APPEND_COLS 1

Expand Down Expand Up @@ -8427,8 +8426,6 @@ static PyTypeObject LdCalculatorType = {
static PyObject *
tskit_get_kastore_version(PyObject *self)
{
/* TODO if we provide the option of linking against kastore separately, we
* should return the link time version using kas_get_version */
return Py_BuildValue("iii", KAS_VERSION_MAJOR, KAS_VERSION_MINOR, KAS_VERSION_PATCH);
}

Expand All @@ -8446,49 +8443,28 @@ static PyMethodDef tskit_methods[] = {
{NULL} /* Sentinel */
};

/* Initialisation code supports Python 2.x and 3.x. The framework uses the
* recommended structure from http://docs.python.org/howto/cporting.html.
* I've ignored the point about storing state in globals, as the examples
* from the Python documentation still use this idiom.
*/

#if PY_MAJOR_VERSION >= 3

static struct PyModuleDef tskitmodule = {
PyModuleDef_HEAD_INIT,
"_tskit", /* name of module */
MODULE_DOC, /* module documentation, may be NULL */
"_tskit",
"Low level interface for tskit",
-1,
tskit_methods,
NULL, NULL, NULL, NULL
};

#define INITERROR return NULL

PyObject *
PyInit__tskit(void)

#else
#define INITERROR return

void
init_tskit(void)
#endif
{
#if PY_MAJOR_VERSION >= 3
PyObject *module = PyModule_Create(&tskitmodule);
#else
PyObject *module = Py_InitModule3("_tskit", tskit_methods, MODULE_DOC);
#endif
if (module == NULL) {
INITERROR;
return NULL;
}
import_array();

/* LightweightTableCollection type */
LightweightTableCollectionType.tp_new = PyType_GenericNew;
if (PyType_Ready(&LightweightTableCollectionType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&LightweightTableCollectionType);
PyModule_AddObject(module, "LightweightTableCollection",
Expand All @@ -8497,111 +8473,111 @@ init_tskit(void)
/* IndividualTable type */
IndividualTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&IndividualTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&IndividualTableType);
PyModule_AddObject(module, "IndividualTable", (PyObject *) &IndividualTableType);

/* NodeTable type */
NodeTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&NodeTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&NodeTableType);
PyModule_AddObject(module, "NodeTable", (PyObject *) &NodeTableType);

/* EdgeTable type */
EdgeTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&EdgeTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&EdgeTableType);
PyModule_AddObject(module, "EdgeTable", (PyObject *) &EdgeTableType);

/* MigrationTable type */
MigrationTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&MigrationTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&MigrationTableType);
PyModule_AddObject(module, "MigrationTable", (PyObject *) &MigrationTableType);

/* SiteTable type */
SiteTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&SiteTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&SiteTableType);
PyModule_AddObject(module, "SiteTable", (PyObject *) &SiteTableType);

/* MutationTable type */
MutationTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&MutationTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&MutationTableType);
PyModule_AddObject(module, "MutationTable", (PyObject *) &MutationTableType);

/* PopulationTable type */
PopulationTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&PopulationTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&PopulationTableType);
PyModule_AddObject(module, "PopulationTable", (PyObject *) &PopulationTableType);

/* ProvenanceTable type */
ProvenanceTableType.tp_new = PyType_GenericNew;
if (PyType_Ready(&ProvenanceTableType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&ProvenanceTableType);
PyModule_AddObject(module, "ProvenanceTable", (PyObject *) &ProvenanceTableType);

/* TableCollectionTable type */
TableCollectionType.tp_new = PyType_GenericNew;
if (PyType_Ready(&TableCollectionType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&TableCollectionType);
PyModule_AddObject(module, "TableCollection", (PyObject *) &TableCollectionType);

/* TreeSequence type */
TreeSequenceType.tp_new = PyType_GenericNew;
if (PyType_Ready(&TreeSequenceType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&TreeSequenceType);
PyModule_AddObject(module, "TreeSequence", (PyObject *) &TreeSequenceType);

/* Tree type */
TreeType.tp_new = PyType_GenericNew;
if (PyType_Ready(&TreeType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&TreeType);
PyModule_AddObject(module, "Tree", (PyObject *) &TreeType);

/* TreeDiffIterator type */
TreeDiffIteratorType.tp_new = PyType_GenericNew;
if (PyType_Ready(&TreeDiffIteratorType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&TreeDiffIteratorType);
PyModule_AddObject(module, "TreeDiffIterator", (PyObject *) &TreeDiffIteratorType);

/* VcfConverter type */
VcfConverterType.tp_new = PyType_GenericNew;
if (PyType_Ready(&VcfConverterType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&VcfConverterType);
PyModule_AddObject(module, "VcfConverter", (PyObject *) &VcfConverterType);

/* HaplotypeGenerator type */
HaplotypeGeneratorType.tp_new = PyType_GenericNew;
if (PyType_Ready(&HaplotypeGeneratorType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&HaplotypeGeneratorType);
PyModule_AddObject(module, "HaplotypeGenerator",
Expand All @@ -8610,15 +8586,15 @@ init_tskit(void)
/* VariantGenerator type */
VariantGeneratorType.tp_new = PyType_GenericNew;
if (PyType_Ready(&VariantGeneratorType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&VariantGeneratorType);
PyModule_AddObject(module, "VariantGenerator", (PyObject *) &VariantGeneratorType);

/* LdCalculator type */
LdCalculatorType.tp_new = PyType_GenericNew;
if (PyType_Ready(&LdCalculatorType) < 0) {
INITERROR;
return NULL;
}
Py_INCREF(&LdCalculatorType);
PyModule_AddObject(module, "LdCalculator", (PyObject *) &LdCalculatorType);
Expand Down Expand Up @@ -8652,7 +8628,5 @@ init_tskit(void)
PyModule_AddIntConstant(module, "FORWARD", TSK_DIR_FORWARD);
PyModule_AddIntConstant(module, "REVERSE", TSK_DIR_REVERSE);

#if PY_MAJOR_VERSION >= 3
return module;
#endif
}
1 change: 0 additions & 1 deletion python/requirements/conda-minimal.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
numpy
nose
h5py
six
jsonschema
svgwrite
msprime
Expand Down
2 changes: 1 addition & 1 deletion python/requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ mock
newick
nose
numpy
six
kastore
jsonschema
sphinx
sphinx-argparse
sphinx_rtd_theme
sphinx-issues
breathe
svgwrite
pyparsing
Expand Down
Loading