{"id":24976019,"url":"https://github.com/dulingkang/exeu","last_synced_at":"2025-03-29T08:16:20.669Z","repository":{"id":63896083,"uuid":"571572302","full_name":"dulingkang/exeu","owner":"dulingkang","description":"execute python code using string, PyPI test. Instruct how to build a PyPI.","archived":false,"fork":false,"pushed_at":"2022-11-28T13:58:13.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T16:18:31.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dulingkang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-28T12:27:58.000Z","updated_at":"2022-11-28T13:55:27.000Z","dependencies_parsed_at":"2023-01-14T12:30:16.010Z","dependency_job_id":null,"html_url":"https://github.com/dulingkang/exeu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dulingkang%2Fexeu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dulingkang%2Fexeu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dulingkang%2Fexeu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dulingkang%2Fexeu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dulingkang","download_url":"https://codeload.github.com/dulingkang/exeu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156416,"owners_count":20732397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-03T21:59:15.935Z","updated_at":"2025-03-29T08:16:20.649Z","avatar_url":"https://github.com/dulingkang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"execute python code using string, PyPI test. Instruct how to build a PyPI.\n# Python打包上传PyPI\n## 注册 PyPI\n在[PyPI](https://pypi.org/)注册帐号\n## 准备含有 setup.py 的Python 项目\n[项目地址](https://github.com/dulingkang/exeu)\n目录结构：\n![目录结构](./pic/exeu_code_struct.png)\n\n### exeu 目录\nexeu 目录为源码目录，一般一个项目下，需要有一个源码目录\n\n### core.py\n具体实现文件\n\ncore.py \n```python\ndef ev(s: str):\n    return eval(s)\n```\n实现 eval 的功能。\n\n### init 文件\n源码目录下的__init__文件需要引入需要暴露的接口，以及 version 定义。\n__init__.py 文件\n```python\n__version__ = \"0.0.1\"\n\nfrom .core import *\n```\n\n### setup.py 文件\n打包成 PyPI 的配置文件\n```python\n# -*- coding: utf-8 -*-\n\nimport io\nimport os\nimport re\n\nfrom setuptools import find_packages\nfrom setuptools import setup\n\n# version\nhere = os.path.abspath(os.path.dirname(__file__))\nwith open(os.path.join(here, 'exeustr', '__init__.py'), 'r') as f:\n  init_py = f.read()\nversion = re.search('__version__ = \"(.*)\"', init_py).groups()[0]\n\n# obtain long description from README\nwith io.open(os.path.join(here, 'README.md'), 'r', encoding='utf-8') as f:\n  README = f.read()\n\n# installation packages\npackages = find_packages()\n\n# setup\nsetup(\n  name='exeustr',\n  version=version,\n  description='execute python code using string',\n  long_description=README,\n  long_description_content_type=\"text/markdown\",\n  author='dulingkang',\n  author_email='dulingkang@163.com',\n  packages=packages,\n  python_requires='\u003e=3.7',\n  install_requires=[],\n  url='https://github.com/dulingkang/exeu',\n  project_urls={\n    \"Bug Tracker\": \"https://github.com/dulingkang/exeu/issues\",\n    \"Documentation\": \"https://github.com/dulingkang/exeu\",\n    \"Source Code\": \"https://github.com/dulingkang/exeu\",\n  },\n  keywords=('exeucate eval, '\n            'pipy test, '\n            'python instruction, '),\n  classifiers=[\n    'Natural Language :: English',\n    'Operating System :: OS Independent',\n    'Programming Language :: Python',\n    'Programming Language :: Python :: 3',\n    'Programming Language :: Python :: 3.7',\n    'Programming Language :: Python :: 3.8',\n    'Programming Language :: Python :: 3.9',\n    'Programming Language :: Python :: 3.10',\n    'Intended Audience :: Science/Research',\n    'License :: OSI Approved :: Apache Software License',\n    'Topic :: Scientific/Engineering :: Bio-Informatics',\n    'Topic :: Scientific/Engineering :: Mathematics',\n    'Topic :: Scientific/Engineering :: Artificial Intelligence',\n    'Topic :: Software Development :: Libraries',\n  ],\n  license='Apache-2.0 license',\n)\n```\n上述主要参数解析:\n- name：库名\n- version：版本号\n- author：作者\n- author_email：作者邮箱（如：发现 bug，可以联系邮箱处理）\n- description：简要描述\n- long_description：详细描述（一般会写在README.md中）\n- long_description_content_type：README.md中描述的语法（一般为markdown)\n- install_requires: 依赖的其它 Python 包\n- url：库/项目主页，一般我们把项目托管在GitHub，放该项目的GitHub地址即可\n- packages：使用setuptools.find_packages()即可，这个是方便以后我们给库拓展新功能的（详情请看官方文档）\n- classifiers：指定该库依赖的Python版本、license、操作系统之类的\n- license: 使用协议名称\n\n## 安装 PyPI 工具包\ninstall `setuptools` 和 `wheel` 和 `twine`\n```\npython3 -m pip install --user --upgrade setuptools wheel twine\n```\n\n## 打包\n打包前，需要先 check setup.py 中有没有错误：\n```\npython3 setup.py check\n```\n\n确认无误后，执行打包：\n```\npython3 setup.py sdist bdist_wheel\n```\n完成后，会生成 `dist` 文件夹\n\n## 上传\n使用 `twine` 将打好的包上传到 `PyPI`\n\n使用如下命令上传：\n```\nTWINE_PASSWORD=your_password TWINE_USERNAME=your_name twine upload dist/*\n```\n`your_name`, `your_password`, 输入第一步在 PyPI注册的用户名和密码。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdulingkang%2Fexeu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdulingkang%2Fexeu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdulingkang%2Fexeu/lists"}