Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use reusable venvs #199

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions ci/azure-pipelines-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,37 @@ jobs:
displayName: Clippy
condition: ne( variables['rustup_toolchain'], 'nightly' )

- ${{ if ne(parameters.name, 'Windows') }}:
- ${{ if eq(parameters.name, 'Linux') }}:
- script: |
cargo run --bin pyoxidizer -- init --pip-install appdirs==1.4.3 --pip-install cryptography ~/pyapp
cat ci/pyapp.py | cargo run --bin pyoxidizer -- run ~/pyapp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#208 is needed for all of these enhancements to the sample app CI. This approach is taken because otherwise the lines are very long, and also to avoid horrid Windows CMD quoting problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix included in #200

displayName: Build Oxidized Application

- ${{ if eq(parameters.name, 'macOS') }}:
- script: brew install [email protected]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unnecessary, as it is pre-installed, but it is only a few seconds. Happy to remove it though.

displayName: 'Install OpenSSL'

- ${{ if eq(parameters.name, 'macOS') }}:
- script: |
cargo run --bin pyoxidizer -- init --pip-install appdirs==1.4.3 --pip-install zero-buffer==0.5.1 ~/pyapp
export CPPFLAGS="-I$(brew --prefix [email protected])/include"
export LDFLAGS="-L$(brew --prefix [email protected])/lib"
cargo run --bin pyoxidizer -- init --pip-install appdirs==1.4.3 --pip-install cryptography==2.8 ~/pyapp
cat ci/pyapp.py | cargo run --bin pyoxidizer -- run ~/pyapp
displayName: Build Oxidized Application

- ${{ if eq(parameters.name, 'Windows') }}:
- script: choco install openssl
displayName: 'Install OpenSSL'

- ${{ if eq(parameters.name, 'Windows') }}:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is necessary because the windows job needs a functional Python, mostly due to indygreg/python-build-standalone#22

indygreg/python-build-standalone#19 is also problematic, but it can be worked around by using virtualenv instead of venv. Currently the code in the PR does use virtualenv because I was initially attempting to use the standalone python, but cffi put a halt to that plan, so I am going to rip that out so that all OS use venv, simplifying a few areas of the changes.


- ${{ if eq(parameters.name, 'Windows') }}:
- script: |
cargo run --bin pyoxidizer -- init --pip-install appdirs==1.4.3 --pip-install zero-buffer==0.5.1 %USERPROFILE%/pyapp
set INCLUDE=%ProgramFiles%\OpenSSL-Win64\include;%INCLUDE%
set LIB=%ProgramFiles%\OpenSSL-Win64\lib\;%LIB%
cargo run --bin pyoxidizer -- init --pip-install appdirs==1.4.3 --pip-install cryptography==2.8 %USERPROFILE%/pyapp
cat ci/pyapp.py | cargo run --bin pyoxidizer -- run %USERPROFILE%/pyapp
displayName: Build Oxidized Application (Windows)
23 changes: 16 additions & 7 deletions ci/pyapp.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import appdirs
import _cffi_backend
# Allow AttributeError rather than ImportError
# as this indirectly triggers a missing __file__
# https://github.com/dabeaz/ply/issues/216
try:
import zero_buffer
except AttributeError:
pass

print("hello, world")

import cryptography.fernet
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is copied from jamesabel/spafit#2

It is a good smoketest for basic cryptography.


m = b'does this work?'
s = 'original message:\n' + str(m) + '\n\n'

k = cryptography.fernet.Fernet.generate_key()
fernet = cryptography.fernet.Fernet(k)
t = fernet.encrypt(m)
d = fernet.decrypt(t)

s += 'key:\n' + str(k) + '\n\n'
s += 'token:\n' + str(t) + '\n\n'
s += 'decoded message:\n' + str(d)
print(s)
assert d == m
2 changes: 2 additions & 0 deletions pyoxidizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cc = "1.0"
clap = "2.32"
codemap = "0.1"
codemap-diagnostic = "0.1"
copy_dir = "0.1.2"
encoding_rs = "0.8"
fs2 = "0.4"
git2 = "0.9"
Expand All @@ -53,6 +54,7 @@ url = "1.7"
uuid = { version = "0.7", features = ["v4", "v5"] }
version-compare = "0.0"
walkdir = "2"
which = "3.1.0"
xml-rs = "0.8"
zip = "0.5"
zstd = "0.4"
Expand Down
3 changes: 3 additions & 0 deletions pyoxidizer/src/app_packaging/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum InstallLocation {
#[derive(Clone, Debug, PartialEq)]
pub struct PackagingSetupPyInstall {
pub path: String,
pub venv_path: Option<String>,
pub extra_env: HashMap<String, String>,
pub extra_global_arguments: Vec<String>,
pub optimize_level: i64,
Expand Down Expand Up @@ -87,6 +88,7 @@ pub struct PackagingPackageRoot {
#[derive(Clone, Debug, PartialEq)]
pub struct PackagingPipInstallSimple {
pub package: String,
pub venv_path: Option<String>,
pub extra_env: HashMap<String, String>,
pub optimize_level: i64,
pub excludes: Vec<String>,
Expand All @@ -99,6 +101,7 @@ pub struct PackagingPipInstallSimple {
pub struct PackagingPipRequirementsFile {
// TODO resolve to a PathBuf.
pub requirements_path: String,
pub venv_path: Option<String>,
pub extra_env: HashMap<String, String>,
pub optimize_level: i64,
pub include_source: bool,
Expand Down
Loading