#17 Assorted code structure related cleanups
Merged 6 years ago by ncoghlan. Opened 6 years ago by ncoghlan.

file modified
+5 -5
@@ -1,16 +1,16 @@ 

  [[source]]

+ 

  url = "https://pypi.python.org/simple"

  verify_ssl = true

  

+ 

  [dev-packages]

  

  pytest = "*"

  six = "*"

- snakeviz = "*"

+ 

  

  [packages]

  

- fedmod = {editable = true, path = "."}

- "requests-toolbelt" = "*"

- click = "*"

- attrs = "*" 

\ No newline at end of file

+ # Runtime dependencies should go in src/setup.py rather than here

+ fedmod = {editable = true, path = "src"}

file modified
+2 -147
@@ -1,7 +1,7 @@ 

  {

      "_meta": {

          "hash": {

-             "sha256": "eb22a789500751e490310d5c8e96e2d6d51d9f89adcf0f5d88ea79641e1fa8b3"

+             "sha256": "65629a979a8af096bf2e21c52c0b0ad16b9f7a80006bbd74e10bec82ab03fcda"

          },

          "host-environment-markers": {

              "implementation_name": "cpython",
@@ -26,137 +26,9 @@ 

          ]

      },

      "default": {

-         "attrs": {

-             "hashes": [

-                 "sha256:a7e0d9183f6457de12df7ba6a81f6569c7d6b25f67ad509b5ad52e8545970a2f",

-                 "sha256:5d4d1b99f94d69338f485984127e4473b3ab9e20f43821b0e546cc3b2302fd11"

-             ],

-             "version": "==17.2.0"

-         },

-         "certifi": {

-             "hashes": [

-                 "sha256:54a07c09c586b0e4c619f02a5e94e36619da8e2b053e20f594348c0611803704",

-                 "sha256:40523d2efb60523e113b44602298f0960e900388cf3bb6043f645cf57ea9e3f5"

-             ],

-             "version": "==2017.7.27.1"

-         },

-         "chardet": {

-             "hashes": [

-                 "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691",

-                 "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"

-             ],

-             "version": "==3.0.4"

-         },

-         "click": {

-             "hashes": [

-                 "sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",

-                 "sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"

-             ],

-             "version": "==6.7"

-         },

          "fedmod": {

              "editable": true,

-             "path": "."

-         },

-         "idna": {

-             "hashes": [

-                 "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4",

-                 "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f"

-             ],

-             "version": "==2.6"

-         },

-         "lxml": {

-             "hashes": [

-                 "sha256:7a8715539adb41c78129983ba69d852e0102a3f51d559eeb91dce1f6290c4ad0",

-                 "sha256:d3a98dda9831a37ef7f55c5e69c0d276c278f24978f5b36b9fad7eac05a22bfc",

-                 "sha256:1deacd52638da2d7fcb864c3949f0285638ec10e6aace93ce15c6a2e0ed91b95",

-                 "sha256:1548247ea3b50014a3ea55ad9446108df191b6a6e51aa8f5953c95b663f382ff",

-                 "sha256:5da6f5b31ea2b573cb20e88aefc6b49d849d07588ba60871342cae42f569b0d7",

-                 "sha256:12e348eb57fb79ccf91a49b7b937c49a5bbe1d73ba75589674b76a56d064bda0",

-                 "sha256:b9e1735918fc1e83c522b9f1048e6bc5af38af958e4efc843046e4b0075a021b",

-                 "sha256:fafeb4b190bd63ba2bcee2496d99cb7345fafbace6b999403010abdff8c05b72",

-                 "sha256:9007da6fb1b96fb1c9d7bd65e97bbbad60295abc19833d7e67e05314c1868f58",

-                 "sha256:cfbf0b956f33cda3af2a1438a2541549b69a7a240e71de7d8ca819b8f1547aac",

-                 "sha256:0a103253a94cdad86028d273aaebb8b30c75fdf009c23e52cdc8ce88429fd326",

-                 "sha256:b3d5a0ecf0c2c31c404246b6706b2e477159ee07b73be5102389ab250dd67701",

-                 "sha256:e92af0fd08c7d2176ad4be4a7c47fd800d6ee05046b41e36ed579c01fb106c25",

-                 "sha256:feb2144c2ae4035ad57165dd22bdc93b1389158a985c0497a096d39e2b2cd67b",

-                 "sha256:a4433655219b84a360dbdf2c34d9625c3988a272e6fc028222d528ad5902f6a2",

-                 "sha256:db98287cb1488eb103930a64444542f6ffe83694ef392f801aa56d648d905663",

-                 "sha256:307d325ee143b60b9c82912e96e9f4345200c33c8ae00b04b001e4c85fb5f146",

-                 "sha256:5caec9b174dbf927034d588669c62d2a9d0ce447365b20a3463f4daab1e4f03b",

-                 "sha256:fb816595494ce21191764572215f56edfbc6d9fbebd1491c8466502892989689",

-                 "sha256:10399bececdb67f0d9251ecf2dda2abf6ddeee6096741754356f1a3715c8c830",

-                 "sha256:c263fd15d27f3be93485fcd83a495cbbc35352512d9e31644d49a54504a1be2a",

-                 "sha256:c10ad53216d5af2b3ba63e65db793cb7dd7e598e17826938045e32f38b0e4814",

-                 "sha256:d42a5182d4b0953d02e5f46c9f0dc304be736fbaa1c0d2f11326182b9684b5f4",

-                 "sha256:dd7c22bf890d266e72c5e5c8c44555ffbfe4ca2a329da785e7d8b1972fc3ff74",

-                 "sha256:93df9805146980e83834ea9320baa6a56d8aea45f63d7d3cc721f71eb1a1bac6",

-                 "sha256:7ba1b62fe9414d73d493241011df952b72074808debc3a2d6d8a64fb9944edf6",

-                 "sha256:d2c121f5f77bed1e1eddeee23ee76fee8a3d48fa7a3aab589d12942f87778a9e",

-                 "sha256:be3aaeb5f468a49f523f16736ccff7d82af2b4b303292ba3d052b5b28f3fbe47"

-             ],

-             "version": "==4.1.0"

-         },

-         "modulemd": {

-             "hashes": [

-                 "sha256:59e66590f4a2e301c629cc83f3696723b1da19ee93a038311dc97bf5713dcccd"

-             ],

-             "version": "==1.3.2"

-         },

-         "python-dateutil": {

-             "hashes": [

-                 "sha256:95511bae634d69bc7329ba55e646499a842bc4ec342ad54a8cdb65645a0aad3c",

-                 "sha256:891c38b2a02f5bb1be3e4793866c8df49c7d19baabf9c1bad62547e0b4866aca"

-             ],

-             "version": "==2.6.1"

-         },

-         "pyyaml": {

-             "hashes": [

-                 "sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f",

-                 "sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736",

-                 "sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269",

-                 "sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8",

-                 "sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4",

-                 "sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1",

-                 "sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",

-                 "sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3",

-                 "sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8",

-                 "sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6",

-                 "sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca",

-                 "sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8",

-                 "sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608",

-                 "sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7"

-             ],

-             "version": "==3.12"

-         },

-         "requests": {

-             "hashes": [

-                 "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b",

-                 "sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e"

-             ],

-             "version": "==2.18.4"

-         },

-         "requests-toolbelt": {

-             "hashes": [

-                 "sha256:42c9c170abc2cacb78b8ab23ac957945c7716249206f90874651971a4acff237",

-                 "sha256:f6a531936c6fa4c6cfce1b9c10d5c4f498d16528d2a54a22ca00011205a187b5"

-             ],

-             "version": "==0.8.0"

-         },

-         "six": {

-             "hashes": [

-                 "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb",

-                 "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"

-             ],

-             "version": "==1.11.0"

-         },

-         "urllib3": {

-             "hashes": [

-                 "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b",

-                 "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"

-             ],

-             "version": "==1.22"

+             "path": "src"

          }

      },

      "develop": {
@@ -180,23 +52,6 @@ 

                  "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"

              ],

              "version": "==1.11.0"

-         },

