mirror of https://github.com/mamba-org/mamba.git
add setup.py
This commit is contained in:
parent
7bfa516591
commit
81f654cb49
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os
|
||||
cur_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(os.path.join(cur_dir, '../mamba/'))
|
||||
|
||||
from conda.cli.main import generate_parser
|
||||
from conda.base.context import context
|
||||
|
@ -23,9 +21,9 @@ from conda.base.constants import ChannelPriority
|
|||
import json
|
||||
import tempfile
|
||||
|
||||
from FastSubdirData import FastSubdirData
|
||||
from mamba.FastSubdirData import FastSubdirData
|
||||
|
||||
import mamba_api as api
|
||||
import mamba.mamba_api as api
|
||||
from multiprocessing.pool import Pool as MPool
|
||||
|
||||
def get_channel(x):
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
from setuptools import setup, Extension
|
||||
from setuptools.command.build_ext import build_ext
|
||||
import sys, os
|
||||
import setuptools
|
||||
|
||||
__version__ = '0.0.1'
|
||||
|
||||
class get_pybind_include(object):
|
||||
"""Helper class to determine the pybind11 include path
|
||||
The purpose of this class is to postpone importing pybind11
|
||||
until it is actually installed, so that the ``get_include()``
|
||||
method can be invoked. """
|
||||
|
||||
def __init__(self, user=False):
|
||||
self.user = user
|
||||
|
||||
def __str__(self):
|
||||
import pybind11
|
||||
return pybind11.get_include(self.user)
|
||||
|
||||
print("Looking for libsolv in: ", sys.prefix)
|
||||
|
||||
ext_modules = [
|
||||
Extension(
|
||||
'mamba.mamba_api',
|
||||
['include/py_interface.cpp', 'include/parsing.cpp', 'include/solver.cpp', 'include/thirdparty/simdjson/simdjson.cpp'],
|
||||
include_dirs=[
|
||||
# Path to pybind11 headers
|
||||
os.path.join(sys.prefix, '/include/'),
|
||||
get_pybind_include(),
|
||||
get_pybind_include(user=True)
|
||||
],
|
||||
library_dirs=[os.path.join(sys.prefix, '/lib/')],
|
||||
libraries=['solv'],
|
||||
language='c++'
|
||||
),
|
||||
]
|
||||
|
||||
# As of Python 3.6, CCompiler has a `has_flag` method.
|
||||
# cf http://bugs.python.org/issue26689
|
||||
def has_flag(compiler, flagname):
|
||||
"""Return a boolean indicating whether a flag name is supported on
|
||||
the specified compiler.
|
||||
"""
|
||||
import tempfile
|
||||
with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f:
|
||||
f.write('int main (int argc, char **argv) { return 0; }')
|
||||
try:
|
||||
compiler.compile([f.name], extra_postargs=[flagname])
|
||||
except setuptools.distutils.errors.CompileError:
|
||||
return False
|
||||
return True
|
||||
|
||||
class BuildExt(build_ext):
|
||||
"""A custom build extension for adding compiler-specific options."""
|
||||
c_opts = {
|
||||
'msvc': ['/EHsc', '/std:c++17', '/arch:AVX2', '/Ox'],
|
||||
'unix': ['-std=c++17', '-march=core-avx2', '-O3'],
|
||||
}
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
|
||||
|
||||
def build_extensions(self):
|
||||
ct = self.compiler.compiler_type
|
||||
opts = self.c_opts.get(ct, [])
|
||||
if ct == 'unix':
|
||||
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
|
||||
if has_flag(self.compiler, '-fvisibility=hidden'):
|
||||
opts.append('-fvisibility=hidden')
|
||||
elif ct == 'msvc':
|
||||
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
|
||||
for ext in self.extensions:
|
||||
ext.extra_compile_args = opts
|
||||
build_ext.build_extensions(self)
|
||||
|
||||
setup(
|
||||
name='mamba',
|
||||
version=__version__,
|
||||
author='Wolf Vollprecht',
|
||||
author_email='w.vollprecht@gmail.com',
|
||||
url='https://github.com/wolfv/mamba',
|
||||
description='Faster than a conda?!',
|
||||
packages=['mamba'],
|
||||
scripts=['bin/mamba'],
|
||||
long_description='A (hopefully faster) reimplementation of the slow bits of conda.',
|
||||
ext_modules=ext_modules,
|
||||
install_requires=['pybind11>=2.2'],
|
||||
cmdclass={'build_ext': BuildExt},
|
||||
zip_safe=False,
|
||||
)
|
Loading…
Reference in New Issue