Skip to content

Commit

Permalink
Don't import biopandas during install (BioPandas#60)
Browse files Browse the repository at this point in the history
* Don't import biopandas during install

Getting the __version__ during install is more safely done by reading __init__ as text.

The reason is that __init__ may at some point include code that requires importing packages that have not yet been installed. Installing a package should always be possible using `pip install biopython` in an empty virtualenv.

* Fix pep8

* Update setup.py

* Fix imports

* Fix for Python 2.7
  • Loading branch information
ecederstrand authored and rasbt committed Oct 10, 2019
1 parent b533b65 commit 4e1f027
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
from os.path import realpath, dirname, join
import io
import os
from setuptools import setup, find_packages
import biopandas

VERSION = biopandas.__version__
PROJECT_ROOT = dirname(realpath(__file__))
VERSION = None
with io.open(
os.path.join(os.path.dirname(__file__), 'biopandas/__init__.py'),
encoding='utf-8'
) as f:
for l in f:
if not l.startswith('__version__'):
continue
VERSION = l.split('=')[1].strip(' "\'\n')
break
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))

REQUIREMENTS_FILE = join(PROJECT_ROOT, 'requirements.txt')
REQUIREMENTS_FILE = os.path.join(PROJECT_ROOT, 'requirements.txt')

with open(REQUIREMENTS_FILE) as f:
install_reqs = f.read().splitlines()
Expand Down

0 comments on commit 4e1f027

Please sign in to comment.