Skip to content

Commit

Permalink
Migrate to Travis com
Browse files Browse the repository at this point in the history
  • Loading branch information
veghp committed Oct 26, 2021
1 parent 14f694d commit 68a38c5
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,7 @@ python:
- "3.6"
# command to install dependencies
install:
- pip install coveralls pytest-cov==2.6 pytest==3.2.3
- pip install coveralls pytest-cov pytest
- pip install -e .
# command to run tests
script:
Expand Down
17 changes: 10 additions & 7 deletions README.rst
@@ -1,12 +1,12 @@
easy_dna
========

.. image:: https://travis-ci.org/Edinburgh-Genome-Foundry/easy_dna.svg?branch=master
:target: https://travis-ci.org/Edinburgh-Genome-Foundry/easy_dna
:alt: Travis CI build status
.. image:: https://app.travis-ci.com/Edinburgh-Genome-Foundry/easy_dna.svg?branch=master
:target: https://app.travis-ci.com/Edinburgh-Genome-Foundry/easy_dna
:alt: Travis CI build status

.. image:: https://coveralls.io/repos/github/Edinburgh-Genome-Foundry/easy_dna/badge.svg?branch=master
:target: https://coveralls.io/github/Edinburgh-Genome-Foundry/easy_dna?branch=master
:target: https://coveralls.io/github/Edinburgh-Genome-Foundry/easy_dna?branch=master

Easy_dna is a Python library implementing useful routines for manipulating DNA
sequences, either as "ATGC" strings or Biopython records. It aims at providing
Expand All @@ -15,24 +15,26 @@ design and genbank generation.

Easy_dna was originally created to gather useful methods repeatedly used in the
different software projects of the Edinburgh Genome Foundry for DNA design and
manufacturing.
manufacturing.

See the API reference `here <https://edinburgh-genome-foundry.github.io/easy_dna/>`_.


Installation
------------

You can install easy_dna through PIP:

.. code::
sudo pip install easy_dna
pip install easy_dna
Alternatively, you can unzip the sources in a folder and type:

.. code::
sudo python setup.py install
python setup.py install
License = MIT
-------------
Expand All @@ -41,6 +43,7 @@ Easy_dna is an open-source software originally written at the `Edinburgh Genome
<http://edinburgh-genome-foundry.github.io/home.html>`_ by `Zulko <https://github.com/Zulko>`_
and `released on Github <https://github.com/Edinburgh-Genome-Foundry/easy_dna>`_ under the MIT licence (Copyright 2019 Edinburgh Genome Foundry). Everyone is welcome to contribute!


More biology software
---------------------

Expand Down
102 changes: 61 additions & 41 deletions ez_setup.py
@@ -1,4 +1,3 @@

#!python
"""Bootstrap setuptools installation
Expand Down Expand Up @@ -32,14 +31,16 @@
DEFAULT_VERSION = "0.9.6"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"


def _python_cmd(*args):
args = (sys.executable,) + args
return subprocess.call(args) == 0


def _install(tarball, install_args=()):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
log.warn("Extracting in %s", tmpdir)
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
Expand All @@ -50,13 +51,13 @@ def _install(tarball, install_args=()):
# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
os.chdir(subdir)
log.warn('Now working in %s', subdir)
log.warn("Now working in %s", subdir)

# installing
log.warn('Installing Setuptools')
if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.')
log.warn('See the error message above.')
log.warn("Installing Setuptools")
if not _python_cmd("setup.py", "install", *install_args):
log.warn("Something went wrong during the installation.")
log.warn("See the error message above.")
# exitcode will be 2
return 2
finally:
Expand All @@ -67,7 +68,7 @@ def _install(tarball, install_args=()):
def _build_egg(egg, tarball, to_dir):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
log.warn("Extracting in %s", tmpdir)
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
Expand All @@ -78,39 +79,45 @@ def _build_egg(egg, tarball, to_dir):
# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
os.chdir(subdir)
log.warn('Now working in %s', subdir)
log.warn("Now working in %s", subdir)

# building an egg
log.warn('Building a Setuptools egg in %s', to_dir)
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
log.warn("Building a Setuptools egg in %s", to_dir)
_python_cmd("setup.py", "-q", "bdist_egg", "--dist-dir", to_dir)

finally:
os.chdir(old_wd)
shutil.rmtree(tmpdir)
# returning the result
log.warn(egg)
if not os.path.exists(egg):
raise IOError('Could not build the egg.')
raise IOError("Could not build the egg.")


def _do_download(version, download_base, to_dir, download_delay):
egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg'
% (version, sys.version_info[0], sys.version_info[1]))
egg = os.path.join(
to_dir,
"setuptools-%s-py%d.%d.egg"
% (version, sys.version_info[0], sys.version_info[1]),
)
if not os.path.exists(egg):
tarball = download_setuptools(version, download_base,
to_dir, download_delay)
tarball = download_setuptools(version, download_base, to_dir, download_delay)
_build_egg(egg, tarball, to_dir)
sys.path.insert(0, egg)
import setuptools

setuptools.bootstrap_install_from = egg


def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, download_delay=15):
def use_setuptools(
version=DEFAULT_VERSION,
download_base=DEFAULT_URL,
to_dir=os.curdir,
download_delay=15,
):
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
was_imported = 'pkg_resources' in sys.modules or \
'setuptools' in sys.modules
was_imported = "pkg_resources" in sys.modules or "setuptools" in sys.modules
try:
import pkg_resources
except ImportError:
Expand All @@ -122,23 +129,23 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
e = sys.exc_info()[1]
if was_imported:
sys.stderr.write(
"The required version of setuptools (>=%s) is not available,\n"
"and can't be installed while this script is running. Please\n"
"install a more recent version first, using\n"
"'easy_install -U setuptools'."
"\n\n(Currently using %r)\n" % (version, e.args[0]))
"The required version of setuptools (>=%s) is not available,\n"
"and can't be installed while this script is running. Please\n"
"install a more recent version first, using\n"
"'easy_install -U setuptools'."
"\n\n(Currently using %r)\n" % (version, e.args[0])
)
sys.exit(2)
else:
del pkg_resources, sys.modules['pkg_resources'] # reload ok
return _do_download(version, download_base, to_dir,
download_delay)
del pkg_resources, sys.modules["pkg_resources"] # reload ok
return _do_download(version, download_base, to_dir, download_delay)
except pkg_resources.DistributionNotFound:
return _do_download(version, download_base, to_dir,
download_delay)
return _do_download(version, download_base, to_dir, download_delay)


def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15):
def download_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15
):
"""Download setuptools from a specified location and return its filename
`version` should be a valid setuptools version number that is available
Expand All @@ -157,7 +164,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
url = download_base + tgz_name
saveto = os.path.join(to_dir, tgz_name)
src = dst = None
if not os.path.exists(saveto): # Avoid repeated downloads
if not os.path.exists(saveto): # Avoid repeated downloads
try:
log.warn("Downloading %s", url)
src = urlopen(url)
Expand All @@ -184,6 +191,7 @@ def _extractall(self, path=".", members=None):
import copy
import operator
from tarfile import ExtractError