-         "snakeviz": {

-             "hashes": [

-                 "sha256:ef58335fe20e71384668159899985e6802bf668d1c82bb5ccd90592aba3b9ec2",

-                 "sha256:adc95ec5eb0a04bc2aa8325e8a713b9aa82ccb30425f9efe0e4d7479e2fa3bcb"

-             ],

-             "version": "==0.4.2"

-         },

-         "tornado": {

-             "hashes": [

-                 "sha256:62a5d4c66bf4e86d25a02e9de97293860b59e61f9c465e80336ba0fc308aacf6",

-                 "sha256:f109c066411c44bcd3bc877267b45feb8e29092ede59dd0582739444c2344b00",

-                 "sha256:e66f47db4753c6f6849af1f82f04bdc7d2c1f5d64b7cc11ddd17230295c8887f",

-                 "sha256:2b40720a7b164848ca5c51fab0feac7e3717adcb87bec77f81f7809b72bf7f56",

-                 "sha256:1fb8e494cd46c674d86fac5885a3ff87b0e283937a47d74eb3c02a48c9e89ad0"

-             ],

-             "version": "==4.5.2"

          }

      }

  }

file modified
+49 -26
@@ -6,21 +6,23 @@ 

  

  Currently, this consists of:

  

- * `python -m fedmod rpm2module`: generates a draft modulemd file based on

