##// END OF EJS Templates
packaging: support building Inno installer with PyOxidizer...
packaging: support building Inno installer with PyOxidizer We want to start distributing Mercurial on Python 3 on Windows. PyOxidizer will be our vehicle for achieving that. This commit implements basic support for producing Inno installers using PyOxidizer. While it is an eventual goal of PyOxidizer to produce installers, those features aren't yet implemented. So our strategy for producing Mercurial installers is similar to what we've been doing with py2exe: invoke a build system to produce files then stage those files into a directory so they can be turned into an installer. We had to make significant alterations to the pyoxidizer.bzl config file to get it to produce the files that we desire for a Windows install. This meant differentiating the build targets so we can target Windows specifically. We've added a new module to hgpackaging to deal with interacting with PyOxidizer. It is similar to pyexe: we invoke a build process then copy files to a staging directory. Ideally these extra files would be defined in pyoxidizer.bzl. But I don't think it is worth doing at this time, as PyOxidizer's config files are lacking some features to make this turnkey. The rest of the change is introducing a variant of the Inno installer code that invokes PyOxidizer instead of py2exe. Comparing the Python 2.7 based Inno installers with this one, the following changes were observed: * No lib/*.{pyd, dll} files * No Microsoft.VC90.CRT.manifest * No msvc{m,p,r}90.dll files * python27.dll replaced with python37.dll * Add vcruntime140.dll file The disappearance of the .pyd and .dll files is acceptable, as PyOxidizer has embedded these in hg.exe and loads them from memory. The disappearance of the *90* files is acceptable because those provide the Visual C++ 9 runtime, as required by Python 2.7. Similarly, the appearance of vcruntime140.dll is a requirement of Python 3.7. Differential Revision: https://phab.mercurial-scm.org/D8473

File last commit:

