Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG23ce9e7bf1e5: setup.py: fix some documentation typos
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
hg-reviewers |
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | setup.py (8 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
23ce9e7bf1e5 | 4afb9627dc77 | Matt Harbison | Dec 18 2021, 8:56 PM |
from distutils.errors import ( | from distutils.errors import ( | ||||
CCompilerError, | CCompilerError, | ||||
DistutilsError, | DistutilsError, | ||||
DistutilsExecError, | DistutilsExecError, | ||||
) | ) | ||||
from distutils.sysconfig import get_python_inc, get_config_var | from distutils.sysconfig import get_python_inc, get_config_var | ||||
from distutils.version import StrictVersion | from distutils.version import StrictVersion | ||||
# Explain to distutils.StrictVersion how our release candidates are versionned | # Explain to distutils.StrictVersion how our release candidates are versioned | ||||
StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$') | StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$') | ||||
def write_if_changed(path, content): | def write_if_changed(path, content): | ||||
"""Write content to a file iff the content hasn't changed.""" | """Write content to a file iff the content hasn't changed.""" | ||||
if os.path.exists(path): | if os.path.exists(path): | ||||
with open(path, 'rb') as fh: | with open(path, 'rb') as fh: | ||||
current = fh.read() | current = fh.read() | ||||
e for e in self.extensions if e not in ruststandalones | e for e in self.extensions if e not in ruststandalones | ||||
] | ] | ||||
# Filter out zstd if disabled via argument. | # Filter out zstd if disabled via argument. | ||||
if not self.zstd: | if not self.zstd: | ||||
self.extensions = [ | self.extensions = [ | ||||
e for e in self.extensions if e.name != 'mercurial.zstd' | e for e in self.extensions if e.name != 'mercurial.zstd' | ||||
] | ] | ||||
# Build Rust standalon extensions if it'll be used | # Build Rust standalone extensions if it'll be used | ||||
# and its build is not explictely disabled (for external build | # and its build is not explicitly disabled (for external build | ||||
# as Linux distributions would do) | # as Linux distributions would do) | ||||
if self.distribution.rust and self.rust: | if self.distribution.rust and self.rust: | ||||
if not sys.platform.startswith('linux'): | if not sys.platform.startswith('linux'): | ||||
self.warn( | self.warn( | ||||
"rust extensions have only been tested on Linux " | "rust extensions have only been tested on Linux " | ||||
"and may not behave correctly on other platforms" | "and may not behave correctly on other platforms" | ||||
) | ) | ||||
) | ) | ||||
try: | try: | ||||
subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir) | subprocess.check_call(cargocmd, env=env, cwd=self.rustsrcdir) | ||||
except OSError as exc: | except OSError as exc: | ||||
if exc.errno == errno.ENOENT: | if exc.errno == errno.ENOENT: | ||||
raise RustCompilationError("Cargo not found") | raise RustCompilationError("Cargo not found") | ||||
elif exc.errno == errno.EACCES: | elif exc.errno == errno.EACCES: | ||||
raise RustCompilationError( | raise RustCompilationError( | ||||
"Cargo found, but permisssion to execute it is denied" | "Cargo found, but permission to execute it is denied" | ||||
) | ) | ||||
else: | else: | ||||
raise | raise | ||||
except subprocess.CalledProcessError: | except subprocess.CalledProcessError: | ||||
raise RustCompilationError( | raise RustCompilationError( | ||||
"Cargo failed. Working directory: %r, " | "Cargo failed. Working directory: %r, " | ||||
"command: %r, environment: %r" | "command: %r, environment: %r" | ||||
% (self.rustsrcdir, cargocmd, env) | % (self.rustsrcdir, cargocmd, env) |