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

pipenv support #82

Open
kesuskim opened this issue Feb 5, 2020 · 5 comments
Open

pipenv support #82

kesuskim opened this issue Feb 5, 2020 · 5 comments

Comments

@kesuskim
Copy link

kesuskim commented Feb 5, 2020

Hello, First of all I am really thankful for the project. I was about to crazy and about to build my own version of docker.
( It seems coexistence of Python2 and Python3 within Windows makes build environment unstable or add side effect something I don't even know what causes problem; I must use Python2 for another build tools depending on it which not even using Python at all, and for Python development we now must use Python3 because Python2 is now deprecated. It is horrible )

Anyway, I think it is really good to support pipenv, as pipenv seems official and very mature, reasonable tool we can use in Python dev.
Just as this project already has support for detection of requirements.txt file, so does Pipfile can make this things through.

I will test some things and send PR.

@kesuskim
Copy link
Author

kesuskim commented Feb 5, 2020

Python program running on wine yet writing to filesystem on linux through pipe fails 😕 I don't know what is the exact issue here.

Simple step to reproduce with wine

root@53f599a5903b:/src#  python -c 'print("Hello World")' > output.txt
Fatal Python error: init_sys_streams: can't initialize sys standard streams
OSError: [WinError 6] Invalid handle

Current thread 0x0000002e (most recent call first):

abnormal program termination

I thought I just install pipenv and write requirements.txt file if there is Pipfile in CWD, but not working because of above issue.

Simply install pipenv like that,

...
# install python in wine, using the msi packages to install, extracting
# the files directly, since installing isn't running correctly.
RUN set -x \
    && winetricks win7 \
    && for msifile in `echo core dev exe lib path pip tcltk tools`; do \
        wget -nv "https://www.python.org/ftp/python/$PYTHON_VERSION/amd64/${msifile}.msi"; \
        wine msiexec /i "${msifile}.msi" /qb TARGETDIR=C:/Python37; \
        rm ${msifile}.msi; \
    done \
    && cd /wine/drive_c/Python37 \
    && wine python.exe -m pip install -U pipenv \
    && echo 'wine '\''C:\Python37\python.exe'\'' "$@"' > /usr/bin/python \
    && echo 'wine '\''C:\Python37\Scripts\easy_install.exe'\'' "$@"' > /usr/bin/easy_install \
    && echo 'wine '\''C:\Python37\Scripts\pip.exe'\'' "$@"' > /usr/bin/pip \
    && echo 'wine '\''C:\Python37\Scripts\pyinstaller.exe'\'' "$@"' > /usr/bin/pyinstaller \
    && echo 'wine '\''C:\Python37\Scripts\pyupdater.exe'\'' "$@"' > /usr/bin/pyupdater \
    && echo 'wine '\''C:\Python37\Scripts\pipenv.exe'\'' "$@"' > /usr/bin/pipenv \
    && echo 'assoc .py=PythonScript' | wine cmd \
    && echo 'ftype PythonScript=c:\Python37\python.exe "%1" %*' | wine cmd \
    && while pgrep wineserver >/dev/null; do echo "Waiting for wineserver"; sleep 1; done \
    && chmod +x /usr/bin/python /usr/bin/easy_install /usr/bin/pip /usr/bin/pyinstaller /usr/bin/pyupdater /usr/bin/pipenv \
    && (pip install -U pip || true) \
    && rm -rf /tmp/.wine-*
...

and check Pipfile from entrypoint-windows.sh.

...
if [ -f Pipfile ]; then
    pipenv lock -r > requirements.txt # failed to work here
    pip install -r requirements.txt
    rm requirements.txt
fi # [ -f Pipfile ] ]

if [ -f requirements.txt ]; then
    pip install -r requirements.txt
fi # [ -f requirements.txt ]
...

manual execution goes like this;

[kesuskim@localhost project]$ docker run -it --rm -v $PWD:/src --entrypoint /bin/bash test:latest
root@53f599a5903b:/src# pipenv lock -r > requirements.txt
Fatal Python error: init_sys_streams: can't initialize sys standard streams
OSError: [WinError 6] Invalid handle

Current thread 0x0000002c (most recent call first):

abnormal program termination

@zamai
Copy link

zamai commented Feb 13, 2020

Hey, @kesuskim I've just discovered this repo and would also love to add pipenv support to this script.
Were you able to figgure out why the build fails?

@kesuskim
Copy link
Author

Hey, @kesuskim I've just discovered this repo and would also love to add pipenv support to this script.
Were you able to figgure out why the build fails?

Hello @zamai ! :)
No, I could not figure out what causes the problem exactly. I only assume that as Python in this case runs on wine which emulates Windows, that stdin / stdout of the program is different from what normal Linux program would be executed; that the piping through output of pipenv lock -r fails.

I'd love to work with this to make it with pipenv seamlessly, but for now I have to do just make it work so I manually extract requirements.txt file and do build ;(

@zamai
Copy link

zamai commented Feb 17, 2020

I see, don't have an inspiration to figgure out the windows stdout handling, so my solution to the problem is a Make command:

build_win: freeze
	rm -rf ./dist/
	docker run --rm -v "$(PWD):/src/" cdrx/pyinstaller-windows

freeze:
	pipenv run pip freeze > requirements.txt

@kesuskim
Copy link
Author

I see, don't have an inspiration to figgure out the windows stdout handling, so my solution to the problem is a Make command:

build_win: freeze
	rm -rf ./dist/
	docker run --rm -v "$(PWD):/src/" cdrx/pyinstaller-windows

freeze:
	pipenv run pip freeze > requirements.txt

Yes, that could be one workaround at application level, too!

I hope one day the problem can be resolved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants