jordansissel / fpm

Effing package management! Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.
http://fpm.readthedocs.io/en/latest/
Other
11.13k stars 1.07k forks source link

Support for Python's new venv module (instead of virtualenv) #1407

Open fgimian opened 6 years ago

fgimian commented 6 years ago

Hey friends, just another little one.

Recent versions of Python include a standard library called venv which essentially performs the exact task that the virtualenv PyPi package performs.

Usually you invoke this as follows to create a virtualenv:

python3 -m venv my-virtualenv

Unfortunately FPM is always expecting a virtualenv binary for it to be able to create virtualenv packages. It would be awesome if the newer method was also supported.

For now, I've created /usr/bin/virtualenv with the following to get around the issue:

#!/bin/bash
python3.6 -m venv "$@"

Thanks so much! Fotis

devinnasar commented 6 years ago

+1 on this issue. If this is the standard way of using virtual environments in python it should be supported in FPM. Thanks!

josegonzalez commented 6 years ago

@devinnasar would you be willing to add support for this in a PR?

devinnasar commented 6 years ago

I don't think I have the relevant skill set right now. I would be willing to learn but I'm not sure how great a beginner with packaging systems might be at it. Could you suggest some competencies I should build to be able to help best? Please understand I don't mean to gripe and not help. I just wanted to add some vocal support for the feature.

D

On Fri, Jul 6, 2018, 3:37 PM Jose Diaz-Gonzalez notifications@github.com wrote:

@devinnasar https://github.com/devinnasar would you be willing to add support for this in a PR?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jordansissel/fpm/issues/1407#issuecomment-403127815, or mute the thread https://github.com/notifications/unsubscribe-auth/AZJHgZqN1m2Rayv-1YmujpyocED60Vblks5uD7x-gaJpZM4PKzan .

dsburns commented 2 years ago

@fgimian - I'm using the workaround you described, but fpm is failing during the virtualenv-tools --update-path command:

Process is running {:pid=>27863, :level=>:debug, :file=>"fpm/util.rb", :line=>"147", :method=>"execmd"}
Error in ./lib/python3.8/site-packages/serial/rs485.pyc {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
Traceback (most recent call last): {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
  File "/usr/local/bin/virtualenv-tools", line 8, in <module> {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
    sys.exit(main()) {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
  File "/home/dev1/.local/lib/python3.8/site-packages/virtualenv_tools.py", line 357, in main {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
    update_paths(venv, update_path) {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
  File "/home/dev1/.local/lib/python3.8/site-packages/virtualenv_tools.py", line 230, in update_paths {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
    update_pycs(lib_dir, new_path) {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
  File "/home/dev1/.local/lib/python3.8/site-packages/virtualenv_tools.py", line 180, in update_pycs {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
    update_pyc(filename, local_path) {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
  File "/home/dev1/.local/lib/python3.8/site-packages/virtualenv_tools.py", line 122, in update_pyc {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
    code = marshal.load(f) {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
ValueError: bad marshal data (unknown type code) {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
Process failed: virtualenv-tools failed (exit code 1). Full command was:["virtualenv-tools", "--update-path", "/usr/share/python/.."] {:level=>:error, :file=>"fpm/command.rb", :line=>"505", :method=>"rescue in execute"}

If you modify https://github.com/jordansissel/fpm/blob/92886d922d326c82dd115efdc83c7673427bef45/lib/fpm/package/virtualenv.rb#L161-L175 by moving the _remove_python_compiledfiles call to the top of the code block, the virtualenv-tools command succeeds and the package is created.

Have you run into this on your environment?

fgimian commented 2 years ago

Hi @dsburns, it honestly has been a long time since I've used FPM to package Python software, and I don't recall having such an issue in the past. Most of my recent projects just use Docker or I build the RPM directly using a SPEC file which IMHO is much more robust.

Perhaps one of the FPM maintainers can chime in though.

Sorry I couldn't be of more help

Cheers Fotis