directories = []

if members is None:
Expand All @@ -194,17 +202,19 @@ def _extractall(self, path=".", members=None):
# Extract directories with a safe mode.
directories.append(tarinfo)
tarinfo = copy.copy(tarinfo)
tarinfo.mode = 448 # decimal for oct 0700
tarinfo.mode = 448 # decimal for oct 0700
self.extract(tarinfo, path)

# Reverse sort directories.
if sys.version_info < (2, 4):

def sorter(dir1, dir2):
return cmp(dir1.name, dir2.name)

directories.sort(sorter)
directories.reverse()
else:
directories.sort(key=operator.attrgetter('name'), reverse=True)
directories.sort(key=operator.attrgetter("name"), reverse=True)

# Set correct owner, mtime and filemode on directories.
for tarinfo in directories:
Expand All @@ -230,30 +240,40 @@ def _build_install_args(options):
if sys.version_info < (2, 6):
log.warn("--user requires Python 2.6 or later")
raise SystemExit(1)
install_args.append('--user')
install_args.append("--user")
return install_args


def _parse_args():
"""
Parse the command line for options
"""
parser = optparse.OptionParser()
parser.add_option(
'--user', dest='user_install', action='store_true', default=False,
help='install in user site package (requires Python 2.6 or later)')
"--user",
dest="user_install",
action="store_true",
default=False,
help="install in user site package (requires Python 2.6 or later)",
)
parser.add_option(
'--download-base', dest='download_base', metavar="URL",
"--download-base",
dest="download_base",
metavar="URL",
default=DEFAULT_URL,
help='alternative URL from where to download the setuptools package')
help="alternative URL from where to download the setuptools package",
)
options, args = parser.parse_args()
# positional arguments are ignored
return options


def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
options = _parse_args()
tarball = download_setuptools(download_base=options.download_base)
return _install(tarball, _build_install_args(options))

if __name__ == '__main__':

if __name__ == "__main__":
sys.exit(main())
5 changes: 3 additions & 2 deletions pypi-readme.rst
@@ -1,5 +1,5 @@
Easy DNA
==========
========

Easy_dna is a Python library implementing useful routines for manipulating DNA
sequences, either as "ATGC" strings or Biopython records. It aims at providing
Expand All @@ -12,8 +12,9 @@ design and genbank generation.

**License:** MIT, Copyright Edinburgh Genome Foundry


More biology software
-----------------------
---------------------

.. image:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/Edinburgh-Genome-Foundry.github.io/master/static/imgs/logos/egf-codon-horizontal.png
:target: https://edinburgh-genome-foundry.github.io/
Expand Down
14 changes: 7 additions & 7 deletions setup.py
@@ -1,7 +1,7 @@
# This will try to import setuptools. If not here, it will reach for the embedded
# ez_setup (or the ez_setup package). If none, it fails with a message
try:
from setuptools import setup
from setuptools import setup, find_packages
except ImportError:
try:
import ez_setup
Expand All @@ -15,13 +15,13 @@
"([sudo] pip install ez_setup) and try again."
)

from setuptools import setup, find_packages

exec(open("easy_dna/version.py").read()) # loads __version__
version = {}
with open("easy_dna/version.py") as fp:
exec(fp.read(), version)

setup(
name="easy_dna",
version=__version__,
version=version["__version__"],
author="Zulko",
description="Methods for DNA sequence reading, writing and editing.",
long_description=open("pypi-readme.rst").read(),
Expand All @@ -36,6 +36,6 @@
"snapgene_reader",
"flametree",
"pandas",
"crazydoc"
]
"crazydoc",
],
)

0 comments on commit 68a38c5

Please sign in to comment.