+ * `fedmod rpm2module`: generates a draft modulemd file based on

    the given RPM name (multiple RPM names can be given, but the resulting

    draft module will lack any descriptive metadata in that case)

- * `python -m fedmod fetch-metadata`: download the F27 Modular Server repository

-   metadata needed to generate draft module definitions

+ * `fedmod fetch-metadata`: download the F27 package and module metadata needed

+   to generate draft module definitions (the metadata sets to use are not yet

+   configurable)

  

  ## Project status

  

  `fedmod` is not yet released, but can already generate basic draft modules from

  a local development checkout:

  

-     $ pipenv run python -m fedmod rpm2module samba

+     $ pipenv run fedmod fetch-metadata

+     $ pipenv run fedmod rpm2module graphite-web

  

- This will generate a draft `modulemd` file called `samba.yaml` in the current

- directory.

+ This will generate a draft `modulemd` file called `graphite-web.yaml` in the

+ current directory.

  

  See the local development instructions below for info on setting up the

  execution environment with `pipenv`.
@@ -50,20 +52,24 @@ 

  

  ## Modulemd creation

  

- `python -m fedmod rpm2module [RPM NAMES]` creates a modulemd file from the

+ `fedmod rpm2module [RPM NAMES]` creates a modulemd file from the

  given package names. Output is written as `<input-package-name>.yaml` when a

  single package name is given, and `modulemd-output.yaml` otherwise.

  

  The following metadata is currently used as input to the draft module generation

  process:

  

- * Module definitions and package dependencies are pulled from the modular Fedora

-   Bikeshed repository, with the metadata being downloaded for local use via

-   the `python -m fedmod metadata` command

+ * Module definitions are pulled from the modular Fedora Bikeshed repository,

+   with the metadata being downloaded for local use via the

+   `fedmod fetch-metadata` command

+ 

+ * Package dependency definitions are pulled from the regular Fedora 27

+   release and updates repositories, with the metadata being downloaded for

+   local use via the `fedmod fetch-metadata` command

  

  * Descriptive metadata is taken from the system running `fedmod`. Due to this,

    `fedmod` currently only supports Fedora 26+. (This will be fixed to use

-   the same repository metadata as everything else)

+   the same repository metadata as is used for package dependency resolution)

  

  Module dependencies currently err on the side of making the generated modules

  smaller by permitting generated modules to depend on packages that aren't
@@ -87,12 +93,15 @@ 

  

  ### Runtime dependencies

  

- The currently preferred means of dependency management is with `pipenv`:

+ The preferred dependency management tool for development is `pipenv`:

  

      $ pipenv --three --site-packages

      $ PIP_IGNORE_INSTALLED=1 pipenv install --dev

  

- This will pull in the required Python level dependencies from PyPI.

+ The `PIP_IGNORE_INSTALLED=1` setting means that everything available to `pip`

+ will be installed into the virtual environment based on `Pipfile.lock`, and only

+ components that aren't installable with `pip` will be used from the system

+ Python installation.

  

  Some dependencies aren't currently available from PyPI, and hence need to be

  installed system-wide:
@@ -100,31 +109,45 @@ 

      $ sudo dnf install python3-dnf python3-solv

  

  

+ ### Additional development dependencies

  

- ### How to run tests

+ `pipenv` itself isn't packaged for Fedora yet, so the recommended bootstrapping

+ approach is to use the "pip script installer", `pipsi`:

  

- To start a shell that's correctly configured to run the tests with the library

- and all necessary dependencies installed:

+     $ sudo dnf install pipsi

+     $ pipsi install pew

+     $ pipsi install pipenv

+ 

+ This will create a pair of isolated virtual environments in your home directory

+ specifically for `pipenv` and the tool it uses for virtual environment

