Skip to content

Commit

Permalink
Merge branch 'bcmeyers'
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Aug 4, 2018
2 parents 3b18726 + 4879fe8 commit fcab70a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
Empty file modified build-wheels.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(open('README.rst').read(), open('CHANGES.rst').read())),
license='MIT',
packages=['setuptools_rust'],
install_requires=['semantic_version>=2.6.0'],
install_requires=['semantic_version>=2.6.0', 'toml>=0.9.0'],
zip_safe=True,
classifiers=[
"Topic :: Software Development :: Version Control",
Expand Down
29 changes: 16 additions & 13 deletions setuptools_rust/extension.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
from __future__ import print_function, absolute_import
import os
import re
import sys
from distutils.errors import DistutilsSetupError
from .utils import Binding, Strip

try:
import configparser
except ImportError:
import ConfigParser as configparser


import semantic_version


Expand Down Expand Up @@ -99,18 +92,28 @@ def __init__(self, target, path,
self.path = path

def get_lib_name(self):
cfg = configparser.ConfigParser()
cfg.read(self.path)
section = 'lib' if cfg.has_option('lib', 'name') else 'package'
name = cfg.get(section, 'name').strip('\'\"').strip()
return re.sub(r"[./\\-]", "_", name)
""" Parse Cargo.toml to get the name of the shared library. """
# We import in here to make sure the the setup_requires are already installed
import toml

cfg = toml.load(self.path)
name = cfg.get('lib', {}).get('name')
if name is None:
name = cfg.get('package', {}).get('name')
if name is None:
raise Exception(
"Can not parse library name from Cargo.toml. "
"Cargo.toml missing value for 'name' key "
"in both the [package] section and the [lib] section")
name = re.sub(r"[./\\-]", "_", name)
return name

def get_rust_version(self):
if self.rust_version is None:
return None
try:
return semantic_version.Spec(self.rust_version)
except:
except ValueError:
raise DistutilsSetupError(
'Can not parse rust compiler version: %s', self.rust_version)

Expand Down

0 comments on commit fcab70a

Please sign in to comment.