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

Installation with --pure doesn't seem to work any more #1093

Closed
aplaice opened this issue Nov 10, 2022 · 4 comments · Fixed by #1094
Closed

Installation with --pure doesn't seem to work any more #1093

aplaice opened this issue Nov 10, 2022 · 4 comments · Fixed by #1094

Comments

@aplaice
Copy link
Contributor

aplaice commented Nov 10, 2022

It seems that the method of installing without C bindings recommended in the README doesn't work.

To reproduce

Clone from master and run:

python3 setup.py --pure install

(Or alternatively run pip3 install dulwich --global-option="--pure".)

Expected behaviour

Dulwich is set up without the C extensions.

Actual behaviour

The following error message is raised:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: option --pure not recognized

Speculation

I suspect that the commit 3b22cba273693e20c491de48cfdcbc30ab0c517d caused the change in behaviour, but haven't investigated further.

Context

I use the "pure" version of Dulwich for an add-on for Anki (CrowdAnki), which has to be distributable in the same form for all platforms, and hence can't rely on compiled C code. This worked with previous versions of Dulwich (e.g. 0.20.24), but doesn't work with the latest version.


Thanks for the extremely useful package!

jelmer added a commit that referenced this issue Nov 10, 2022
@jelmer jelmer mentioned this issue Nov 10, 2022
@aplaice
Copy link
Contributor Author

aplaice commented Nov 10, 2022

Thanks so much for the fast fix! (setupy.py with --pure does indeed work now!)

@jelmer
Copy link
Owner

jelmer commented Nov 10, 2022

No worries, thanks for the report.

Ideally setuptools would add some functionality than does this..

@aplaice
Copy link
Contributor Author

aplaice commented Jan 30, 2023

Sorry to bother you again, for something that's totally not your fault (but is due to the changes in pip and setuptools), but unfortunately, it's still the case that neither pip install dulwich --global-option="--pure" nor pip install --no-binary dulwich -r <(echo 'dulwich --global-option="--pure"') (i.e. using requirements.txt) works to get a pure-python install (with or without --no-binary) (--install-option etc. also doesn't work).

(Tested with pip 22.3.1.)

python setup.py install --pure and python setup.py bdist_wheel --pure both function as expected.

Unfortunately, with PEP517 (I think), setuptools/pip do not pass the "--global-option" (when it's passed in this way) to setup.py. (setup.py is, however, still being called, to obtain the ext_modules.)


After some investigations, it seems that (either of) the two following monstrosities do work (producing a pure-python install):

pip install --no-binary dulwich dulwich --config-settings "--global-option=--pure"
pip install --no-binary dulwich dulwich --config-settings "--build-option=--pure"

(--no-binary is needed to avoid using the wheels from PyPi which logically do contain the built C bindings.)

However, (while I'll probably be using one of them for my use (in CrowdAnki)), I'm not sure if they're the correct approach (there might be something less verbose). It also seems that --config-settings cannot (yet) be specified in requirements.txt (pypa/pip#11325). Hence, I'm not opening a PR to update the docs.

(Sorry for not having tested this at the time, but I had assumed that if setup.py worked then so would pip.)

@jelmer
Copy link
Owner

jelmer commented Jan 30, 2023

Unfortunately the pip ecosystem is out of Dulwich' control :) I'm happy to take a PR that updates the instructions for pip.

I'm also somewhat leaning towards just drop those instructions, rather than trying to chase pip and come up with workarounds. Ideally this would be fixed with a flag in upstream pip to indicate you prefer pure packages.

aplaice added a commit to aplaice/dulwich that referenced this issue May 23, 2023
See: jelmer#1093.

Currently, both --global-option=--pure and --build-option=--pure
work (when set in --config-settings).  However, using --global-option
in this way is considered deprecated:

https://setuptools.pypa.io/en/latest/history.html#id139

pypa/setuptools#3380

--no-binary is needed to prevent pip installing the pre-built wheels
from pypi.org.
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.

2 participants