#422 Improve readme for virtualenv; Fix pygit2 version comparison.
Closed 3 years ago by pingou. Opened 3 years ago by dmach.
dmach/pagure readme-pygit2-fixes  into  master

file modified
+23 -2

@@ -26,6 +26,20 @@ 

  * Retrieve the sources::

  

      git clone git://github.com/pypingou/pagure

+     cd pagure

+ 

+ 

+ * Install dependencies

+ 

+   * development virtualenv::

+ 

+       dnf install libgit2-devel

+       virtualenv devel

+       devel/bin/pip install -r requirements.txt

+ 

+   * Fedora RPMs::

+ 

+       dnf install $(cat requirements-fedora.txt)

  

  

  * Create the folder that will receive the projects, forks, docs and tickets'

@@ -36,19 +50,26 @@ 

  

  * Create the inital database scheme::

  

+     # development virtualenv only

+     source devel/bin/activate

+ 

      python createdb.py

  

  

  * Run it::

  

+     # development virtualenv only

+     source devel/bin/activate

+ 

      ./runserver.py

  

  

  * To get some profiling information you can also run it as::

  

-     ./runserver.py --profile

+     # development virtualenv only

+     source devel/bin/activate

  

+     ./runserver.py --profile

  

  

  This will launch the application at http://127.0.0.1:5000

- 

file modified
+7

@@ -32,6 +32,13 @@ 

  # pylint: disable=R0913,E1101,R0914

  

  

+ def get_pygit2_version():

I am wondering if we shouldn't put this directly in repo.py, what do you think?

+     ''' Return pygit2 version as a tuple of integers.

+     This is needed for correct version comparison.

+     '''

+     return tuple([int(i) for i in pygit2.__version__.split('.')])
ralph commented 3 years ago

Also, it seems this will work, but I've grown fond of using distutils.version.LooseVersion(...) for comparisons like this.

+ 

+ 

  def commit_to_patch(repo_obj, commits):

      ''' For a given commit (PyGit2 commit object) of a specified git repo,

      returns a string representation of the changes the commit did in a

file modified
+3 -1

@@ -13,6 +13,7 @@ 

  

  import pagure

  import pagure.exceptions

+ import pagure.lib.git

  

  

  class PagureRepo(pygit2.Repository):

@@ -24,7 +25,8 @@ 

      @staticmethod

      def push(remote, refname):

          """ Push the given reference to the specified remote. """

-         if pygit2.__version__.startswith('0.22'):

+         pygit2_version = pagure.lib.git.get_pygit2_version()

+         if pygit2_version >= (0, 22):

              remote.push([refname])

          else:

              remote.push(refname)

@@ -0,0 +1,11 @@ 

+ python-arrow

+ python-bleach

+ python-flask

+ python-flask-wtf

+ python-jinja2

+ python-markdown

+ python-openid-cla

+ python-openid-teams

+ python-redis

+ python-sqlalchemy

+ python-straight-plugin

no initial comment

I am wondering if we shouldn't put this directly in repo.py, what do you think?

Also, it seems this will work, but I've grown fond of using distutils.version.LooseVersion(...) for comparisons like this.

@pingou, maybe we should just merge this and fix it to our liking post-facto.

Ok, I'm merging this manually (to avoid the merge commit) and will adjust it post-facto as suggested by @ralph.