r44703:bad4e7b3 default
r45256:9965d6c3 default
Show More
dirs_multiset.rs
140 lines | 4.2 KiB | application/rls-services+xml | RustLexer
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 // dirs_multiset.rs
//
// Copyright 2019 Raphaël Gomès <rgomes@octobus.net>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
//! Bindings for the `hg::dirstate::dirs_multiset` file provided by the
//! `hg-core` package.
use std::cell::RefCell;
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 use std::convert::TryInto;
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991
use cpython::{
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 exc, ObjectProtocol, PyBytes, PyClone, PyDict, PyErr, PyObject, PyResult,
Yuya Nishihara
rust-cpython: switch to upstreamed version of PySharedRefCell...
r44703 Python, UnsafePyLeaked,
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 };
Yuya Nishihara
rust-cpython: move $leaked struct out of macro...
r43447 use crate::dirstate::extract_dirstate;
Yuya Nishihara
rust-cpython: replace dyn Iterator<..> of sequence with concrete type...
r43157 use hg::{
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 utils::hg_path::{HgPath, HgPathBuf},
Yuya Nishihara
rust-cpython: replace dyn Iterator<..> of sequence with concrete type...
r43157 DirsMultiset, DirsMultisetIter, DirstateMapError, DirstateParseError,
EntryState,
};
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991
py_class!(pub class Dirs |py| {
Yuya Nishihara
rust-cpython: switch to upstreamed version of PySharedRefCell...
r44703 @shared data inner: DirsMultiset;
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991
// `map` is either a `dict` or a flat iterator (usually a `set`, sometimes
// a `list`)
def __new__(
_cls,
map: PyObject,
skip: Option<PyObject> = None
) -> PyResult<Self> {
Raphaël Gomès
rust-dirstate: use EntryState enum instead of literals...
r42994 let mut skip_state: Option<EntryState> = None;
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 if let Some(skip) = skip {
Raphaël Gomès
rust-dirstate: use EntryState enum instead of literals...
r42994 skip_state = Some(
skip.extract::<PyBytes>(py)?.data(py)[0]
.try_into()
.map_err(|e: DirstateParseError| {
PyErr::new::<exc::ValueError, _>(py, e.to_string())
})?,
);
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 }
Raphaël Gomès
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop...
r42993 let inner = if let Ok(map) = map.cast_as::<PyDict>(py) {
let dirstate = extract_dirstate(py, &map)?;
Yuya Nishihara
rust-dirstate: split DirsMultiset constructor per input type...
r43070 DirsMultiset::from_dirstate(&dirstate, skip_state)
Raphaël Gomès
rust-dirs: handle forgotten `Result`s...
r44315 .map_err(|e| {
PyErr::new::<exc::ValueError, _>(py, e.to_string())
})?
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 } else {
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 let map: Result<Vec<HgPathBuf>, PyErr> = map
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 .iter(py)?
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 .map(|o| {
Ok(HgPathBuf::from_bytes(
o?.extract::<PyBytes>(py)?.data(py),
))
})
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 .collect();
Yuya Nishihara
rust-dirstate: split DirsMultiset constructor per input type...
r43070 DirsMultiset::from_manifest(&map?)
Raphaël Gomès
rust-dirs: handle forgotten `Result`s...
r44315 .map_err(|e| {
PyErr::new::<exc::ValueError, _>(py, e.to_string())
})?
Raphaël Gomès
rust-parsers: switch to parse/pack_dirstate to mutate-on-loop...
r42993 };
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991
Yuya Nishihara
rust-cpython: switch to upstreamed version of PySharedRefCell...
r44703 Self::create_instance(py, inner)
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 }
def addpath(&self, path: PyObject) -> PyResult<PyObject> {
Yuya Nishihara
rust-cpython: rename inner_shared() to inner()...
r44702 self.inner(py).borrow_mut().add_path(
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
Raphaël Gomès
rust-dirs: address failing tests for `dirs` impl with a temporary fix...
r44227 ).and(Ok(py.None())).or_else(|e| {
match e {
DirstateMapError::EmptyPath => {
Ok(py.None())
},
e => {
Err(PyErr::new::<exc::ValueError, _>(
py,
e.to_string(),
))
}
}
})
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 }
def delpath(&self, path: PyObject) -> PyResult<PyObject> {
Yuya Nishihara
rust-cpython: rename inner_shared() to inner()...
r44702 self.inner(py).borrow_mut().delete_path(
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 HgPath::new(path.extract::<PyBytes>(py)?.data(py)),
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 )
.and(Ok(py.None()))
.or_else(|e| {
match e {
Raphaël Gomès
rust-dirs: address failing tests for `dirs` impl with a temporary fix...
r44227 DirstateMapError::EmptyPath => {
Ok(py.None())
},
e => {
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 Err(PyErr::new::<exc::ValueError, _>(
py,
Raphaël Gomès
rust-dirs: address failing tests for `dirs` impl with a temporary fix...
r44227 e.to_string(),
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 ))
}
}
})
}
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 def __iter__(&self) -> PyResult<DirsMultisetKeysIterator> {
Yuya Nishihara
rust-cpython: rename inner_shared() to inner()...
r44702 let leaked_ref = self.inner(py).leak_immutable();
Yuya Nishihara
rust-cpython: leverage py_shared_iterator::from_inner() where appropriate
r43161 DirsMultisetKeysIterator::from_inner(
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 py,
Yuya Nishihara
rust-cpython: make PyLeakedRef operations relatively safe...
r43579 unsafe { leaked_ref.map(py, |o| o.iter()) },
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 )
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 }
def __contains__(&self, item: PyObject) -> PyResult<bool> {
Yuya Nishihara
rust-cpython: rename inner_shared() to inner()...
r44702 Ok(self.inner(py).borrow().contains(HgPath::new(
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 item.extract::<PyBytes>(py)?.data(py).as_ref(),
)))
Raphaël Gomès
rust-dirstate: create dirstate submodule in hg-cpython...
r42991 }
});
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997
impl Dirs {
pub fn from_inner(py: Python, d: DirsMultiset) -> PyResult<Self> {
Yuya Nishihara
rust-cpython: switch to upstreamed version of PySharedRefCell...
r44703 Self::create_instance(py, d)
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 }
Raphaël Gomès
rust-hgpath: replace all paths and filenames with HgPath/HgPathBuf...
r43227 fn translate_key(
py: Python,
res: &HgPathBuf,
) -> PyResult<Option<PyBytes>> {
Ok(Some(PyBytes::new(py, res.as_ref())))
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 }
}
Yuya Nishihara
rust-cpython: rename py_shared_iterator_impl to py_shared_iterator...
r43159 py_shared_iterator!(
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 DirsMultisetKeysIterator,
Yuya Nishihara
rust-cpython: switch to upstreamed version of PySharedRefCell...
r44703 UnsafePyLeaked<DirsMultisetIter<'static>>,
Raphaël Gomès
rust-cpython: add macro for sharing references...
r42997 Dirs::translate_key,
Option<PyBytes>
);