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

Adding geeadd to conda-forge #10

Closed
giswqs opened this issue Apr 24, 2020 · 11 comments
Closed

Adding geeadd to conda-forge #10

giswqs opened this issue Apr 24, 2020 · 11 comments

Comments

@giswqs
Copy link

giswqs commented Apr 24, 2020

I plan to incorporate geeadd into the geemap package, making geeadd one of the dependencies. It would be nice to have this package available on conda-forge. Here is the instruction for adding a package to conda-forge. You can create a meta.yaml using conda skeleton pypi geeadd. Then fork conda-forge/staged-recipes and add a geeadd folder with the meta.yaml and LICENSE to the recipes folder. Submit a pull request and wait for the review and approval. I can help in this regard if needed. Thanks.

@samapriya
Copy link
Owner

Hi @giswqs
I forked the repo and created the yaml file, would you mind checking and letting me know what else I am missing. I created the meta.yaml using conda skeleton pypi geeadd as suggested. I zipped the file because github doesn't allow for yaml attachment.

meta.zip

Added the yaml file here . Let me know and I can submit a pull request based on any other edits as needed.

@samapriya samapriya reopened this Apr 25, 2020
@giswqs
Copy link
Author

giswqs commented Apr 25, 2020

Your meta.yaml seems to be a bit different from what I generated from using conda skeleton pypi geeadd. See this meta.yaml.

Following conda-forge's guidelines, a few edits are needed:

  1. Added noarch: python to build
  2. For this host, you only need pip and python. All dependencies are placed within run
  3. You will need to put the LICENSE file within your recipe folder. Check out my geemap-feedstock on conda-forge. You can also check my previous pull-request.

@samapriya
Copy link
Owner

Thanks @giswqs
Do I need to specify that it is only compatible with python3 somewhere in the yaml file? Would you mind checking again here if the yaml file and license file placements is correct?

https://github.com/samapriya/staged-recipes/tree/master/recipes/geeadd

@giswqs
Copy link
Author

giswqs commented Apr 25, 2020

It looks good to me. I believe you don't need to specify Python version in meta.yaml. Python versions are already specified in the setup.py of the package, which meta.ymal will inherit from.

@samapriya
Copy link
Owner

build seems to work in osx and windows but is failing during merge check for Linux. Would you mind taking a look?
conda-forge/staged-recipes#11374

@samapriya
Copy link
Owner

samapriya commented Apr 25, 2020

Hey @giswqs
Got it to work the yaml needed git to be available in the system. Will not wait for approval to be added I guess?

@giswqs
Copy link
Author

giswqs commented Apr 25, 2020

Great work! Just wait for the conda-forge team to review it.

@giswqs
Copy link
Author

giswqs commented Apr 25, 2020

It seems GitPython requires Git to be installed on the computer. This would be a barrier for users without Git on their computer. I would suggest replacing it with the built-in library urllib if you are only downloading files from GitHub. See my examples here and here.

@giswqs
Copy link
Author

giswqs commented Apr 25, 2020

You can replace Lines 213-216 with urllib. See my sample functions below.

    Repo.clone_from(
        "https://github.com/samapriya/Earth-Engine-Datasets-List.git",
        os.path.join(lpath, folder_name),
    )
def download_from_url(url, out_file_name=None, out_dir='.', unzip=True):
    """Download a file from a URL (e.g., https://github.com/giswqs/whitebox/raw/master/examples/testdata.zip)
    Args:
        url (str): The HTTP URL to download.
        out_file_name (str, optional): The output file name to use. Defaults to None.
        out_dir (str, optional): The output directory to use. Defaults to '.'.
        unzip (bool, optional): Whether to unzip the downloaded file if it is a zip file. Defaults to True.
    """
    in_file_name = os.path.basename(url)

    if out_file_name is None:
        out_file_name = in_file_name
    out_file_path = os.path.join(os.path.abspath(out_dir), out_file_name)

    print('Downloading {} ...'.format(url))

    try:
        urllib.request.urlretrieve(url, out_file_path)
    except:
        print("The URL is invalid. Please double check the URL.")
        return

    final_path = out_file_path

    if unzip:
        # if it is a zip file
        if '.zip' in out_file_name:
            print("Unzipping {} ...".format(out_file_name))
            with zipfile.ZipFile(out_file_path, "r") as zip_ref:
                zip_ref.extractall(out_dir)
            final_path = os.path.join(os.path.abspath(
                out_dir), out_file_name.replace('.zip', ''))

        # if it is a tar file
        if '.tar' in out_file_name:
            print("Unzipping {} ...".format(out_file_name))
            with tarfile.open(out_file_path, "r") as tar_ref:
                tar_ref.extractall(out_dir)
            final_path = os.path.join(os.path.abspath(
                out_dir), out_file_name.replace('.tart', ''))

    print('Data downloaded to: {}'.format(final_path))

def clone_repo(out_dir='.', unzip=True):
    """Clones the geemap GitHub repository.
    Args:
        out_dir (str, optional): Output folder for the repo. Defaults to '.'.
        unzip (bool, optional): Whether to unzip the repository. Defaults to True.
    """
    url = 'https://github.com/giswqs/geemap/archive/master.zip'
    filename = 'geemap-master.zip'
    download_from_url(url, out_file_name=filename,
                      out_dir=out_dir, unzip=unzip)

samapriya added a commit that referenced this issue Apr 25, 2020
- Removed git dependency and used urllib instead based on [feedback](#10)
- Created conda forge release based on [Issue 10](#10)
@samapriya
Copy link
Owner

Used urllib method and modified a few lines to get the desired effect. All checks completed for the new version 0.4.4 and conda-forge yaml file was updated to remove git and updated to v0.4.4. This is also better since it reduces dependency on the project. Thanks for the suggestions, closing this for now.

@giswqs
Copy link
Author

giswqs commented Apr 26, 2020

Excellent! Thank you for your prompt action!

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

No branches or pull requests

2 participants