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

Latest pip versions doesn't support --build option #1831

Closed
de-bug opened this issue Sep 7, 2021 · 9 comments · Fixed by #1896
Closed

Latest pip versions doesn't support --build option #1831

de-bug opened this issue Sep 7, 2021 · 9 comments · Fixed by #1896

Comments

@de-bug
Copy link

de-bug commented Sep 7, 2021

Got the related error on Fedora 34 (Python v3.9). Running command:
fpm --debug -s python -t rpm --debug --iteration 1 --python-install-lib /usr/lib/python3.9/site-packages --python-bin /bin/python3 --python-package-name-prefix python3 --no-python-fix-name --debug-workspace gcalcli

The result looks like:

Trying to download {:package=>"gcalcli", :level=>:info, :file=>"fpm/package/python.rb", :line=>"126", :method=>"download_if_necessary"}
using pip {:pip=>["/bin/python3", "-m", "pip"], :level=>:debug, :file=>"fpm/package/python.rb", :line=>"144", :method=>"download_if_necessary"}
Running command {:args=>["/bin/python3", "-m", "pip", "download", "--no-clean", "--no-deps", "--no-binary", ":all:", "-i", "https://pypi.python.org/simple", "--build", "/tmp/package-python-build-06a618cebd821ff20c7455670df692b64cfd71c108bf4189955925baa3d6/gcalcli", "gcalcli"], :level=>:debug, :file=>"fpm/util.rb", :line=>"138", :method=>"execmd"}
Process is running {:pid=>566215, :level=>:debug, :file=>"fpm/util.rb", :line=>"147", :method=>"execmd"}
DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated and has no effect anymore. pip 21.1 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly
combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333. {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
Looking in indexes: https://pypi.python.org/simple {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
Collecting gcalcli {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
  File was already downloaded /home/svr/tmp/fpm/gcalcli-4.3.0.tar.gz {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
Successfully downloaded gcalcli {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
plugin directory {:plugin=>"python", :pathtype=>:build_path, :path=>"/tmp/package-python-build-06a618cebd821ff20c7455670df692b64cfd71c108bf4189955925baa3d6", :file=>"fpm/command.rb", :line=>"512", :method=>"each"}
/home/svr/.gem/ruby/gems/fpm-1.13.1/lib/fpm/package/python.rb:184:in 'download_if_necessary': Unexpected directory layout after easy_install. Maybe file a bug? The directory is /tmp/package-python-build-06a618cebd821ff20c7455670df692b64cfd71c108bf4189955925baa3d6 (RuntimeError)
        from /home/svr/.gem/ruby/gems/fpm-1.13.1/lib/fpm/package/python.rb:98:in `input'
        from /home/svr/.gem/ruby/gems/fpm-1.13.1/lib/fpm/command.rb:352:in `block in execute'
        from /home/svr/.gem/ruby/gems/fpm-1.13.1/lib/fpm/command.rb:351:in `each'
        from /home/svr/.gem/ruby/gems/fpm-1.13.1/lib/fpm/command.rb:351:in `execute'
        from /home/svr/.gem/ruby/gems/clamp-1.0.1/lib/clamp/command.rb:68:in `run'
        from /home/svr/.gem/ruby/gems/fpm-1.13.1/lib/fpm/command.rb:574:in `run'
        from /home/svr/.gem/ruby/gems/clamp-1.0.1/lib/clamp/command.rb:133:in `run'
        from /home/svr/.gem/ruby/gems/fpm-1.13.1/bin/fpm:7:in `<top (required)>'
        from /home/svr/bin/fpm:23:in `load'
        from /home/svr/bin/fpm:23:in `<main>'
@jordansissel
Copy link
Owner

Confirmed. I upgraded pip on my workstation and tested this:

% python3 -m pip download --no-clean --no-deps --no-binary :all: -i https://pypi.python.org/simple --build /tmp/zt gcalc
li
DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated and has no effect anymore. pip 21.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.

@jordansissel
Copy link
Owner

No response on my comment about fpm using --build -- pypa/pip#8333 (comment)

We'll probably have to find a workaround instead of having pip help us.

@zpl
Copy link

zpl commented Jan 16, 2022

I have same probs, and now im building packages this this way (it's enough for my local needs):

sudo python3 -m pip install --root tmp --system ujson
fpm -s dir -t deb -n python39-ujson -v 5.1.0 --iteration 1 ./tmp/=/

Hope it helps in finding workaround

@Jayfrown
Copy link

Jayfrown commented Apr 8, 2022

@jordansissel Any update or workaround on this? Using an outdated pip version is becoming harder to maintain as well.

@jordansissel
Copy link
Owner

@Jayfrown I haven't found a solution yet. I think we can remove the --build flag and unpack the downloaded .tar.gz produced by pip download ... but haven't tested much yet.

@jordansissel
Copy link
Owner

The above comment wasn't quite clear, sorry.

The --build flag was removed in upstream pip, and newer pip versions fail because this flag doesn't exist. It works fine in older pip versions.

For newer pip versions, if I try removing the --build flag, pip will fetch the python package as requested and leave it in the target directory as a tarball. I don't know if it'll work, but we can teach fpm to take this tarball and install it with python -- might work?

jordansissel added a commit that referenced this issue May 1, 2022
Previously, fpm would use `pip download ... --build ...` to instruct pip
to unpack a given python package to a specific directory for the purpose
of running something like `python setup.py` from it.

However, somewhere in 2021, pip removed this flag. First, I think, it
was deprecated and ignored, then finally removed. One reference to
this removal in the upstream pip project is this issue:
pypa/pip#8333

Without `--build`, pip will place a single tarball in the destination
directory. Fpm cannot easily predict the name of this file because we
don't know the "real" name of the python package nor do we know the
version number being downloaded.

For example:

```
% python3 -m pip download --no-binary :all: --no-deps --no-clean django
...
Successfully downloaded django
% ls
Django-4.0.4.tar.gz
```

Best guess:
* we can expect exactly one file in the previously-empty target directory
* we can also expect that it is a .tar.gz

I don't know if these guesses are always correct, but it's a start.

As of this commit, the following command generates a Debian package:

`fpm -s python --python-bin python3 -t deb django`

Prior to this commit, with a newer version of pip, the command would
fail.

Fixes #1831
@jordansissel
Copy link
Owner

I think this works: #1896

jordansissel added a commit that referenced this issue May 2, 2022
Previously, fpm would use `pip download ... --build ...` to instruct pip
to unpack a given python package to a specific directory for the purpose
of running something like `python setup.py` from it.

However, somewhere in 2021, pip removed this flag. First, I think, it
was deprecated and ignored, then finally removed. One reference to
this removal in the upstream pip project is this issue:
pypa/pip#8333

Without `--build`, pip will place a single tarball in the destination
directory. Fpm cannot easily predict the name of this file because we
don't know the "real" name of the python package nor do we know the
version number being downloaded.

For example:

```
% python3 -m pip download --no-binary :all: --no-deps --no-clean django
...
Successfully downloaded django
% ls
Django-4.0.4.tar.gz
```

Best guess:
* we can expect exactly one file in the previously-empty target directory
* we can also expect that it is a .tar.gz

I don't know if these guesses are always correct, but it's a start.

As of this commit, the following command generates a Debian package:

`fpm -s python --python-bin python3 -t deb django`

Prior to this commit, with a newer version of pip, the command would
fail.

Fixes #1831
@jordansissel
Copy link
Owner

#1896 should solve this.

@jordansissel
Copy link
Owner

fpm 1.15.0 is released and contains this improvement.

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

Successfully merging a pull request may close this issue.

4 participants