Opened 5 years ago

Closed 5 years ago

#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 Merged in:
Authors: Tim Dumol Reviewers: Mitesh Patel
Report Upstream: N/A Work issues:
Branch: Commit:
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 (2)

trac_7467-setuptools.patch (1.2 KB) - added by timdumol 5 years ago.
Makes setup.py use setuptools instead of distutils. Depends on #7402 for things to work properly.
trac_7467-setuptools.2.patch (1.4 KB) - added by timdumol 5 years ago.
Added necessary .hgignore lines.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 5 years ago by timdumol

  • Status changed from new to needs_review

This should do it.

Changed 5 years ago by timdumol

Makes setup.py use setuptools instead of distutils. Depends on #7402 for things to work properly.

Changed 5 years ago by timdumol

Added necessary .hgignore lines.

comment:2 follow-up: Changed 5 years ago by mpatel

  • Authors set to Tim Dumol

comment:3 in reply to: ↑ 2 Changed 5 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: Changed 5 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:5 in reply to: ↑ 4 ; follow-up: Changed 5 years ago by 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

comment:6 in reply to: ↑ 5 Changed 5 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 5 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: Changed 5 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 5 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 5 years ago by mpatel

OK, or pip, I suppose. Thanks. I'll put a note at #7447.

comment:11 Changed 5 years ago by mpatel

  • Report Upstream set to N/A
  • Status changed from needs_review to positive_review

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:12 Changed 5 years ago by mpatel

  • Reviewers set to Mitesh Patel

comment:13 Changed 5 years ago by was

  • Resolution set to fixed
  • Status changed from positive_review to closed

+1!

Note: See TracTickets for help on using tickets.