Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit e1f25c1

Browse files
edoficgarbas
authored andcommitted
Add support for passing extra env variables
1 parent 346b2b3 commit e1f25c1

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/pypi2nix/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
help=u'Extra build dependencies needed for installation of '
5252
u'required python packages.'
5353
)
54+
@click.option('-N', '--extra-env',
55+
default='',
56+
help=u'Extra environment variables needed for installation of'
57+
u'required python pakcages.'
58+
u'Example: "LANG=en_US.UTF-8 FOO_OPTS=xyz"'
59+
)
5460
@click.option('-T', '--enable-tests',
5561
is_flag=True,
5662
help=u'Enable tests in generated packages.'
@@ -97,6 +103,7 @@ def main(version,
97103
basename,
98104
cache_dir,
99105
extra_build_inputs,
106+
extra_env,
100107
enable_tests,
101108
python_version,
102109
requirements,
@@ -260,6 +267,7 @@ def handle_requirements_file(project_dir, requirements_file):
260267
python_version=pypi2nix.utils.PYTHON_VERSIONS[python_version],
261268
nix_path=nix_path,
262269
setup_requires=setup_requires,
270+
extra_env=extra_env,
263271
)
264272

265273
click.echo('Stage2: Extracting metadata from pypi.python.org ...')

src/pypi2nix/pip.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
, pip_build_dir
66
, python_version
77
, extra_build_inputs ? []
8+
, extra_env ? ""
89
, setup_requires ? []
910
}:
1011

@@ -45,7 +46,7 @@ let
4546
--find-links ${wheel_cache_dir} \
4647
--cache-dir ${download_cache_dir} \
4748
--build ${pip_build_dir} \
48-
--no-binary :all:
49+
--no-binary :all:
4950
'';
5051

5152
in pkgs.stdenv.mkDerivation rec {
@@ -74,7 +75,7 @@ in pkgs.stdenv.mkDerivation rec {
7475
mkdir -p ${project_dir}/wheel ${project_dir}/wheelhouse
7576
7677
PYTHONPATH=${pypi2nix_bootstrap}/extra:${project_dir}/setup_requires:$PYTHONPATH \
77-
pip wheel \
78+
${extra_env} pip wheel \
7879
${builtins.concatStringsSep" "(map (x: "-r ${x} ") requirements_files)} \
7980
--wheel-dir ${project_dir}/wheel \
8081
--find-links ${wheel_cache_dir} \

src/pypi2nix/stage1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def main(verbose,
2121
nix_path=None,
2222
nix_shell='nix-shell',
2323
setup_requires=[],
24+
extra_env='',
2425
):
2526
"""Create a complete (pip freeze) requirements.txt and a wheelhouse from
2627
a user provided requirements.txt.
@@ -36,6 +37,7 @@ def main(verbose,
3637
wheel_cache_dir=wheel_cache_dir,
3738
pip_build_dir=pip_build_dir,
3839
extra_build_inputs=extra_build_inputs,
40+
extra_env=extra_env,
3941
python_version=python_version,
4042
setup_requires=setup_requires,
4143
)),

0 commit comments

Comments
 (0)