+ management, `pew`. These can later be updated to newer versions using `pipsi`:

+ 

+     $ pipsi upgrade pew

+     $ pipsi upgrade pipenv

+ 

+ (Note: the `pipsi list` command will list all packages installed via `pipsi`,

+ and the commands they provide)

+ 

+ 

+ ### Running the tests

+ 

+ After going through the environment setup steps above, start a shell that's

+ correctly configured to run the tests with `fedmod` and all of its

+ dependencies available:

  

-     $ pipenv --three --site-packages

-     $ PIP_IGNORE_INSTALLED=1 pipenv install --dev

      $ pipenv shell

  

- The `PIP_IGNORE_INSTALLED=1` setting means that everything available to `pip`

- will be installed into the virtual environment based on `Pipfile.lock`, and only

- components that aren't installable with `pip` will be used from the system

- Python installation.

+ The metadata needed by the module generator tests can then be installed with

+ `fedmod` itself:

  

- See the next section for additional preparation currently needed to run the

- tests.

+     $ fedmod fetch-metadata

  

  The tests can then be run in the launched subshell with:

  

      $ pytest tests

  

- Note: the tests will currently fail. Fixing that is a work in progress :)

  

- ### Reviewing dependencies

+ ### Reviewing project dependencies

  

  To see the Python level dependencies graph:

  

src/MANIFEST.in MANIFEST.in
file renamed
file was moved with no change to the file
src/_fedmod/__init__.py fedmod/__init__.py
file renamed
file was moved with no change to the file
src/_fedmod/__main__.py fedmod/__main__.py
file renamed
file was moved with no change to the file
src/_fedmod/_depchase.py fedmod/_depchase.py
file renamed
file was moved with no change to the file
src/_fedmod/_repodata.py fedmod/_repodata.py
file renamed
file was moved with no change to the file
src/_fedmod/cli.py fedmod/cli.py
file renamed
+15 -18
@@ -54,22 +54,19 @@ 

              return object.__getattribute__(self, name)

  

  

- class ModtoolsCLIHelper(object):

+ def run():

+     try:

+         cli = ModtoolsCLI(sys.argv[1:])

+         if cli.args.verbose:

+             logging.basicConfig(level=logging.INFO)

+         if cli.args.cmd_name == 'rpm2module':

+             mg = ModuleGenerator(cli.args.pkgs)

+             mg.run()

+         elif cli.args.cmd_name == 'fetch-metadata':

+             _repodata.download_repo_metadata()

  

-     @staticmethod

-     def run():

-         try:

-             cli = ModtoolsCLI(sys.argv[1:])

-             if cli.args.verbose:

-                 logging.basicConfig(level=logging.INFO)

-             if cli.args.cmd_name == 'rpm2module':

-                 mg = ModuleGenerator(cli.args.pkgs)

-                 mg.run()

-             elif cli.args.cmd_name == 'fetch-metadata':

-                 _repodata.download_repo_metadata()

- 

-         except KeyboardInterrupt:

-             print('\nInterrupted by user')

-         except Exception as e:

-             logging.exception("Unexpected exception")

-             sys.exit(1)

+     except KeyboardInterrupt:

+         print('\nInterrupted by user')

+     except Exception as e:

+         logging.exception("Unexpected exception")

+         sys.exit(1)

src/_fedmod/module_generator.py fedmod/module_generator.py
file renamed
file was moved with no change to the file
src/setup.py setup.py
file renamed
+3 -2
@@ -18,9 +18,9 @@ 

      license='MIT',

      keywords='modularization modularity module modulemd fedora',

      url='https://pagure.io/modularity/fedmod',

-     entry_point={

+     entry_points={

          'console_scripts': [

-             'fedmod=modularity.cli.ModtoolsCliHelper.run'

+             'fedmod=_fedmod.cli:run'

          ]

      },

      install_requires=[
@@ -29,6 +29,7 @@ 

          'requests',

          'requests-toolbelt',

          'lxml',

+         'attrs',

      ],

      packages=find_packages(),

  )

@@ -1,7 +1,7 @@ 

  import pytest

  import os.path

- from fedmod.cli import ModtoolsCLI

- from fedmod.module_generator import ModuleGenerator

+ from _fedmod.cli import ModtoolsCLI

+ from _fedmod.module_generator import ModuleGenerator

  

  def _generate_modulemd(rpms):

      cmd_input = list(['rpm2module'])