Ticket #7467 (closed enhancement: fixed)
Make SageNB use `setuptools` instead of `distutils`
| Reported by: | timdumol | Owned by: | boothby |
|---|---|---|---|
| Priority: | major | Milestone: | sage-4.3 |
| Component: | notebook | Keywords: | |
| Cc: | mpatel, was | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Mitesh Patel |
| Authors: | Tim Dumol | Merged in: | |
| Dependencies: | Stopgaps: |
Description
Currently, SageNB makes use of distutils. The standard method of package distribution, though, is setuptools. This has several advantages, the foremost being a setup.py develop command, which bypasses the need to reinstall the package in order to propagate a change, as well as the ability to upload the package to PyPI with a single command. There is also additional functionality regards packaging, etc.
Attachments
Change History
Changed 4 years ago by timdumol
-
attachment
trac_7467-setuptools.patch
added
Makes setup.py use setuptools instead of distutils. Depends on #7402 for things to work properly.
Changed 4 years ago by timdumol
-
attachment
trac_7467-setuptools.2.patch
added
Added necessary .hgignore lines.
comment:2 follow-up: ↓ 3 Changed 4 years ago by mpatel
- Authors set to Tim Dumol
What are your thoughts about
? I found these links at Tools of the Modern Python Hacker: Virtualenv, Fabric and Pip.
comment:3 in reply to: ↑ 2 Changed 4 years ago by timdumol
Replying to mpatel:
What are your thoughts about
? I found these links at Tools of the Modern Python Hacker: Virtualenv, Fabric and Pip.
These tools are orthogonal to usage of setuptools, to note.
I personally make use of Virtualenv and Pip all the time for deployment. They're very useful for keeping one's site-packages clean.
comment:4 follow-ups: ↓ 5 ↓ 7 Changed 4 years ago by mpatel
Thanks for the clarification. What if we use pip (i.e., pip.py) as SageNB's installer? The uninstall facility might allow us to select among different development versions (and their requirements) in a clean way. Currently, extraneous files can "accumulate" in site-packages/sagenb until I do rm -rf and reinstall.
Disclaimer: I'm not familiar with distutils, pip, or setuptools.
On #7447: Can we query the installed version of a package with setuptools and/or pip?
comment:6 in reply to: ↑ 5 Changed 4 years ago by timdumol
Replying to timdumol:
Replying to mpatel:
[...] On #7447: Can we query the installed version of a package with setuptools and/or pip?
I believe something like this should do the trick:
from pkg_resources import Requirement, working_set version = working_set.find9Requirement.parse('sagenb')).version
Sorry, I meant working_set.find(Requirement.parse('sagenb')).version
comment:7 in reply to: ↑ 4 Changed 4 years ago by timdumol
Replying to mpatel:
Thanks for the clarification. What if we use pip (i.e., pip.py) as SageNB's installer? The uninstall facility might allow us to select among different development versions (and their requirements) in a clean way. Currently, extraneous files can "accumulate" in site-packages/sagenb until I do rm -rf and reinstall. ..
Wow, that feature's new. I don't see why not, although it would mean adding another package to Sage.
comment:8 follow-up: ↓ 9 Changed 4 years ago by mpatel
I get
sage: from pkg_resources import Requirement, working_set sage: working_set.find(Requirement.parse('sagenb')).version AttributeError: 'NoneType' object has no attribute 'version'
On using pip: We could just add pip.py, according to this.
comment:9 in reply to: ↑ 8 Changed 4 years ago by timdumol
Replying to mpatel:
I get
sage: from pkg_resources import Requirement, working_set sage: working_set.find(Requirement.parse('sagenb')).version AttributeError: 'NoneType' object has no attribute 'version'On using pip: We could just add pip.py, according to this.
I believe detection of version using pkg_resources requires it be installed by setuptools, i.e., this patch.
comment:10 Changed 4 years ago by mpatel
OK, or pip, I suppose. Thanks. I'll put a note at #7447.
comment:11 Changed 3 years ago by mpatel
- Status changed from needs_review to positive_review
- Report Upstream set to N/A
Although I'm not very familar with distutils or setuptools, this works for and looks good to me. A spkg built with spkg-dist installs properly. Moreover, we can query the sagenb version just as indicated in the comments above.
comment:13 Changed 3 years ago by was
- Status changed from positive_review to closed
- Resolution set to fixed
+1!

This should do it.