Skip to content

Commit 5adb24e

Browse files
author
Martin Larralde
authored
Fix single quotes not being handled in Cargo.toml (#33)
* Fix single quotes not being handled when parsing `Cargo.toml` * Use single quotes and no library name in example * Fix bad regex in `extension.py`
1 parent afd46d6 commit 5adb24e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

example/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "hello-world"
2+
name = 'hello-world'
33
version = "0.1.0"
44
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
55

@@ -9,4 +9,3 @@ default-features = false
99

1010
[lib]
1111
crate-type = ["cdylib"]
12-
name = "helloworld"

setuptools_rust/extension.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import print_function, absolute_import
22
import os
3-
import os.path
3+
import re
44
import sys
55
from distutils.errors import DistutilsSetupError
66
from .utils import Binding, Strip
@@ -84,7 +84,7 @@ def __init__(self, target, path,
8484

8585
self.features = [s.strip() for s in features]
8686

87-
# get absolute path to Cargo manifest file
87+
# get relative path to Cargo manifest file
8888
path = os.path.relpath(path)
8989
# file = sys._getframe(1).f_globals.get('__file__')
9090
# if file:
@@ -102,8 +102,8 @@ def get_lib_name(self):
102102
cfg = configparser.ConfigParser()
103103
cfg.read(self.path)
104104
section = 'lib' if cfg.has_option('lib', 'name') else 'package'
105-
name = cfg.get(section, 'name').strip('"')
106-
return name.replace('-', '_').replace('.', '_')
105+
name = cfg.get(section, 'name').strip('\'\"').strip()
106+
return re.sub(r"[./\\-]", "_", name)
107107

108108
def get_rust_version(self):
109109
if self.rust_version is None:

0 commit comments

Comments
 (0)